Add configuration and scheduler info to settings page

This commit is contained in:
JonnyWong16 2016-02-14 17:51:14 -08:00
commit 38c9c5a6ea
8 changed files with 205 additions and 18 deletions

View file

@ -57,9 +57,9 @@ _INITIALIZED = False
started = False
DATA_DIR = None
BACKUP_DIR = None
CONFIG = None
CONFIG_FILE = None
DB_FILE = None
@ -79,12 +79,14 @@ def initialize(config_file):
with INIT_LOCK:
global CONFIG
global CONFIG_FILE
global _INITIALIZED
global CURRENT_VERSION
global LATEST_VERSION
global UMASK
global POLLING_FAILOVER
CONFIG = plexpy.config.Config(config_file)
CONFIG_FILE = config_file
assert CONFIG is not None
@ -118,6 +120,15 @@ def initialize(config_file):
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR,
verbose=VERBOSE)
if not CONFIG.BACKUP_DIR.startswith(os.path.abspath(DATA_DIR)):
# Put the backup dir in the data dir for now
CONFIG.BACKUP_DIR = os.path.join(DATA_DIR, 'backups')
if not os.path.exists(CONFIG.BACKUP_DIR):
try:
os.makedirs(CONFIG.BACKUP_DIR)
except OSError as e:
logger.error("Could not create backup dir '%s': %s", BACKUP_DIR, e)
if not CONFIG.CACHE_DIR.startswith(os.path.abspath(DATA_DIR)):
# Put the cache dir in the data dir for now
CONFIG.CACHE_DIR = os.path.join(DATA_DIR, 'cache')
@ -127,12 +138,6 @@ def initialize(config_file):
except OSError as e:
logger.error("Could not create cache dir '%s': %s", DATA_DIR, e)
plexpy.BACKUP_DIR = os.path.join(plexpy.PROG_DIR, 'backups')
try:
os.makedirs(plexpy.BACKUP_DIR)
except OSError:
pass
# Initialize the database
logger.info('Checking to see if the database has all tables....')
try:
@ -289,9 +294,9 @@ def initialize_scheduler():
seconds = 0
if CONFIG.PMS_IP and CONFIG.PMS_TOKEN:
schedule_job(plextv.get_real_pms_url, 'Refresh Plex Server URLs',
schedule_job(plextv.get_real_pms_url, 'Refresh Plex server URLs',
hours=12, minutes=0, seconds=0)
schedule_job(pmsconnect.get_server_friendly_name, 'Refresh Plex Server Name',
schedule_job(pmsconnect.get_server_friendly_name, 'Refresh Plex server name',
hours=12, minutes=0, seconds=0)
if CONFIG.NOTIFY_RECENTLY_ADDED:
@ -302,10 +307,10 @@ def initialize_scheduler():
hours=0, minutes=0, seconds=0)
if CONFIG.MONITOR_REMOTE_ACCESS:
schedule_job(activity_pinger.check_server_response, 'Check for server response',
schedule_job(activity_pinger.check_server_response, 'Check for Plex remote access',
hours=0, minutes=0, seconds=seconds)
else:
schedule_job(activity_pinger.check_server_response, 'Check for server response',
schedule_job(activity_pinger.check_server_response, 'Check for Plex remote access',
hours=0, minutes=0, seconds=0)
# If we're not using websockets then fall back to polling

View file

@ -57,4 +57,14 @@ MEDIA_FLAGS_AUDIO = {'ac.?3': 'dolby_digital',
MEDIA_FLAGS_VIDEO = {'avc1': 'h264',
'wmv(1|2)': 'wmv',
'wmv3': 'wmvhd'
}
}
SCHEDULER_LIST = ['Check GitHub for updates',
'Check for active sessions',
'Check for recently added items',
'Check for Plex remote access',
'Refresh users list',
'Refresh libraries list'
'Refresh Plex server URLs',
'Refresh Plex server name',
]

View file

@ -30,6 +30,7 @@ _CONFIG_DEFINITIONS = {
'PMS_USE_BIF': (int, 'PMS', 0),
'PMS_UUID': (str, 'PMS', ''),
'TIME_FORMAT': (str, 'General', 'HH:mm'),
'ANON_REDIRECT': (str, 'General', 'http://dereferer.org/?'),
'API_ENABLED': (int, 'General', 0),
'API_KEY': (str, 'General', ''),
'API_SQL': (int, 'General', 0),
@ -49,6 +50,7 @@ _CONFIG_DEFINITIONS = {
'BOXCAR_ON_INTUP': (int, 'Boxcar', 0),
'BUFFER_THRESHOLD': (int, 'Monitoring', 3),
'BUFFER_WAIT': (int, 'Monitoring', 900),
'BACKUP_DIR': (str, 'General', ''),
'CACHE_DIR': (str, 'General', ''),
'CACHE_SIZEMB': (int, 'Advanced', 32),
'CHECK_GITHUB': (int, 'General', 1),

View file

@ -49,7 +49,7 @@ def db_filename(filename="plexpy.db"):
def make_backup(cleanup=False):
""" Makes a backup of db, removes all but the last 3 backups """
backupfolder = plexpy.BACKUP_DIR
backupfolder = plexpy.CONFIG.BACKUP_DIR
backup_file = 'plexpy.backup-%s.db' % int(time.time())
backup_file_fp = os.path.join(backupfolder, backup_file)

View file

@ -516,3 +516,10 @@ def get_ip(host):
logger.error(u"IP Checker :: Bad IP or hostname provided.")
return ip_address
# Taken from SickRage
def anon_url(*url):
"""
Return a URL string consisting of the Anonymous redirect URL and an arbitrary number of values appended.
"""
return '' if None in url else '%s%s' % (plexpy.CONFIG.ANON_REDIRECT, ''.join(str(s) for s in url))

View file

@ -1114,6 +1114,7 @@ class WebInterface(object):
"enable_https": checked(plexpy.CONFIG.ENABLE_HTTPS),
"https_cert": plexpy.CONFIG.HTTPS_CERT,
"https_key": plexpy.CONFIG.HTTPS_KEY,
"anon_redirect": plexpy.CONFIG.ANON_REDIRECT,
"api_enabled": checked(plexpy.CONFIG.API_ENABLED),
"api_key": plexpy.CONFIG.API_KEY,
"update_db_interval": plexpy.CONFIG.UPDATE_DB_INTERVAL,