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')
|
'-d', '--daemon', action='store_true', help='Run as a daemon')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-p', '--port', type=int, help='Force PlexPy to run on a specified port')
|
'-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(
|
parser.add_argument(
|
||||||
'--datadir', help='Specify a directory where to store your data files')
|
'--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(
|
||||||
parser.add_argument('--nolaunch', action='store_true',
|
'--config', help='Specify a config file to use')
|
||||||
help='Prevent browser from launching on startup')
|
parser.add_argument(
|
||||||
|
'--nolaunch', action='store_true', help='Prevent browser from launching on startup')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--pidfile', help='Create a pid file (only relevant when running as a daemon)')
|
'--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,
|
logger.initLogger(console=not plexpy.QUIET, log_dir=False,
|
||||||
verbose=plexpy.VERBOSE)
|
verbose=plexpy.VERBOSE)
|
||||||
|
|
||||||
|
if args.dev:
|
||||||
|
plexpy.DEV = True
|
||||||
|
logger.debug(u"PlexPy is running in the dev environment.")
|
||||||
|
|
||||||
if args.daemon:
|
if args.daemon:
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
|
@ -164,6 +171,19 @@ def main():
|
||||||
# Read config and start logging
|
# Read config and start logging
|
||||||
plexpy.initialize(config_file)
|
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
|
# Force the http port if neccessary
|
||||||
if args.port:
|
if args.port:
|
||||||
http_port = args.port
|
http_port = args.port
|
||||||
|
@ -196,21 +216,8 @@ def main():
|
||||||
}
|
}
|
||||||
webstart.initialize(web_config)
|
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
|
# 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.launch_browser(plexpy.CONFIG.HTTP_HOST, http_port,
|
||||||
plexpy.CONFIG.HTTP_ROOT)
|
plexpy.CONFIG.HTTP_ROOT)
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,8 @@ UMASK = None
|
||||||
|
|
||||||
POLLING_FAILOVER = False
|
POLLING_FAILOVER = False
|
||||||
|
|
||||||
|
DEV = False
|
||||||
|
|
||||||
|
|
||||||
def initialize(config_file):
|
def initialize(config_file):
|
||||||
with INIT_LOCK:
|
with INIT_LOCK:
|
||||||
|
|
|
@ -449,7 +449,9 @@ class Config(object):
|
||||||
for key in _CONFIG_DEFINITIONS.keys():
|
for key in _CONFIG_DEFINITIONS.keys():
|
||||||
self.check_setting(key)
|
self.check_setting(key)
|
||||||
self._upgrade()
|
self._upgrade()
|
||||||
self._blacklist()
|
|
||||||
|
if not plexpy.DEV:
|
||||||
|
self._blacklist()
|
||||||
|
|
||||||
def _blacklist(self):
|
def _blacklist(self):
|
||||||
""" Add tokens and passwords to blacklisted words in logger """
|
""" Add tokens and passwords to blacklisted words in logger """
|
||||||
|
@ -520,7 +522,8 @@ class Config(object):
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
plexpy.logger.error("Error writing configuration file: %s", e)
|
plexpy.logger.error("Error writing configuration file: %s", e)
|
||||||
|
|
||||||
self._blacklist()
|
if not plexpy.DEV:
|
||||||
|
self._blacklist()
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -51,8 +51,6 @@ def initialize(options):
|
||||||
'tools.encode.on': True,
|
'tools.encode.on': True,
|
||||||
'tools.encode.encoding': 'utf-8',
|
'tools.encode.encoding': 'utf-8',
|
||||||
'tools.decode.on': True,
|
'tools.decode.on': True,
|
||||||
'log.screen': False,
|
|
||||||
'engine.autoreload.on': False,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if enable_https:
|
if enable_https:
|
||||||
|
@ -62,6 +60,10 @@ def initialize(options):
|
||||||
else:
|
else:
|
||||||
protocol = "http"
|
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,
|
logger.info("Starting PlexPy web server on %s://%s:%d/", protocol,
|
||||||
options['http_host'], options['http_port'])
|
options['http_host'], options['http_port'])
|
||||||
cherrypy.config.update(options_dict)
|
cherrypy.config.update(options_dict)
|
||||||
|
@ -120,7 +122,12 @@ def initialize(options):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cherrypy.process.servers.check_port(str(options['http_host']), options['http_port'])
|
cherrypy.process.servers.check_port(str(options['http_host']), options['http_port'])
|
||||||
cherrypy.server.start()
|
if not plexpy.DEV:
|
||||||
|
cherrypy.server.start()
|
||||||
|
else:
|
||||||
|
cherrypy.engine.signals.subscribe()
|
||||||
|
cherrypy.engine.start()
|
||||||
|
cherrypy.engine.block()
|
||||||
except IOError:
|
except IOError:
|
||||||
sys.stderr.write('Failed to start on port: %i. Is something else running?\n' % (options['http_port']))
|
sys.stderr.write('Failed to start on port: %i. Is something else running?\n' % (options['http_port']))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue