MySQLdb for custom metadata agent

need help for custom agent to access a MySQL database
I made a custom agent to get medtadata from a MySQL database and put this line of code in my agent.
import MySQLdb
And I get this error from the sandbox.py

I'm using Ubuntu 12.04 and I can import MySQLdb and access MySQL tables from my own python code.

I'm getting test error listed in the log file


File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/core.py", line 595, in start
self.sandbox.execute(self.init_code)
File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 256, in execute
exec(code) in self.environment
File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/MythAdult.bundle/Contents/Code/__init__.py", line 5, in
import MySQLdb
File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 345, in __import__
raise e
ImportError: No module named MySQLdb


in looking at the sandbox.py script it has notes of:
class Sandbox(Framework.CoreObject):
"""
Sandbox manages the loading, compilation and execution of restricted code within a plug-in.
Multiple sandboxes can be created and used by the framework. Each sandbox is bound to a Framework
core object and a policy class. The policy dictates the API exposed to the sandboxed code and
which security measures should be used.
"""
def __init__(self, core, code_path, policy, flags=[], identifier = None):
Framework.CoreObject.__init__(self, core)


is using the import for MySQLdb not allowed and is there some override so I can access a MySQL table from a custom agent?

Thanks
Andre

sorry for the bother and not doing better research before asking a Ninja

All I can say it that it was late and I did not complete debuging the agent.



I’m on Ubuntu 12.04





The temp fix was to add to the path the path to the _mysql.so library in my script before importing MySQLdb.



import sys

sys.path.append(’/var/lib/python-support/python2.7’)

import MySQLdb



However, this is only temporary, since when you upgrade python this line could break.



on my system /var/lib/python-support is a link to /usr/lib/pymodules



to find out where your python library are you can user the terminal and key:

dpkg-query -L python-mysqldb



but hey this was a agent I creating for my system, I have mythtv on my system and have most of my video files in it.

One problem I was running into was that Plex movie lookup will find the wrong movie and update the metadata

like the movie taken 2, it will get the information from taken then first movie.



Since I have all of my video files in MythTv that uses a mysql database I wanted to add a option to look there and update the metadata.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.