Lock for Plex Google Chrome App

https://twitter.com/lockforplex/status/663283582832480256

https://www.youtube.com/watch?v=nSQ59fn6Qfw
@lockforplex

https://twitter.com/lockforplex/status/663283582832480256

@iSh0w I’ll take a look as soon as I can. I’ve seen the Python file, but as you instructed I didn’t touch it just in case. I’ll take a look soon as I can, but my kid had. A sleepover so it might be a bit.


Would you prefer I update first so you can have a log?

https://twitter.com/lockforplex/status/663283582832480256

OK tried what you suggested and a couple different things including the full path and the "%LOCALAPPDATA%\Plex Media Server\" path.  No dice.

Here are the logs...

Here’s the variants I tried - Note: I commented out and added back in all the variants once the tests were done (they were not in the file during the tests):


#BASEPATHLOCK = os.path.expanduser("~/AppData/Local/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/lock.bat")

#BASEPATHUNLOCK = os.path.expanduser("~/AppData/Local/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/unlock.bat")


BASEPATHLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+"/Lock.bundle/Contents/Resources/lock_support/lock.bat"))).replace(" “,”\ “)

BASEPATHUNLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+”/Lock.bundle/Contents/Resources/lock_support/unlock.bat"))).replace(" “,”\ “)


#BASEPATHLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+”/Lock.bundle/Contents/Resources/lock_support/lock.bat")))

#BASEPATHUNLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+"/Lock.bundle/Contents/Resources/lock_support/unlock.bat")))

These last two obviously will not work now that I checked up on expanduser D’OH!


#BASEPATHLOCK = os.path.expanduser(“C:\Users
eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\lock.bat”)

#BASEPATHUNLOCK = os.path.expanduser(“C:\Users
eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\unlock.bat”)


#BASEPATHLOCK = os.path.expanduser("%LOCALAPPDATA%\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\lock.bat")

#BASEPATHUNLOCK = os.path.expanduser("%LOCALAPPDATA%\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\unlock.bat")

https://twitter.com/lockforplex/status/663283582832480256

FYi for:

BASEPATHLOCK = os.path.expanduser("~\AppData\Local\Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/lock.bat")

BASEPATHUNLOCK = os.path.expanduser("~\AppData\Local/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/unlock.bat")

I added:

Log.Info('~~~~~~~LockforPlexLog~~~~~~~~~~This is the basepath 0:' + BASEPATHLOCK)

result: 

2014-09-01 09:21:13,983 (1f18) :  INFO (logkit:16) - ~~~~~~~LockforPlexLog~~~~~~~~~~This is the basepath 0:C:\Users eedlephoenix/AppData/Local/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/lock.bat

Seems kind of fishy

Tried all the variants with no success.  The new batch file still works though.

Do you need to use open when using os.system?  Just a shot in the dark.

https://twitter.com/lockforplex/status/663283582832480256

https://twitter.com/lockforplex/status/663283582832480256

You got me :P  no idea

ok so this is all the variants I've tried at this point none of which seem to run the batch file:

BASEPATHLOCK = os.path.expanduser("~/AppData/Local/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/lock.bat")
BASEPATHUNLOCK = os.path.expanduser("~/AppData/Local/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/unlock.bat")
 
#BASEPATHLOCK = os.path.expanduser("~\AppData\Local\Plex/ Media/ Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\lock.bat")
#BASEPATHUNLOCK = os.path.expanduser("~\AppData\Local\Plex /Media /Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\unlock.bat")
 
#BASEPATHLOCK = os.path.expanduser("C:\Users eedlephoenix\AppData\Local\Plex/Media/Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\lock.bat")
#BASEPATHUNLOCK = os.path.expanduser("C:\Users eedlephoenix\AppData\Local\Plex/Media/Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\unlock.bat")
 
#BASEPATHLOCK = "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\lock.bat"
#BASEPATHUNLOCK = "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\unlock.bat"
 
#BASEPATHLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+"/Lock.bundle/Contents/Resources/lock_support/lock.bat"))).replace(" ","/ ")
#BASEPATHUNLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+"/Lock.bundle/Contents/Resources/lock_support/unlock.bat"))).replace(" ","/ ")
 
#BASEPATHLOCK = os.path.expanduser("~\AppData\Local\Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/lock.bat")
#BASEPATHUNLOCK = os.path.expanduser("~\AppData\Local/Plex Media Server/Plug-ins/Lock.bundle/Contents/Resources/lock_support/unlock.bat")
 
#BASEPATHLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+"/Lock.bundle/Contents/Resources/lock_support/lock.bat"))).replace(" ","\\ ")
#BASEPATHUNLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+"/Lock.bundle/Contents/Resources/lock_support/unlock.bat"))).replace(" ","\\ ")
 
#BASEPATHLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+"/Lock.bundle/Contents/Resources/lock_support/lock.bat")))
#BASEPATHUNLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name+"/Lock.bundle/Contents/Resources/lock_support/unlock.bat")))
 
#BASEPATHLOCK = os.path.expanduser("C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\lock.bat")
#BASEPATHUNLOCK = os.path.expanduser("C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\unlock.bat")
 
#BASEPATHLOCK = os.path.expanduser("%LOCALAPPDATA%\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\lock.bat")
#BASEPATHUNLOCK = os.path.expanduser("%LOCALAPPDATA%\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support\unlock.bat")

https://twitter.com/lockforplex/status/663283582832480256

https://twitter.com/lockforplex/status/663283582832480256

