mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 05:01:14 -07:00
Enable PlexPy dev environment using --dev flag
This commit is contained in:
parent
0b126278f9
commit
252145cf58
4 changed files with 41 additions and 22 deletions
41
PlexPy.py
41
PlexPy.py
|
@ -81,11 +81,14 @@ def main():
|
|||
'-d', '--daemon', action='store_true', help='Run as a daemon')
|
||||
parser.add_argument(
|
||||
'-p', '--port', type=int, help='Force PlexPy to run on a specified port')
|
||||
parser.add_argument(
|
||||
'--dev', action='store_true', help='Start PlexPy in the development environment')
|
||||
parser.add_argument(
|
||||
'--datadir', help='Specify a directory where to store your data files')
|
||||
parser.add_argument('--config', help='Specify a config file to use')
|
||||
parser.add_argument('--nolaunch', action='store_true',
|
||||
help='Prevent browser from launching on startup')
|
||||
parser.add_argument(
|
||||
'--config', help='Specify a config file to use')
|
||||
parser.add_argument(
|
||||
'--nolaunch', action='store_true', help='Prevent browser from launching on startup')
|
||||
parser.add_argument(
|
||||
'--pidfile', help='Create a pid file (only relevant when running as a daemon)')
|
||||
|
||||
|
@ -100,6 +103,10 @@ def main():
|
|||
logger.initLogger(console=not plexpy.QUIET, log_dir=False,
|
||||
verbose=plexpy.VERBOSE)
|
||||
|
||||
if args.dev:
|
||||
plexpy.DEV = True
|
||||
logger.debug(u"PlexPy is running in the dev environment.")
|
||||
|
||||
if args.daemon:
|
||||
if sys.platform == 'win32':
|
||||
sys.stderr.write(
|
||||
|
@ -164,6 +171,19 @@ def main():
|
|||
# Read config and start logging
|
||||
plexpy.initialize(config_file)
|
||||
|
||||
# Start the background threads
|
||||
plexpy.start()
|
||||
|
||||
# Open connection for websocket
|
||||
if plexpy.CONFIG.MONITORING_USE_WEBSOCKET:
|
||||
try:
|
||||
web_socket.start_thread()
|
||||
except:
|
||||
logger.warn(u"Websocket :: Unable to open connection.")
|
||||
# Fallback to polling
|
||||
plexpy.POLLING_FAILOVER = True
|
||||
plexpy.initialize_scheduler()
|
||||
|
||||
# Force the http port if neccessary
|
||||
if args.port:
|
||||
http_port = args.port
|
||||
|
@ -196,21 +216,8 @@ def main():
|
|||
}
|
||||
webstart.initialize(web_config)
|
||||
|
||||
# Start the background threads
|
||||
plexpy.start()
|
||||
|
||||
# Open connection for websocket
|
||||
if plexpy.CONFIG.MONITORING_USE_WEBSOCKET:
|
||||
try:
|
||||
web_socket.start_thread()
|
||||
except:
|
||||
logger.warn(u"Websocket :: Unable to open connection.")
|
||||
# Fallback to polling
|
||||
plexpy.POLLING_FAILOVER = True
|
||||
plexpy.initialize_scheduler()
|
||||
|
||||
# Open webbrowser
|
||||
if plexpy.CONFIG.LAUNCH_BROWSER and not args.nolaunch:
|
||||
if plexpy.CONFIG.LAUNCH_BROWSER and not args.nolaunch and not plexpy.DEV:
|
||||
plexpy.launch_browser(plexpy.CONFIG.HTTP_HOST, http_port,
|
||||
plexpy.CONFIG.HTTP_ROOT)
|
||||
|
||||
|
|
|
@ -74,6 +74,8 @@ UMASK = None
|
|||
|
||||
POLLING_FAILOVER = False
|
||||
|
||||
DEV = False
|
||||
|
||||
|
||||
def initialize(config_file):
|
||||
with INIT_LOCK:
|
||||
|
|
|
@ -449,6 +449,8 @@ class Config(object):
|
|||
for key in _CONFIG_DEFINITIONS.keys():
|
||||
self.check_setting(key)
|
||||
self._upgrade()
|
||||
|
||||
if not plexpy.DEV:
|
||||
self._blacklist()
|
||||
|
||||
def _blacklist(self):
|
||||
|
@ -520,6 +522,7 @@ class Config(object):
|
|||
except IOError as e:
|
||||
plexpy.logger.error("Error writing configuration file: %s", e)
|
||||
|
||||
if not plexpy.DEV:
|
||||
self._blacklist()
|
||||
|
||||
def __getattr__(self, name):
|
||||
|
|
|
@ -51,8 +51,6 @@ def initialize(options):
|
|||
'tools.encode.on': True,
|
||||
'tools.encode.encoding': 'utf-8',
|
||||
'tools.decode.on': True,
|
||||
'log.screen': False,
|
||||
'engine.autoreload.on': False,
|
||||
}
|
||||
|
||||
if enable_https:
|
||||
|
@ -62,6 +60,10 @@ def initialize(options):
|
|||
else:
|
||||
protocol = "http"
|
||||
|
||||
if plexpy.DEV:
|
||||
options_dict['environment'] = "test_suite"
|
||||
options_dict['engine.autoreload.on'] = True
|
||||
|
||||
logger.info("Starting PlexPy web server on %s://%s:%d/", protocol,
|
||||
options['http_host'], options['http_port'])
|
||||
cherrypy.config.update(options_dict)
|
||||
|
@ -120,7 +122,12 @@ def initialize(options):
|
|||
|
||||
try:
|
||||
cherrypy.process.servers.check_port(str(options['http_host']), options['http_port'])
|
||||
if not plexpy.DEV:
|
||||
cherrypy.server.start()
|
||||
else:
|
||||
cherrypy.engine.signals.subscribe()
|
||||
cherrypy.engine.start()
|
||||
cherrypy.engine.block()
|
||||
except IOError:
|
||||
sys.stderr.write('Failed to start on port: %i. Is something else running?\n' % (options['http_port']))
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue