I have Plex Plugin, that works, (https://github.com/stuckless/sagetv-phoenix-plex-channel), and it contains a main Channel (__init__.py), a Search Service and a URL Service.
I need to share code between all 3 parts, and I've googled, and I've search, and I found that you can use a "Libraries/Shared" folder to put in shared code (although I saw in one plugin that it used a "Shared Code" folder... so I'm not 100% sure which is correct).
My problem is that the Libraries/Shared seems fairly useless for actually sharing code between the different parts of my channel. I created a very simple use case ...
In my Shared/Libraries/ I have a file sagedebug.py
def debugit(val='x'):
Log("xxxxxxxxxxxxxxxxxxxx:" + val)
import sagedebug as xdebug
...
def Start():
...
xdebug.debugit('init.py')
2014-01-28 18:51:27,735 (-48dcf700) : CRITICAL (sandbox:306) - Exception when calling function 'Start' (most recent call last):File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 297, in call_named_functionresult = f(*args, **kwargs)File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SageTVPhoenix.bundle/Contents/Code/__init__.py", line 82, in Startxdebug.debugit('init.py')File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SageTVPhoenix.bundle/Contents/Libraries/Shared/sagedebug.py", line 4, in debugitLog("xxxxxxxxxxxxxxxxxxxx:" + val)NameError: global name 'Log' is not defined
So, it would appear that I can't use the Plex Logging facilities from the shared file??
In another case, I replaced the Log statement with a simple print statement to log out the value of a Prefs[] field... and it didn't work :(
print("DEBUG: " + Prefs['server'] )
Again, I get an error that Prefs is not valid.
So, it would appear that I share code code, like a string utility, but I can't use the Plex system in the shared code, and I can't access any Plex Plugin preferences for my channel?? I'm pretty sure I must be doing something wrong, since this is a pretty trival use case.
Currently, to get around this, I have common file, sagex.py, that I actually have to cut and paste into each of my ServiceCode.pys files :( (This is not a very maintainable way to organize "shared" code)
I'd appreciate if anyone could tell me how to properly have a shared code section.
Thanks,