cd /
cd %userprofile%\AppData\Local\Plex Media Server\Plug-ins\Lock.bundle\Contents\Resources\lock_support
 
sqlite3 "%userprofile%\AppData\Local\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db" < lock.sql
 
exit

FYI using sublime.  You should try it out its quite good, we have been using it at work for ages.

https://twitter.com/lockforplex/status/663283582832480256

Hmmm....

2014-09-01 09:50:39,615 (2a70) :  INFO (core:347) - Starting framework core - Version: 2.5.0, Build: a51033b (Mon Jul 28 12:19:14 UTC 2014)
2014-09-01 09:50:39,615 (2a70) :  DEBUG (core:359) - Using the elevated policy
2014-09-01 09:50:39,615 (2a70) :  DEBUG (core:448) - Starting runtime component.
2014-09-01 09:50:39,618 (2a70) :  DEBUG (core:448) - Starting caching component.
2014-09-01 09:50:39,618 (2a70) :  DEBUG (core:448) - Starting data component.
2014-09-01 09:50:39,618 (2a70) :  DEBUG (core:448) - Starting networking component.
2014-09-01 09:50:39,621 (2a70) :  DEBUG (networking:288) - Loaded HTTP cookies
2014-09-01 09:50:39,621 (2a70) :  DEBUG (networking:458) - Setting the default network timeout to 20.0
2014-09-01 09:50:39,621 (2a70) :  DEBUG (core:448) - Starting localization component.
2014-09-01 09:50:39,622 (2a70) :  INFO (localization:408) - Setting the default locale to en-us
2014-09-01 09:50:39,622 (2a70) :  DEBUG (core:448) - Starting messaging component.
2014-09-01 09:50:39,624 (2860) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/system/messaging/clear_events/com.plexapp.plugins.lockunlock'
2014-09-01 09:50:39,628 (2a70) :  DEBUG (core:448) - Starting debugging component.
2014-09-01 09:50:39,628 (2a70) :  DEBUG (core:448) - Starting services component.
2014-09-01 09:50:39,628 (2a70) :  DEBUG (core:448) - Starting myplex component.
2014-09-01 09:50:39,628 (2a70) :  DEBUG (core:448) - Starting notifications component.
2014-09-01 09:50:39,786 (2a70) :  DEBUG (accessor:68) - Creating a new model access point for provider com.plexapp.plugins.lockunlock in namespace 'metadata'
2014-09-01 09:50:39,792 (2a70) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/resourceHashes'
2014-09-01 09:50:40,000 (3024) :  DEBUG (services:265) - Plug-in is not daemonized - loading services from system
2014-09-01 09:50:40,000 (3024) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X0J1bmRsZVNlcnZpY2U6QWxsU2VydmljZXM_/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoxCmRpY3QKMApyMAo_'
2014-09-01 09:50:40,003 (2a70) :  DEBUG (runtime:1111) - Created a thread named 'load_all_services'
2014-09-01 09:50:40,013 (2a70) :  DEBUG (runtime:1111) - Created a thread named 'get_server_info'
2014-09-01 09:50:40,022 (2a70) :  DEBUG (core:150) - Finished starting framework core
2014-09-01 09:50:40,022 (2a70) :  DEBUG (core:558) - Loading plug-in code
2014-09-01 09:50:40,023 (2198) :  DEBUG (networking:172) - Requesting 'http://127.0.0.1:32400'
2014-09-01 09:50:40,045 (2a70) :  CRITICAL (core:572) - Exception while loading code (most recent call last):
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\core.py", line 561, in load_code
    self.init_code = self.loader.load(self.init_path, elevated, use_xpython = Framework.constants.flags.use_xpython in self.sandbox.flags)
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\code\loader.py", line 47, in load
    code = self.compile(str(source), str(uni(filename)), elevated)
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\code\loader.py", line 52, in compile
    return RestrictedPython.compile_restricted(source, name, 'exec', elevated=elevated)
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Platforms\Shared\Libraries\RestrictedPython\RCompile.py", line 115, in compile_restricted
    gen.compile()
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Platforms\Shared\Libraries\RestrictedPython\RCompile.py", line 68, in compile
    tree = self._get_tree()
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Platforms\Shared\Libraries\RestrictedPython\RCompile.py", line 59, in _get_tree
    tree = self.parse()
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Platforms\Shared\Libraries\RestrictedPython\RCompile.py", line 56, in parse
    return niceParse(self.source, self.filename, self.mode)
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Platforms\Shared\Libraries\RestrictedPython\RCompile.py", line 38, in niceParse
    compile(source, filename, mode)
  File "C:\Users eedlephoenix\AppData\Local\Plex Media Server\Plug-ins\Lock.bundle\Contents\Code\__init__.py", line 7
    BASEPATHUNLOCK = (Core.storage.join_path(Core.storage.join_path(Core.app_support_path, Core.config.bundles_dir_name), 'Lock.bundle')+"\Contents\Resources\lock_support\unlock.bat")
                 ^
SyntaxError: invalid syntax
 
2014-09-01 09:50:40,094 (2198) :  DEBUG (core:536) - Machine identifier is f763994b0c644c0df1377f47ee1112dd1b928277
2014-09-01 09:50:40,095 (2198) :  DEBUG (core:537) - Server version is 0.9.9.14.531-7eef8c6
2014-09-01 09:50:40,364 (3024) :  DEBUG (services:362) - Loaded services
2014-09-01 09:50:40,368 (2250) :  DEBUG (services:438) - No shared code to load