From 43229e9184ce64ea2d4b3e1b18930b9b3d4a7ff2 Mon Sep 17 00:00:00 2001 From: shypike <> Date: Sun, 21 Feb 2010 14:33:36 +0000 Subject: [PATCH] Lowercase all option instances. --- main/SABnzbd.py | 78 +++++++-------- main/SABnzbdDelegate.py | 2 +- main/sabnzbd/__init__.py | 80 +++++++-------- main/sabnzbd/assembler.py | 4 +- main/sabnzbd/cfg.py | 231 ++++++++++++++++++++++--------------------- main/sabnzbd/database.py | 2 +- main/sabnzbd/decoder.py | 4 +- main/sabnzbd/dirscanner.py | 10 +- main/sabnzbd/downloader.py | 12 +-- main/sabnzbd/emailer.py | 24 ++--- main/sabnzbd/interface.py | 196 ++++++++++++++++++------------------ main/sabnzbd/misc.py | 28 +++--- main/sabnzbd/newsunpack.py | 2 +- main/sabnzbd/newswrapper.py | 2 +- main/sabnzbd/newzbin.py | 10 +- main/sabnzbd/nzbqueue.py | 10 +- main/sabnzbd/nzbstuff.py | 12 +-- main/sabnzbd/postproc.py | 32 +++--- main/sabnzbd/rss.py | 4 +- main/sabnzbd/scheduler.py | 18 ++-- main/sabnzbd/tvsort.py | 30 +++--- main/sabnzbd/urlgrabber.py | 4 +- main/sabnzbd/utils/upload.py | 18 ++-- main/sabnzbd/wizard.py | 68 ++++++------- 24 files changed, 441 insertions(+), 440 deletions(-) diff --git a/main/SABnzbd.py b/main/SABnzbd.py index 7a344a0..a6b5469 100755 --- a/main/SABnzbd.py +++ b/main/SABnzbd.py @@ -283,7 +283,7 @@ def Web_Template(key, defweb, wdir): panic_tmpl(full_dir) exit_sab(1) - sabnzbd.lang.install_language(real_path(full_dir, DEF_INT_LANGUAGE), sabnzbd.cfg.LANGUAGE(), wdir) + sabnzbd.lang.install_language(real_path(full_dir, DEF_INT_LANGUAGE), sabnzbd.cfg.language(), wdir) return real_path(full_dir, "templates") @@ -436,9 +436,9 @@ def get_webhost(cherryhost, cherryport, https_port): return (host, port, browserhost) """ if cherryhost is None: - cherryhost = sabnzbd.cfg.CHERRYHOST() + cherryhost = sabnzbd.cfg.cherryhost() else: - sabnzbd.cfg.CHERRYHOST.set(cherryhost) + sabnzbd.cfg.cherryhost.set(cherryhost) # Get IP address, but discard APIPA/IPV6 # If only APIPA's or IPV6 are found, fall back to localhost @@ -525,19 +525,19 @@ def get_webhost(cherryhost, cherryport, https_port): browserhost = '127.0.0.1' if cherryport is None: - cherryport = sabnzbd.cfg.CHERRYPORT.get_int() + cherryport = sabnzbd.cfg.cherryport.get_int() else: - sabnzbd.cfg.CHERRYPORT.set(str(cherryport)) + sabnzbd.cfg.cherryport.set(str(cherryport)) if https_port is None: - https_port = sabnzbd.cfg.HTTPS_PORT.get_int() + https_port = sabnzbd.cfg.https_port.get_int() else: - sabnzbd.cfg.HTTPS_PORT.set(str(https_port)) + sabnzbd.cfg.https_port.set(str(https_port)) # if the https port was specified, assume they want HTTPS enabling also - sabnzbd.cfg.ENABLE_HTTPS.set(True) + sabnzbd.cfg.enable_https.set(True) if cherryport == https_port: - sabnzbd.cfg.ENABLE_HTTPS.set(False) + sabnzbd.cfg.enable_https.set(False) logging.error(Ta('error-sameHTTP-HTTPS')) return cherryhost, cherryport, browserhost, https_port @@ -728,7 +728,7 @@ def get_f_option(opts): def main(): global LOG_FLAG - AUTOBROWSER = None + autobrowser = None autorestarted = False sabnzbd.MY_FULLNAME = sys.argv[0] fork = False @@ -756,7 +756,7 @@ def main(): elif opt in ('-d', '--daemon'): if not sabnzbd.WIN32: fork = True - AUTOBROWSER = False + autobrowser = False sabnzbd.DAEMON = True consoleLogging = False re_argv.append(opt) @@ -774,12 +774,12 @@ def main(): elif opt in ('-s', '--server'): (cherryhost, cherryport) = split_host(arg) elif opt in ('-n', '--nobrowser'): - AUTOBROWSER = False + autobrowser = False elif opt in ('-b', '--browser'): try: - AUTOBROWSER = bool(int(arg)) + autobrowser = bool(int(arg)) except: - AUTOBROWSER = True + autobrowser = True elif opt in ('--autorestarted'): autorestarted = True elif opt in ('-c', '--clean'): @@ -895,7 +895,7 @@ def main(): # Determine web host address cherryhost, cherryport, browserhost, https_port = get_webhost(cherryhost, cherryport, https_port) - enable_https = sabnzbd.cfg.ENABLE_HTTPS() + enable_https = sabnzbd.cfg.enable_https() # When this is a daemon, just check and bail out if port in use if sabnzbd.DAEMON: @@ -924,7 +924,7 @@ def main(): if not check_for_sabnzbd(url, upload_nzbs): port = find_free_port(browserhost, https_port) if port > 0: - sabnzbd.cfg.HTTPS_PORT.set(port) + sabnzbd.cfg.https_port.set(port) cherryport = port ## NonSSL try: @@ -937,21 +937,21 @@ def main(): if not check_for_sabnzbd(url, upload_nzbs): port = find_free_port(browserhost, cherryport) if port > 0: - sabnzbd.cfg.CHERRYPORT.set(port) + sabnzbd.cfg.cherryport.set(port) cherryport = port if cherrypylogging is None: - cherrypylogging = sabnzbd.cfg.LOG_WEB() + cherrypylogging = sabnzbd.cfg.log_web() else: - sabnzbd.cfg.LOG_WEB.set(cherrypylogging) + sabnzbd.cfg.log_web.set(cherrypylogging) if logging_level is None: - logging_level = sabnzbd.cfg.LOG_LEVEL() + logging_level = sabnzbd.cfg.log_level() else: - sabnzbd.cfg.LOG_LEVEL.set(logging_level) + sabnzbd.cfg.log_level.set(logging_level) - logdir = sabnzbd.cfg.LOG_DIR.get_path() + logdir = sabnzbd.cfg.log_dir.get_path() if fork and not logdir: print "Error:" print "I refuse to fork without a log directory!" @@ -965,11 +965,11 @@ def main(): try: sabnzbd.LOGFILE = os.path.join(logdir, DEF_LOG_FILE) - logsize = sabnzbd.cfg.LOG_SIZE.get_int() + logsize = sabnzbd.cfg.log_size.get_int() rollover_log = logging.handlers.RotatingFileHandler(\ sabnzbd.LOGFILE, 'a+', logsize, - sabnzbd.cfg.LOG_BACKUPS()) + sabnzbd.cfg.log_backups()) format = '%(asctime)s::%(levelname)s::[%(module)s:%(lineno)d] %(message)s' rollover_log.setFormatter(logging.Formatter(format)) @@ -1040,12 +1040,12 @@ def main(): except: logging.info('[osx] IO priority setting not supported') - if AUTOBROWSER != None: - sabnzbd.cfg.AUTOBROWSER.set(AUTOBROWSER) + if autobrowser != None: + sabnzbd.cfg.autobrowser.set(autobrowser) else: - AUTOBROWSER = sabnzbd.cfg.AUTOBROWSER() + autobrowser = sabnzbd.cfg.autobrowser() - sabnzbd.cfg.DEBUG_DELAY.set(delay) + sabnzbd.cfg.debug_delay.set(delay) # Find external programs sabnzbd.newsunpack.find_programs(sabnzbd.DIR_PROG) @@ -1063,20 +1063,20 @@ def main(): os.chdir(sabnzbd.DIR_PROG) - web_dir = Web_Template(sabnzbd.cfg.WEB_DIR, DEF_STDINTF, fix_webname(web_dir)) - web_dir2 = Web_Template(sabnzbd.cfg.WEB_DIR2, '', fix_webname(web_dir2)) + web_dir = Web_Template(sabnzbd.cfg.web_dir, DEF_STDINTF, fix_webname(web_dir)) + web_dir2 = Web_Template(sabnzbd.cfg.web_dir2, '', fix_webname(web_dir2)) wizard_dir = os.path.join(sabnzbd.DIR_INTERFACES, 'wizard') - sabnzbd.lang.install_language(os.path.join(wizard_dir, DEF_INT_LANGUAGE), sabnzbd.cfg.LANGUAGE(), 'wizard') + sabnzbd.lang.install_language(os.path.join(wizard_dir, DEF_INT_LANGUAGE), sabnzbd.cfg.language(), 'wizard') sabnzbd.WEB_DIR = web_dir sabnzbd.WEB_DIR2 = web_dir2 sabnzbd.WIZARD_DIR = wizard_dir - sabnzbd.WEB_COLOR = CheckColor(sabnzbd.cfg.WEB_COLOR(), web_dir) - sabnzbd.cfg.WEB_COLOR.set(sabnzbd.WEB_COLOR) - sabnzbd.WEB_COLOR2 = CheckColor(sabnzbd.cfg.WEB_COLOR2(), web_dir2) - sabnzbd.cfg.WEB_COLOR2.set(sabnzbd.WEB_COLOR2) + sabnzbd.WEB_COLOR = CheckColor(sabnzbd.cfg.web_color(), web_dir) + sabnzbd.cfg.web_color.set(sabnzbd.WEB_COLOR) + sabnzbd.WEB_COLOR2 = CheckColor(sabnzbd.cfg.web_color2(), web_dir2) + sabnzbd.cfg.web_color2.set(sabnzbd.WEB_COLOR2) if fork and not sabnzbd.WIN32: daemonize() @@ -1131,8 +1131,8 @@ def main(): 'error_page.401': sabnzbd.misc.error_page_401 }) - https_cert = sabnzbd.cfg.HTTPS_CERT.get_path() - https_key = sabnzbd.cfg.HTTPS_KEY.get_path() + https_cert = sabnzbd.cfg.https_cert.get_path() + https_key = sabnzbd.cfg.https_key.get_path() if enable_https: # If either the HTTPS certificate or key do not exist, make some self-signed ones. if not (https_cert and os.path.exists(https_cert)) or not (https_key and os.path.exists(https_key)): @@ -1184,7 +1184,7 @@ def main(): logging.info('Starting web-interface on %s:%s', cherryhost, cherryport) - sabnzbd.cfg.LOG_LEVEL.callback(guard_loglevel) + sabnzbd.cfg.log_level.callback(guard_loglevel) try: # Use internal cherrypy check first to prevent ugly tracebacks @@ -1238,7 +1238,7 @@ def main(): # Check for loglevel changes if LOG_FLAG: LOG_FLAG = False - level = LOGLEVELS[sabnzbd.cfg.LOG_LEVEL()] + level = LOGLEVELS[sabnzbd.cfg.log_level()] logger.setLevel(level) if consoleLogging: console.setLevel(level) diff --git a/main/SABnzbdDelegate.py b/main/SABnzbdDelegate.py index 15f3086..06d159c 100755 --- a/main/SABnzbdDelegate.py +++ b/main/SABnzbdDelegate.py @@ -469,7 +469,7 @@ class SABnzbdDelegate(NSObject): def newzbinUpdate(self): try: - if sabnzbd.cfg.USERNAME_NEWZBIN() and sabnzbd.cfg.PASSWORD_NEWZBIN() and sabnzbd.cfg.NEWZBIN_BOOKMARKS(): + if sabnzbd.cfg.newzbin_username() and sabnzbd.cfg.newzbin_password() and sabnzbd.cfg.NEWZBIN_BOOKMARKS(): if self.isLeopard: self.newzbin_menu_item.setHidden_(NO) else: diff --git a/main/sabnzbd/__init__.py b/main/sabnzbd/__init__.py index e2ce9a4..00dc2f6 100644 --- a/main/sabnzbd/__init__.py +++ b/main/sabnzbd/__init__.py @@ -176,43 +176,43 @@ def initialize(pause_downloader = False, clean_up = False, evalSched=False): ### Clean the cache folder, if requested if clean_up: - xlist= glob.glob(cfg.CACHE_DIR.get_path() + '/*') + xlist= glob.glob(cfg.cache_dir.get_path() + '/*') for x in xlist: os.remove(x) ### If dirscan_dir cannot be created, set a proper value anyway. ### Maybe it's a network path that's temporarily missing. - path = cfg.DIRSCAN_DIR.get_path() + path = cfg.dirscan_dir.get_path() if not os.path.exists(path): - sabnzbd.misc.create_real_path(cfg.DIRSCAN_DIR.ident(), '', path, False) + sabnzbd.misc.create_real_path(cfg.dirscan_dir.ident(), '', path, False) ### Set call backs for Config items - cfg.CACHE_LIMIT.callback(new_limit) - cfg.CHERRYHOST.callback(guard_restart) - cfg.CHERRYPORT.callback(guard_restart) - cfg.WEB_DIR.callback(guard_restart) - cfg.WEB_DIR2.callback(guard_restart) - cfg.WEB_COLOR.callback(guard_restart) - cfg.WEB_COLOR2.callback(guard_restart) - cfg.LOG_DIR.callback(guard_restart) - cfg.CACHE_DIR.callback(guard_restart) - cfg.HTTPS_PORT.callback(guard_restart) - cfg.HTTPS_CERT.callback(guard_restart) - cfg.HTTPS_KEY.callback(guard_restart) - cfg.ENABLE_HTTPS.callback(guard_restart) - cfg.BANDWIDTH_LIMIT.callback(guard_speedlimit) - cfg.TOP_ONLY.callback(guard_top_only) - cfg.PAUSE_ON_POST_PROCESSING.callback(guard_pause_on_pp) + cfg.cache_limit.callback(new_limit) + cfg.cherryhost.callback(guard_restart) + cfg.cherryport.callback(guard_restart) + cfg.web_dir.callback(guard_restart) + cfg.web_dir2.callback(guard_restart) + cfg.web_color.callback(guard_restart) + cfg.web_color2.callback(guard_restart) + cfg.log_dir.callback(guard_restart) + cfg.cache_dir.callback(guard_restart) + cfg.https_port.callback(guard_restart) + cfg.https_cert.callback(guard_restart) + cfg.https_key.callback(guard_restart) + cfg.enable_https.callback(guard_restart) + cfg.bandwidth_limit.callback(guard_speedlimit) + cfg.top_only.callback(guard_top_only) + cfg.pause_on_post_processing.callback(guard_pause_on_pp) ### Set cache limit - ArticleCache.do.new_limit(cfg.CACHE_LIMIT.get_int(), cfg.DEBUG_DELAY()) + ArticleCache.do.new_limit(cfg.cache_limit.get_int(), cfg.debug_delay()) ### Set language files - lang.install_language(DIR_LANGUAGE, cfg.LANGUAGE()) + lang.install_language(DIR_LANGUAGE, cfg.language()) ### Check for old queue (when a new queue is not present) - if not os.path.exists(os.path.join(cfg.CACHE_DIR.get_path(), QUEUE_FILE_NAME)): - OLD_QUEUE = bool(glob.glob(os.path.join(cfg.CACHE_DIR.get_path(), QUEUE_FILE_TMPL % '?'))) + if not os.path.exists(os.path.join(cfg.cache_dir.get_path(), QUEUE_FILE_NAME)): + OLD_QUEUE = bool(glob.glob(os.path.join(cfg.cache_dir.get_path(), QUEUE_FILE_TMPL % '?'))) ### ### Initialize threads @@ -350,7 +350,7 @@ def halt(): def new_limit(): """ Callback for article cache changes """ - ArticleCache.do.new_limit(cfg.CACHE_LIMIT.get_int()) + ArticleCache.do.new_limit(cfg.cache_limit.get_int()) def guard_restart(): """ Callback for config options requiring a restart """ @@ -359,15 +359,15 @@ def guard_restart(): def guard_speedlimit(): """ Callback for change of bandwidth_limit, sets actual speed """ - downloader.limit_speed(cfg.BANDWIDTH_LIMIT()) + downloader.limit_speed(cfg.bandwidth_limit()) def guard_top_only(): """ Callback for change of top_only option """ - nzbqueue.set_top_only(cfg.TOP_ONLY()) + nzbqueue.set_top_only(cfg.top_only()) def guard_pause_on_pp(): """ Callback for change of pause-download-on-pp """ - if cfg.PAUSE_ON_POST_PROCESSING(): + if cfg.pause_on_post_processing(): pass # Not safe to idle downloader, because we don't know # if post-processing is active now else: @@ -381,7 +381,7 @@ def add_msgid(msgid, pp=None, script=None, cat=None, priority=None, nzbname=None if priority == None: priority = NORMAL_PRIORITY - if cfg.USERNAME_NEWZBIN() and cfg.PASSWORD_NEWZBIN(): + if cfg.newzbin_username() and cfg.newzbin_password(): logging.info('Fetching msgid %s from www.newzbin.com', msgid) msg = T('fetchingNewzbin@1') % msgid @@ -437,21 +437,21 @@ NZB_LOCK = Lock() def backup_exists(filename): """ Return True if backup exists and no_dupes is set """ - path = cfg.NZB_BACKUP_DIR.get_path() - return path and sabnzbd.cfg.NO_DUPES() and \ + path = cfg.nzb_backup_dir.get_path() + return path and sabnzbd.cfg.no_dupes() and \ os.path.exists(os.path.join(path, filename+'.gz')) @synchronized(NZB_LOCK) def backup_nzb(filename, data): """ Backup NZB file """ - if cfg.NZB_BACKUP_DIR.get_path(): + if cfg.nzb_backup_dir.get_path(): backup_name = filename + '.gz' # Need to go to the backup folder to # prevent the pathname being embedded in the GZ file here = os.getcwd() - os.chdir(cfg.NZB_BACKUP_DIR.get_path()) + os.chdir(cfg.nzb_backup_dir.get_path()) logging.info("Backing up %s", backup_name) try: @@ -460,7 +460,7 @@ def backup_nzb(filename, data): _f.flush() _f.close() except: - logging.error("Saving %s to %s failed", backup_name, cfg.NZB_BACKUP_DIR.get_path()) + logging.error("Saving %s to %s failed", backup_name, cfg.nzb_backup_dir.get_path()) logging.debug("Traceback: ", exc_info = True) os.chdir(here) @@ -609,7 +609,7 @@ def change_queue_complete_action(action): def run_script(script): - command = os.path.join(cfg.SCRIPT_DIR.get_path(), script) + command = os.path.join(cfg.script_dir.get_path(), script) stup, need_shell, command, creationflags = sabnzbd.newsunpack.build_command(command) logging.info('Spawning external command %s', command) subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE, @@ -634,8 +634,8 @@ def keep_awake(): def CheckFreeSpace(): - if cfg.DOWNLOAD_FREE() and not downloader.paused(): - if misc.diskfree(cfg.DOWNLOAD_DIR.get_path()) < cfg.DOWNLOAD_FREE.get_float() / GIGI: + if cfg.download_free() and not downloader.paused(): + if misc.diskfree(cfg.download_dir.get_path()) < cfg.download_free.get_float() / GIGI: logging.warning(Ta('warn-noSpace')) # Pause downloader, but don't save, since the disk is almost full! downloader.pause_downloader(save=False) @@ -650,7 +650,7 @@ IO_LOCK = RLock() @synchronized(IO_LOCK) def get_new_id(prefix): try: - fd, l = tempfile.mkstemp('', 'SABnzbd_%s_' % prefix, cfg.CACHE_DIR.get_path()) + fd, l = tempfile.mkstemp('', 'SABnzbd_%s_' % prefix, cfg.cache_dir.get_path()) os.close(fd) head, tail = os.path.split(l) return tail @@ -661,7 +661,7 @@ def get_new_id(prefix): @synchronized(IO_LOCK) def save_data(data, _id, do_pickle = True, doze=0): - path = os.path.join(cfg.CACHE_DIR.get_path(), _id) + path = os.path.join(cfg.cache_dir.get_path(), _id) logging.info("Saving data for %s in %s", _id, path) try: @@ -682,7 +682,7 @@ def save_data(data, _id, do_pickle = True, doze=0): @synchronized(IO_LOCK) def load_data(_id, remove = True, do_pickle = True): - path = os.path.join(cfg.CACHE_DIR.get_path(), _id) + path = os.path.join(cfg.cache_dir.get_path(), _id) logging.info("Loading data for %s from %s", _id, path) if not os.path.exists(path): @@ -711,7 +711,7 @@ def load_data(_id, remove = True, do_pickle = True): @synchronized(IO_LOCK) def remove_data(_id): - path = os.path.join(cfg.CACHE_DIR.get_path(), _id) + path = os.path.join(cfg.cache_dir.get_path(), _id) try: os.remove(path) logging.info("%s removed", path) diff --git a/main/sabnzbd/assembler.py b/main/sabnzbd/assembler.py index 28700cb..59291c8 100644 --- a/main/sabnzbd/assembler.py +++ b/main/sabnzbd/assembler.py @@ -77,7 +77,7 @@ class Assembler(Thread): dupe = nzo.check_for_dupe(nzf) - filepath = get_filepath(cfg.DOWNLOAD_DIR.get_path(), nzo, filename) + filepath = get_filepath(cfg.download_dir.get_path(), nzo, filename) if filepath: logging.info('Decoding %s %s', filepath, nzf.get_type()) @@ -113,7 +113,7 @@ def _assemble(nzf, path, dupe): fout = open(path, 'ab') - if cfg.QUICK_CHECK(): + if cfg.quick_check(): md5 = new_md5() else: md5 = None diff --git a/main/sabnzbd/cfg.py b/main/sabnzbd/cfg.py index 2e04515..5c4a8a5 100644 --- a/main/sabnzbd/cfg.py +++ b/main/sabnzbd/cfg.py @@ -18,23 +18,24 @@ """ sabnzbd.cfg - Configuration Parameters """ +import re import sabnzbd -from sabnzbd.constants import * +from sabnzbd.constants import DEF_HOST, DEF_PORT_WIN_SSL, DEF_PORT_WIN, DEF_STDINTF, \ + DEF_DOWNLOAD_DIR, DEF_NZBBACK_DIR, DEF_PORT_UNIX_SSL, \ + NORMAL_PRIORITY, DEF_SCANRATE, DEF_PORT_UNIX, DEF_COMPLETE_DIR from sabnzbd.config import OptionBool, OptionNumber, OptionPassword, \ OptionDir, OptionStr, OptionList, no_nonsense, \ validate_octal, validate_safedir, validate_dir_exists, \ create_api_key from sabnzbd.lang import T - #------------------------------------------------------------------------------ # Email validation support # -import re RE_VAL = re.compile('[^@ ]+@[^.@ ]+\.[^.@ ]') def validate_email(value): - global EMAIL_ENDJOB, EMAIL_FULL - if EMAIL_ENDJOB() or EMAIL_FULL(): + global email_endjob, email_full + if email_endjob() or email_full(): if value and RE_VAL.match(value): return None, value else: @@ -45,8 +46,8 @@ def validate_email(value): def validate_server(value): """ Check if server non-empty""" - global EMAIL_ENDJOB, EMAIL_FULL - if value == '' and (EMAIL_ENDJOB() or EMAIL_FULL()): + global email_endjob, email_full + if value == '' and (email_endjob() or email_full()): return T('error-needServer'), None else: return None, value @@ -60,26 +61,26 @@ else: #------------------------------------------------------------------------------ # Configuration instances # -QUICK_CHECK = OptionBool('misc', 'quick_check', True) -FAIL_ON_CRC = OptionBool('misc', 'fail_on_crc', False) -SEND_GROUP = OptionBool('misc', 'send_group', False) - -EMAIL_SERVER = OptionStr('misc', 'email_server', validation=validate_server) -EMAIL_TO = OptionStr('misc', 'email_to', validation=validate_email) -EMAIL_FROM = OptionStr('misc', 'email_from', validation=validate_email) -EMAIL_ACCOUNT= OptionStr('misc', 'email_account') -EMAIL_PWD = OptionPassword('misc', 'email_pwd') -EMAIL_ENDJOB = OptionNumber('misc', 'email_endjob', 0, 0, 2) -EMAIL_FULL = OptionBool('misc', 'email_full', False) -EMAIL_DIR = OptionDir('misc', 'email_dir', create=False, validation=validate_dir_exists) -EMAIL_RSS = OptionBool('misc', 'email_rss', False) - -DIRSCAN_PP = OptionNumber('misc', 'dirscan_opts', 3, 0, 3) -VERSION_CHECK = OptionBool('misc', 'check_new_rel', True) -DIRSCAN_SCRIPT = OptionStr('misc', 'dirscan_script', 'None') -DIRSCAN_PRIORITY = OptionNumber('misc', 'dirscan_priority', NORMAL_PRIORITY) -AUTOBROWSER = OptionBool('misc', 'auto_browser', True) -REPLACE_ILLEGAL = OptionBool('misc', 'replace_illegal', True) +quick_check = OptionBool('misc', 'quick_check', True) +fail_on_crc = OptionBool('misc', 'fail_on_crc', False) +send_group = OptionBool('misc', 'send_group', False) + +email_server = OptionStr('misc', 'email_server', validation=validate_server) +email_to = OptionStr('misc', 'email_to', validation=validate_email) +email_from = OptionStr('misc', 'email_from', validation=validate_email) +email_account= OptionStr('misc', 'email_account') +email_pwd = OptionPassword('misc', 'email_pwd') +email_endjob = OptionNumber('misc', 'email_endjob', 0, 0, 2) +email_full = OptionBool('misc', 'email_full', False) +email_dir = OptionDir('misc', 'email_dir', create=False, validation=validate_dir_exists) +email_rss = OptionBool('misc', 'email_rss', False) + +dirscan_pp = OptionNumber('misc', 'dirscan_opts', 3, 0, 3) +version_check = OptionBool('misc', 'check_new_rel', True) +dirscan_script = OptionStr('misc', 'dirscan_script', 'None') +dirscan_priority = OptionNumber('misc', 'dirscan_priority', NORMAL_PRIORITY) +autobrowser = OptionBool('misc', 'auto_browser', True) +replace_illegal = OptionBool('misc', 'replace_illegal', True) enable_unrar = OptionBool('misc', 'enable_unrar', True) enable_unzip = OptionBool('misc', 'enable_unzip', True) @@ -92,119 +93,119 @@ ionice = OptionStr('misc', 'ionice', '', validation=no_nonsense) ignore_wrong_unrar = OptionBool('misc', 'ignore_wrong_unrar', False) par2_multicore = OptionBool('misc', 'par2_multicore', True) -USERNAME_NEWZBIN = OptionStr('newzbin', 'username') -PASSWORD_NEWZBIN = OptionPassword('newzbin', 'password') -NEWZBIN_BOOKMARKS = OptionBool('newzbin', 'bookmarks', False) -NEWZBIN_UNBOOKMARK = OptionBool('newzbin', 'unbookmark', True) -BOOKMARK_RATE = OptionNumber('newzbin', 'bookmark_rate', 60, minval=15, maxval=24*60) - -TOP_ONLY = OptionBool('misc', 'top_only', True) -AUTODISCONNECT = OptionBool('misc', 'auto_disconnect', True) - -REPLACE_SPACES = OptionBool('misc', 'replace_spaces', False) -REPLACE_DOTS = OptionBool('misc', 'replace_dots', False) -NO_DUPES = OptionBool('misc', 'no_dupes', False) -IGNORE_SAMPLES = OptionNumber('misc', 'ignore_samples', 0, 0, 2) -CREATE_GROUP_FOLDERS = OptionBool('misc', 'create_group_folders', False) -AUTO_SORT = OptionBool('misc', 'auto_sort', False) -FOLDER_RENAME = OptionBool('misc', 'folder_rename', True) +newzbin_username = OptionStr('newzbin', 'username') +newzbin_password = OptionPassword('newzbin', 'password') +newzbin_bookmarks = OptionBool('newzbin', 'bookmarks', False) +newzbin_unbookmark = OptionBool('newzbin', 'unbookmark', True) +bookmark_rate = OptionNumber('newzbin', 'bookmark_rate', 60, minval=15, maxval=24*60) + +top_only = OptionBool('misc', 'top_only', True) +autodisconnect = OptionBool('misc', 'auto_disconnect', True) + +replace_spaces = OptionBool('misc', 'replace_spaces', False) +replace_dots = OptionBool('misc', 'replace_dots', False) +no_dupes = OptionBool('misc', 'no_dupes', False) +ignore_samples = OptionNumber('misc', 'ignore_samples', 0, 0, 2) +create_group_folders = OptionBool('misc', 'create_group_folders', False) +auto_sort = OptionBool('misc', 'auto_sort', False) +folder_rename = OptionBool('misc', 'folder_rename', True) folder_max_length = OptionNumber('misc', 'folder_max_length', DEF_FOLDER_MAX, 20, 65000) -SAFE_POSTPROC = OptionBool('misc', 'safe_postproc', True) -PAUSE_ON_POST_PROCESSING = OptionBool('misc', 'pause_on_post_processing', False) +safe_postproc = OptionBool('misc', 'safe_postproc', True) +pause_on_post_processing = OptionBool('misc', 'pause_on_post_processing', False) -SCHEDULES = OptionList('misc', 'schedlines') +schedules = OptionList('misc', 'schedlines') -ENABLE_TV_SORTING = OptionBool('misc', 'enable_tv_sorting', False) -TV_SORT_STRING = OptionStr('misc', 'tv_sort_string') -TV_SORT_COUNTRIES = OptionNumber('misc', 'tv_sort_countries', 1) -TV_CATEGORIES = OptionList('misc', 'tv_categories', ['tv']) +enable_tv_sorting = OptionBool('misc', 'enable_tv_sorting', False) +tv_sort_string = OptionStr('misc', 'tv_sort_string') +tv_sort_countries = OptionNumber('misc', 'tv_sort_countries', 1) +tv_categories = OptionList('misc', 'tv_categories', ['tv']) -ENABLE_MOVIE_SORTING = OptionBool('misc', 'enable_movie_sorting', False) -MOVIE_SORT_STRING = OptionStr('misc', 'movie_sort_string') -MOVIE_SORT_EXTRA = OptionStr('misc', 'movie_sort_extra', '-cd%1', strip=False) -MOVIE_EXTRA_FOLDER = OptionBool('misc', 'movie_extra_folder', False) -MOVIE_CATEGORIES = OptionList('misc', 'movie_categories', ['movies']) +enable_movie_sorting = OptionBool('misc', 'enable_movie_sorting', False) +movie_sort_string = OptionStr('misc', 'movie_sort_string') +movie_sort_extra = OptionStr('misc', 'movie_sort_extra', '-cd%1', strip=False) +movie_extra_folders = OptionBool('misc', 'movie_extra_folder', False) +movie_categories = OptionList('misc', 'movie_categories', ['movies']) -ENABLE_DATE_SORTING = OptionBool('misc', 'enable_date_sorting', False) -DATE_SORT_STRING = OptionStr('misc', 'date_sort_string') -DATE_CATEGORIES = OptionStr('misc', 'date_categories', ['tv']) +enable_date_sorting = OptionBool('misc', 'enable_date_sorting', False) +date_sort_string = OptionStr('misc', 'date_sort_string') +date_categories = OptionStr('misc', 'date_categories', ['tv']) -MATRIX_USERNAME = OptionStr('nzbmatrix', 'username') -MATRIX_APIKEY = OptionStr('nzbmatrix', 'apikey') +matrix_username = OptionStr('nzbmatrix', 'username') +matrix_apikey = OptionStr('nzbmatrix', 'apikey') -CONFIGLOCK = OptionBool('misc', 'config_lock', 0) +configlock = OptionBool('misc', 'config_lock', 0) -UMASK = OptionStr('misc', 'permissions', '', validation=validate_octal) -DOWNLOAD_DIR = OptionDir('misc', 'download_dir', DEF_DOWNLOAD_DIR, validation=validate_safedir) -DOWNLOAD_FREE = OptionStr('misc', 'download_free') -COMPLETE_DIR = OptionDir('misc', 'complete_dir', DEF_COMPLETE_DIR, apply_umask=True) -SCRIPT_DIR = OptionDir('misc', 'script_dir', create=False, validation=validate_dir_exists) -NZB_BACKUP_DIR = OptionDir('misc', 'nzb_backup_dir', DEF_NZBBACK_DIR) -CACHE_DIR = OptionDir('misc', 'cache_dir', 'cache', validation=validate_safedir) -ADMIN_DIR = OptionDir('misc', 'admin_dir', 'admin', validation=validate_safedir) -#LOG_DIR = OptionDir('misc', 'log_dir', 'logs') -DIRSCAN_DIR = OptionDir('misc', 'dirscan_dir', create=False) -DIRSCAN_SPEED = OptionNumber('misc', 'dirscan_speed', DEF_SCANRATE, 1, 3600) +umask = OptionStr('misc', 'permissions', '', validation=validate_octal) +download_dir = OptionDir('misc', 'download_dir', DEF_DOWNLOAD_DIR, validation=validate_safedir) +download_free = OptionStr('misc', 'download_free') +complete_dir = OptionDir('misc', 'complete_dir', DEF_COMPLETE_DIR, apply_umask=True) +script_dir = OptionDir('misc', 'script_dir', create=False, validation=validate_dir_exists) +nzb_backup_dir = OptionDir('misc', 'nzb_backup_dir', DEF_NZBBACK_DIR) +cache_dir = OptionDir('misc', 'cache_dir', 'cache', validation=validate_safedir) +admin_dir = OptionDir('misc', 'admin_dir', 'admin', validation=validate_safedir) +#log_dir = OptionDir('misc', 'log_dir', 'logs') +dirscan_dir = OptionDir('misc', 'dirscan_dir', create=False) +dirscan_speed = OptionNumber('misc', 'dirscan_speed', DEF_SCANRATE, 1, 3600) -CHERRYHOST = OptionStr('misc','host', DEF_HOST) +cherryhost = OptionStr('misc','host', DEF_HOST) if sabnzbd.WIN32: - CHERRYPORT = OptionStr('misc','port', DEF_PORT_WIN) + cherryport = OptionStr('misc','port', DEF_PORT_WIN) else: - CHERRYPORT = OptionStr('misc','port', DEF_PORT_UNIX) + cherryport = OptionStr('misc','port', DEF_PORT_UNIX) if sabnzbd.WIN32: - HTTPS_PORT = OptionStr('misc','https_port', DEF_PORT_WIN_SSL) + https_port = OptionStr('misc','https_port', DEF_PORT_WIN_SSL) else: - HTTPS_PORT = OptionStr('misc','https_port', DEF_PORT_UNIX_SSL) - -USERNAME = OptionStr('misc', 'username') -PASSWORD = OptionPassword('misc', 'password') -BANDWIDTH_LIMIT = OptionNumber('misc', 'bandwidth_limit', 0) -REFRESH_RATE = OptionNumber('misc', 'refresh_rate', 0) -RSS_RATE = OptionNumber('misc', 'rss_rate', 60, 15, 24*60) -CACHE_LIMIT = OptionStr('misc', 'cache_limit') -WEB_DIR = OptionStr('misc', 'web_dir', DEF_STDINTF) -WEB_DIR2 = OptionStr('misc', 'web_dir2') -WEB_COLOR = OptionStr('misc', 'web_color', '') -WEB_COLOR2 = OptionStr('misc', 'web_color2') -CLEANUP_LIST = OptionList('misc', 'cleanup_list') + https_port = OptionStr('misc','https_port', DEF_PORT_UNIX_SSL) + +username = OptionStr('misc', 'username') +password = OptionPassword('misc', 'password') +bandwidth_limit = OptionNumber('misc', 'bandwidth_limit', 0) +refresh_rate = OptionNumber('misc', 'refresh_rate', 0) +rss_rate = OptionNumber('misc', 'rss_rate', 60, 15, 24*60) +cache_limit = OptionStr('misc', 'cache_limit') +web_dir = OptionStr('misc', 'web_dir', DEF_STDINTF) +web_dir2 = OptionStr('misc', 'web_dir2') +web_color = OptionStr('misc', 'web_color', '') +web_color2 = OptionStr('misc', 'web_color2') +cleanup_list = OptionList('misc', 'cleanup_list') warned_old_queue = OptionBool('misc', 'warned_old_queue', False) -LOG_WEB = OptionBool('logging', 'enable_cherrypy_logging', False) -LOG_DIR = OptionDir('misc', 'log_dir', 'logs') -LOG_LEVEL = OptionNumber('logging', 'log_level', 1, 0, 2) -LOG_SIZE = OptionStr('logging', 'max_log_size', '5242880') -LOG_BACKUPS = OptionNumber('logging', 'log_backups', 5, 1, 1024) +log_web = OptionBool('logging', 'enable_cherrypy_logging', False) +log_dir = OptionDir('misc', 'log_dir', 'logs') +log_level = OptionNumber('logging', 'log_level', 1, 0, 2) +log_size = OptionStr('logging', 'max_log_size', '5242880') +log_backups = OptionNumber('logging', 'log_backups', 5, 1, 1024) -HTTPS_CERT = OptionDir('misc', 'https_cert', 'server.cert', create=False) -HTTPS_KEY = OptionDir('misc', 'https_key', 'server.key', create=False) -ENABLE_HTTPS = OptionBool('misc', 'enable_https', False) +https_cert = OptionDir('misc', 'https_cert', 'server.cert', create=False) +https_key = OptionDir('misc', 'https_key', 'server.key', create=False) +enable_https = OptionBool('misc', 'enable_https', False) -LANGUAGE = OptionStr('misc', 'language', 'us-en') -SSL_TYPE = OptionStr('misc', 'ssl_type', 'v23') -UNPACK_CHECK = OptionBool('misc', 'unpack_check', True) -NO_PENALTIES = OptionBool('misc', 'no_penalties', False) +language = OptionStr('misc', 'language', 'us-en') +ssl_type = OptionStr('misc', 'ssl_type', 'v23') +unpack_check = OptionBool('misc', 'unpack_check', True) +no_penalties = OptionBool('misc', 'no_penalties', False) # Internal options, not saved in INI file -DEBUG_DELAY = OptionNumber('misc', 'debug_delay', 0, add=False) +debug_delay = OptionNumber('misc', 'debug_delay', 0, add=False) -API_KEY = OptionStr('misc','api_key', create_api_key()) -DISABLE_KEY = OptionBool('misc', 'disable_api_key', False) +api_key = OptionStr('misc','api_key', create_api_key()) +disable_key = OptionBool('misc', 'disable_api_key', False) #------------------------------------------------------------------------------ # Set root folders for Folder config-items # def set_root_folders(home, lcldata, prog, interf): - EMAIL_DIR.set_root(home) - DOWNLOAD_DIR.set_root(home) - COMPLETE_DIR.set_root(home) - SCRIPT_DIR.set_root(home) - NZB_BACKUP_DIR.set_root(lcldata) - CACHE_DIR.set_root(lcldata) - ADMIN_DIR.set_root(lcldata) - DIRSCAN_DIR.set_root(home) - LOG_DIR.set_root(lcldata) + email_dir.set_root(home) + download_dir.set_root(home) + complete_dir.set_root(home) + script_dir.set_root(home) + nzb_backup_dir.set_root(lcldata) + cache_dir.set_root(lcldata) + admin_dir.set_root(lcldata) + dirscan_dir.set_root(home) + log_dir.set_root(lcldata) def set_root_folders2(): - HTTPS_CERT.set_root(ADMIN_DIR.get_path()) - HTTPS_KEY.set_root(ADMIN_DIR.get_path()) + https_cert.set_root(admin_dir.get_path()) + https_key.set_root(admin_dir.get_path()) diff --git a/main/sabnzbd/database.py b/main/sabnzbd/database.py index dc1e7cc..50e4b07 100644 --- a/main/sabnzbd/database.py +++ b/main/sabnzbd/database.py @@ -47,7 +47,7 @@ def get_history_handle(): """ Get an instance of the history db hanlder """ global _HISTORY_DB if not _HISTORY_DB: - _HISTORY_DB = os.path.join(sabnzbd.cfg.ADMIN_DIR.get_path(), DB_HISTORY_NAME) + _HISTORY_DB = os.path.join(sabnzbd.cfg.admin_dir.get_path(), DB_HISTORY_NAME) return HistoryDB(_HISTORY_DB) diff --git a/main/sabnzbd/decoder.py b/main/sabnzbd/decoder.py index d008ca7..2e6eff3 100644 --- a/main/sabnzbd/decoder.py +++ b/main/sabnzbd/decoder.py @@ -108,7 +108,7 @@ class Decoder(Thread): data = e.data - if cfg.FAIL_ON_CRC(): + if cfg.fail_on_crc(): new_server_found = self.__search_new_server(article) if new_server_found: register = False @@ -116,7 +116,7 @@ class Decoder(Thread): except BadYenc, e: logging.warning("Badly formed yEnc article in %s", article) - if cfg.FAIL_ON_CRC(): + if cfg.fail_on_crc(): new_server_found = self.__search_new_server(article) if new_server_found: register = False diff --git a/main/sabnzbd/dirscanner.py b/main/sabnzbd/dirscanner.py index fbaf183..473b7fa 100644 --- a/main/sabnzbd/dirscanner.py +++ b/main/sabnzbd/dirscanner.py @@ -226,17 +226,17 @@ class DirScanner(threading.Thread): self.shutdown = False self.error_reported = False # Prevents mulitple reporting of missing watched folder - self.dirscan_dir = cfg.DIRSCAN_DIR.get_path() - self.dirscan_speed = cfg.DIRSCAN_SPEED() - cfg.DIRSCAN_DIR.callback(self.newdir) + self.dirscan_dir = cfg.dirscan_dir.get_path() + self.dirscan_speed = cfg.dirscan_speed() + cfg.dirscan_dir.callback(self.newdir) DirScanner.do = self def newdir(self): """ We're notified of a dir change """ self.ignored = {} self.suspected = {} - self.dirscan_dir = cfg.DIRSCAN_DIR.get_path() - self.dirscan_speed = cfg.DIRSCAN_SPEED() + self.dirscan_dir = cfg.dirscan_dir.get_path() + self.dirscan_speed = cfg.dirscan_speed() def stop(self): self.save() diff --git a/main/sabnzbd/downloader.py b/main/sabnzbd/downloader.py index 18776ff..52e779f 100644 --- a/main/sabnzbd/downloader.py +++ b/main/sabnzbd/downloader.py @@ -99,7 +99,7 @@ def pause_downloader(save=True): global __DOWNLOADER if __DOWNLOADER: __DOWNLOADER.pause() - if cfg.AUTODISCONNECT(): + if cfg.autodisconnect(): __DOWNLOADER.disconnect() if save: sabnzbd.save_state() @@ -249,8 +249,8 @@ class Downloader(Thread): self.paused = paused #used for throttling bandwidth and scheduling bandwidth changes - self.bandwidth_limit = cfg.BANDWIDTH_LIMIT() - cfg.BANDWIDTH_LIMIT.callback(self.speed_set) + self.bandwidth_limit = cfg.bandwidth_limit() + cfg.bandwidth_limit.callback(self.speed_set) # Used for reducing speed self.delayed = False @@ -360,7 +360,7 @@ class Downloader(Thread): return self.bandwidth_limit def speed_set(self): - self.bandwidth_limit = cfg.BANDWIDTH_LIMIT() + self.bandwidth_limit = cfg.bandwidth_limit() def is_paused(self): if not self.paused: @@ -626,7 +626,7 @@ class Downloader(Thread): if block or (penalty and server.optional): if server.active: server.active = False - if (not server.optional) and cfg.NO_PENALTIES.get(): + if (not server.optional) and cfg.no_penalties.get(): penalty = _PENALTY_SHORT if penalty and (block or server.optional): logging.info('Server %s ignored for %s minutes', server.id, penalty) @@ -743,7 +743,7 @@ class Downloader(Thread): def __request_article(self, nw): try: - if cfg.SEND_GROUP() and nw.article.nzf.nzo.get_group() != nw.group: + if cfg.send_group() and nw.article.nzf.nzo.get_group() != nw.group: group = nw.article.nzf.nzo.get_group() logging.info('Thread %s@%s:%s: GROUP <%s>', nw.thrdnum, nw.server.host, diff --git a/main/sabnzbd/emailer.py b/main/sabnzbd/emailer.py index a87ccb7..d83d913 100644 --- a/main/sabnzbd/emailer.py +++ b/main/sabnzbd/emailer.py @@ -45,10 +45,10 @@ def send(message): if not message.strip('\n\r\t '): return "Skipped empty message" - if cfg.EMAIL_SERVER() and cfg.EMAIL_TO() and cfg.EMAIL_FROM(): + if cfg.email_server() and cfg.email_to() and cfg.email_from(): failure = T('error-mailSend') - server, port = split_host(cfg.EMAIL_SERVER()) + server, port = split_host(cfg.email_server()) if not port: port = 25 @@ -91,9 +91,9 @@ def send(message): return failure # Authentication - if (cfg.EMAIL_ACCOUNT() != "") and (cfg.EMAIL_PWD() != ""): + if (cfg.email_account() != "") and (cfg.email_pwd() != ""): try: - mailconn.login(cfg.EMAIL_ACCOUNT(), cfg.EMAIL_PWD()) + mailconn.login(cfg.email_account(), cfg.email_pwd()) except: logging.error(Ta('error-mailAuth')) return failure @@ -101,7 +101,7 @@ def send(message): try: if isinstance(message, unicode): message = message.encode('utf8') - mailconn.sendmail(cfg.EMAIL_FROM(), cfg.EMAIL_TO(), message) + mailconn.sendmail(cfg.email_from(), cfg.email_to(), message) except: logging.error(Ta('error-mailSend')) return failure @@ -117,7 +117,7 @@ def send(message): ################################################################################ -# EMAIL_ENDJOB +# email_endjob # # ################################################################################ @@ -126,12 +126,12 @@ from Cheetah.Template import Template def send_with_template(prefix, parm): """ Send an email using template """ - parm['to'] = cfg.EMAIL_TO() - parm['from'] = cfg.EMAIL_FROM() + parm['to'] = cfg.email_to() + parm['from'] = cfg.email_from() parm['date'] = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) lst = [] - path = cfg.EMAIL_DIR.get_path() + path = cfg.email_dir.get_path() if path and os.path.exists(path): try: lst = glob.glob(os.path.join(path, '%s-*.tmpl' % prefix)) @@ -139,7 +139,7 @@ def send_with_template(prefix, parm): logging.error(Ta('error-mailTempl@1'), path) else: path = os.path.join(sabnzbd.DIR_PROG, DEF_LANGUAGE) - tpath = os.path.join(path, '%s-%s.tmpl' % (prefix, cfg.LANGUAGE())) + tpath = os.path.join(path, '%s-%s.tmpl' % (prefix, cfg.language())) if os.path.exists(tpath): lst = [tpath] else: @@ -198,8 +198,8 @@ def rss_mail(feed, jobs): def diskfull(): """ Send email about disk full, no templates """ - if cfg.EMAIL_FULL(): - return send(T('email-full@2') % (cfg.EMAIL_TO(), cfg.EMAIL_FROM())) + if cfg.email_full(): + return send(T('email-full@2') % (cfg.email_to(), cfg.email_from())) else: return "" diff --git a/main/sabnzbd/interface.py b/main/sabnzbd/interface.py index 613871e..a8ef8f1 100644 --- a/main/sabnzbd/interface.py +++ b/main/sabnzbd/interface.py @@ -85,7 +85,7 @@ def check_server(host, port): def ListScripts(default=False): """ Return a list of script names """ lst = [] - dd = cfg.SCRIPT_DIR.get_path() + dd = cfg.script_dir.get_path() if dd and os.access(dd, os.R_OK): if default: @@ -164,7 +164,7 @@ def Strip(txt): # Web login support def get_users(): users = {} - users[cfg.USERNAME()] = cfg.PASSWORD() + users[cfg.username()] = cfg.password() return users def encrypt_pwd(pwd): @@ -174,7 +174,7 @@ def encrypt_pwd(pwd): def set_auth(conf): """ Set the authentication for CherryPy """ - if cfg.USERNAME() and cfg.PASSWORD(): + if cfg.username() and cfg.password(): conf.update({'tools.basic_auth.on' : True, 'tools.basic_auth.realm' : 'SABnzbd', 'tools.basic_auth.users' : get_users, 'tools.basic_auth.encrypt' : encrypt_pwd}) conf.update({'/api':{'tools.basic_auth.on' : False}, @@ -195,7 +195,7 @@ def check_session(kwargs): if not key: logging.warning(Ta('warn-missingKey')) msg = T('error-missingKey') - elif key != cfg.API_KEY(): + elif key != cfg.api_key(): logging.warning(Ta('error-badKey')) msg = T('error-badKey') return msg @@ -211,21 +211,21 @@ def check_apikey(kwargs, nokey=False): special = mode in ('get_scripts', 'qstatus') # First check APIKEY, if OK that's sufficient - if not (cfg.DISABLE_KEY() or nokey): + if not (cfg.disable_key() or nokey): key = kwargs.get('apikey') if not key: if not special: logging.warning(Ta('warn-apikeyNone')) return report(output, 'API Key Required') - elif key != cfg.API_KEY(): + elif key != cfg.api_key(): logging.warning(Ta('warn-apikeyBad')) return report(output, 'API Key Incorrect') else: return None # No active APIKEY, check web credentials instead - if cfg.USERNAME() and cfg.PASSWORD(): - if kwargs.get('ma_username') == cfg.USERNAME() and kwargs.get('ma_password') == cfg.PASSWORD(): + if cfg.username() and cfg.password(): + if kwargs.get('ma_username') == cfg.username() and kwargs.get('ma_password') == cfg.password(): pass else: if not special: @@ -373,11 +373,11 @@ class MainPage: if kwargs.get('skip_wizard') or config.get_servers(): info, pnfo_list, bytespersec = build_header(self.__prim) - if cfg.USERNAME_NEWZBIN() and cfg.PASSWORD_NEWZBIN.get_stars(): + if cfg.newzbin_username() and cfg.newzbin_password.get_stars(): info['newzbinDetails'] = True info['script_list'] = ListScripts(default=True) - info['script'] = cfg.DIRSCAN_SCRIPT() + info['script'] = cfg.dirscan_script() info['cat'] = 'Default' info['cat_list'] = ListCats(True) @@ -402,7 +402,7 @@ class MainPage: #def reset_lang(self, **kwargs): # msg = check_session(kwargs) # if msg: return msg - # reset_language(cfg.LANGUAGE()) + # reset_language(cfg.language()) # raise dcRaiser(self.__root, kwargs) @@ -834,9 +834,9 @@ class MainPage: elif name == 'set_colorscheme': if value: if self.__prim: - cfg.WEB_COLOR.set(value) + cfg.web_color.set(value) else: - cfg.WEB_COLOR2.set(value) + cfg.web_color2.set(value) return report(output) else: return report(output, _MSG_NO_VALUE) @@ -845,9 +845,9 @@ class MainPage: return report(output) elif name == 'set_apikey': - cfg.API_KEY.set(config.create_api_key()) + cfg.api_key.set(config.create_api_key()) config.save_config() - return report(output, keyword='apikey', data=cfg.API_KEY()) + return report(output, keyword='apikey', data=cfg.api_key()) elif name == 'test_server': @@ -873,9 +873,9 @@ class MainPage: if mode == 'auth': auth = 'None' - if cfg.USERNAME.get() and cfg.PASSWORD.get(): + if cfg.username.get() and cfg.password.get(): auth = 'login' - if not cfg.DISABLE_KEY.get(): + if not cfg.disable_key.get(): auth = 'apikey' return report(output, keyword='auth', data=auth) @@ -1235,9 +1235,9 @@ class QueuePage: if item: cat, pp, script, priority = cat_to_opts(cat) else: - script = cfg.DIRSCAN_SCRIPT() - pp = cfg.DIRSCAN_PP() - priority = cfg.DIRSCAN_PRIORITY() + script = cfg.dirscan_script() + pp = cfg.dirscan_pp() + priority = cfg.dirscan_priority() nzbqueue.change_script(nzo_id, script) nzbqueue.change_opts(nzo_id, pp) @@ -1349,7 +1349,7 @@ class HistoryPage: history['isverbose'] = self.__verbose - if cfg.USERNAME_NEWZBIN() and cfg.PASSWORD_NEWZBIN(): + if cfg.newzbin_username() and cfg.newzbin_password(): history['newzbinDetails'] = True #history_items, total_bytes, bytes_beginning = sabnzbd.history_info() @@ -1520,7 +1520,7 @@ class ConfigDirectories: @cherrypy.expose def index(self, **kwargs): - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) @@ -1572,7 +1572,7 @@ class ConfigSwitches: @cherrypy.expose def index(self, **kwargs): - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) @@ -1645,7 +1645,7 @@ class ConfigGeneral: else: return '' - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) @@ -1690,29 +1690,29 @@ class ConfigGeneral: conf['web_colors2'] = ['None'] conf['web_color2'] = 'None' - conf['web_dir'] = add_color(cfg.WEB_DIR(), cfg.WEB_COLOR()) - conf['web_dir2'] = add_color(cfg.WEB_DIR2(), cfg.WEB_COLOR2()) + conf['web_dir'] = add_color(cfg.web_dir(), cfg.web_color()) + conf['web_dir2'] = add_color(cfg.web_dir2(), cfg.web_color2()) - conf['language'] = cfg.LANGUAGE() + conf['language'] = cfg.language() list = list_languages(sabnzbd.DIR_LANGUAGE) if len(list) < 2: list = [] conf['lang_list'] = list - conf['disable_api_key'] = cfg.DISABLE_KEY() - conf['host'] = cfg.CHERRYHOST() - conf['port'] = cfg.CHERRYPORT() - conf['https_port'] = cfg.HTTPS_PORT() - conf['https_cert'] = cfg.HTTPS_CERT() - conf['https_key'] = cfg.HTTPS_KEY() - conf['enable_https'] = cfg.ENABLE_HTTPS() - conf['username'] = cfg.USERNAME() - conf['password'] = cfg.PASSWORD.get_stars() - conf['bandwidth_limit'] = cfg.BANDWIDTH_LIMIT() - conf['refresh_rate'] = cfg.REFRESH_RATE() - conf['rss_rate'] = cfg.RSS_RATE() - conf['cache_limit'] = cfg.CACHE_LIMIT() - conf['cleanup_list'] = List2String(cfg.CLEANUP_LIST()) + conf['disable_api_key'] = cfg.disable_key() + conf['host'] = cfg.cherryhost() + conf['port'] = cfg.cherryport() + conf['https_port'] = cfg.https_port() + conf['https_cert'] = cfg.https_cert() + conf['https_key'] = cfg.https_key() + conf['enable_https'] = cfg.enable_https() + conf['username'] = cfg.username() + conf['password'] = cfg.password.get_stars() + conf['bandwidth_limit'] = cfg.bandwidth_limit() + conf['refresh_rate'] = cfg.refresh_rate() + conf['rss_rate'] = cfg.rss_rate() + conf['cache_limit'] = cfg.cache_limit() + conf['cleanup_list'] = List2String(cfg.cleanup_list()) template = Template(file=os.path.join(self.__web_dir, 'config_general.tmpl'), filter=FILTER, searchList=[conf], compilerSettings=DIRECTIVES) @@ -1736,14 +1736,14 @@ class ConfigGeneral: # Handle special options language = kwargs.get('language') - if language and language != cfg.LANGUAGE(): - cfg.LANGUAGE.set(language) + if language and language != cfg.language(): + cfg.language.set(language) reset_language(language) cleanup_list = kwargs.get('cleanup_list') if cleanup_list and sabnzbd.WIN32: cleanup_list = cleanup_list.lower() - cfg.CLEANUP_LIST.set_string(cleanup_list) + cfg.cleanup_list.set_string(cleanup_list) web_dir = kwargs.get('web_dir') web_dir2 = kwargs.get('web_dir2') @@ -1755,15 +1755,15 @@ class ConfigGeneral: web_dir2_path = real_path(sabnzbd.DIR_INTERFACES, web_dir2) if web_dir2 == 'None': - cfg.WEB_DIR2.set('') + cfg.web_dir2.set('') elif os.path.exists(web_dir2_path): - cfg.WEB_DIR2.set(web_dir2) - cfg.WEB_COLOR2.set(web_color2) + cfg.web_dir2.set(web_dir2) + cfg.web_color2.set(web_color2) bandwidth_limit = kwargs.get('bandwidth_limit') if bandwidth_limit != None: bandwidth_limit = IntConv(bandwidth_limit) - cfg.BANDWIDTH_LIMIT.set(bandwidth_limit) + cfg.bandwidth_limit.set(bandwidth_limit) config.save_config() @@ -1777,7 +1777,7 @@ class ConfigGeneral: if msg: return msg logging.debug('API Key Changed') - cfg.API_KEY.set(config.create_api_key()) + cfg.api_key.set(config.create_api_key()) config.save_config() raise dcRaiser(self.__root, kwargs) @@ -1795,8 +1795,8 @@ def change_web_dir(web_dir): if not os.path.exists(web_dir_path): return badParameterResponse('Cannot find web template: %s' % web_dir_path) else: - cfg.WEB_DIR.set(web_dir) - cfg.WEB_COLOR.set(web_color) + cfg.web_dir.set(web_dir) + cfg.web_color.set(web_color) #------------------------------------------------------------------------------ @@ -1809,7 +1809,7 @@ class ConfigServer: @cherrypy.expose def index(self, **kwargs): - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) @@ -1941,7 +1941,7 @@ class ConfigRss: @cherrypy.expose def index(self, **kwargs): - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) @@ -2151,7 +2151,7 @@ class ConfigScheduling: days["7"] = T('sunday') return days - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) @@ -2230,10 +2230,10 @@ class ConfigScheduling: action = None if action: - sched = cfg.SCHEDULES() + sched = cfg.schedules() sched.append('%s %s %s %s %s' % (minute, hour, dayofweek, action, arguments)) - cfg.SCHEDULES.set(sched) + cfg.schedules.set(sched) config.save_config() scheduler.restart(force=True) @@ -2244,11 +2244,11 @@ class ConfigScheduling: msg = check_session(kwargs) if msg: return msg - schedules = cfg.SCHEDULES() + schedules = cfg.schedules() line = kwargs.get('line') if line and line in schedules: schedules.remove(line) - cfg.SCHEDULES.set(schedules) + cfg.schedules.set(schedules) config.save_config() scheduler.restart(force=True) raise dcRaiser(self.__root, kwargs) @@ -2263,21 +2263,21 @@ class ConfigNewzbin: @cherrypy.expose def index(self, **kwargs): - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) - conf['username_newzbin'] = cfg.USERNAME_NEWZBIN() - conf['password_newzbin'] = cfg.PASSWORD_NEWZBIN.get_stars() - conf['newzbin_bookmarks'] = int(cfg.NEWZBIN_BOOKMARKS()) - conf['newzbin_unbookmark'] = int(cfg.NEWZBIN_UNBOOKMARK()) - conf['bookmark_rate'] = cfg.BOOKMARK_RATE() + conf['username_newzbin'] = cfg.newzbin_username() + conf['password_newzbin'] = cfg.newzbin_password.get_stars() + conf['newzbin_bookmarks'] = int(cfg.newzbin_bookmarks()) + conf['newzbin_unbookmark'] = int(cfg.newzbin_unbookmark()) + conf['bookmark_rate'] = cfg.bookmark_rate() conf['bookmarks_list'] = self.__bookmarks - conf['matrix_username'] = cfg.MATRIX_USERNAME() - conf['matrix_apikey'] = cfg.MATRIX_APIKEY() + conf['matrix_username'] = cfg.matrix_username() + conf['matrix_apikey'] = cfg.matrix_apikey() template = Template(file=os.path.join(self.__web_dir, 'config_newzbin.tmpl'), filter=FILTER, searchList=[conf], compilerSettings=DIRECTIVES) @@ -2288,14 +2288,14 @@ class ConfigNewzbin: msg = check_session(kwargs) if msg: return msg - cfg.USERNAME_NEWZBIN.set(kwargs.get('username_newzbin')) - cfg.PASSWORD_NEWZBIN.set(kwargs.get('password_newzbin')) - cfg.NEWZBIN_BOOKMARKS.set(kwargs.get('newzbin_bookmarks')) - cfg.NEWZBIN_UNBOOKMARK.set(kwargs.get('newzbin_unbookmark')) - cfg.BOOKMARK_RATE.set(kwargs.get('bookmark_rate')) + cfg.newzbin_username.set(kwargs.get('username_newzbin')) + cfg.newzbin_password.set(kwargs.get('password_newzbin')) + cfg.newzbin_bookmarks.set(kwargs.get('newzbin_bookmarks')) + cfg.newzbin_unbookmark.set(kwargs.get('newzbin_unbookmark')) + cfg.bookmark_rate.set(kwargs.get('bookmark_rate')) - cfg.MATRIX_USERNAME.set(kwargs.get('matrix_username')) - cfg.MATRIX_APIKEY.set(kwargs.get('matrix_apikey')) + cfg.matrix_username.set(kwargs.get('matrix_username')) + cfg.matrix_apikey.set(kwargs.get('matrix_apikey')) config.save_config() raise dcRaiser(self.__root, kwargs) @@ -2305,8 +2305,8 @@ class ConfigNewzbin: msg = check_session(kwargs) if msg: return msg - cfg.MATRIX_USERNAME.set(kwargs.get('matrix_username')) - cfg.MATRIX_APIKEY.set(kwargs.get('matrix_apikey')) + cfg.matrix_username.set(kwargs.get('matrix_username')) + cfg.matrix_apikey.set(kwargs.get('matrix_apikey')) config.save_config() raise dcRaiser(self.__root, kwargs) @@ -2343,19 +2343,19 @@ class ConfigCats: @cherrypy.expose def index(self, **kwargs): - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) - if cfg.USERNAME_NEWZBIN() and cfg.PASSWORD_NEWZBIN(): + if cfg.newzbin_username() and cfg.newzbin_password(): conf['newzbinDetails'] = True conf['script_list'] = ListScripts(default=True) categories = config.get_categories() conf['have_cats'] = categories != {} - conf['defdir'] = cfg.COMPLETE_DIR.get_path() + conf['defdir'] = cfg.complete_dir.get_path() empty = { 'name':'', 'pp':'-1', 'script':'', 'dir':'', 'newzbin':'', 'priority':DEFAULT_PRIORITY } @@ -2421,11 +2421,11 @@ class ConfigSorting: @cherrypy.expose def index(self, **kwargs): - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) - conf['complete_dir'] = cfg.COMPLETE_DIR.get_path() + conf['complete_dir'] = cfg.complete_dir.get_path() for kw in SORT_LIST: conf[kw] = config.get_config('misc', kw)() @@ -2480,7 +2480,7 @@ class ConnectionInfo: header['logfile'] = sabnzbd.LOGFILE header['weblogfile'] = sabnzbd.WEBLOGFILE - header['loglevel'] = str(cfg.LOG_LEVEL()) + header['loglevel'] = str(cfg.log_level()) header['lastmail'] = self.__lastmail @@ -2554,7 +2554,7 @@ class ConnectionInfo: pack['unpack'] = ['action 1', 'action 2'] self.__lastmail= emailer.endjob('Test Job', 123, 'unknown', True, - os.path.normpath(os.path.join(cfg.COMPLETE_DIR.get_path(), '/unknown/Test Job')), + os.path.normpath(os.path.join(cfg.complete_dir.get_path(), '/unknown/Test Job')), str(123*MEBI), pack, 'my_script', 'Line 1\nLine 2\nLine 3\n', 0) raise dcRaiser(self.__root, kwargs) @@ -2588,7 +2588,7 @@ class ConnectionInfo: def change_loglevel(self, **kwargs): msg = check_session(kwargs) if msg: return msg - cfg.LOG_LEVEL.set(kwargs.get('loglevel')) + cfg.log_level.set(kwargs.get('loglevel')) config.save_config() raise dcRaiser(self.__root, kwargs) @@ -2719,7 +2719,7 @@ def _make_link(qfeed, job): title = '%s' % (job['url'], title) return '%s   %s%s
' % \ - (cfg.API_KEY() ,qfeed, name, cat, pp, script, prio, nzbname, T('link-download'), title, star) + (cfg.api_key() ,qfeed, name, cat, pp, script, prio, nzbname, T('link-download'), title, star) def ShowRssLog(feed, all): @@ -2819,16 +2819,16 @@ def build_header(prim): speed_limit = '' header['helpuri'] = 'http://wiki.sabnzbd.org/' - header['diskspace1'] = "%.2f" % diskfree(cfg.DOWNLOAD_DIR.get_path()) - header['diskspace2'] = "%.2f" % diskfree(cfg.COMPLETE_DIR.get_path()) - header['diskspacetotal1'] = "%.2f" % disktotal(cfg.DOWNLOAD_DIR.get_path()) - header['diskspacetotal2'] = "%.2f" % disktotal(cfg.COMPLETE_DIR.get_path()) + header['diskspace1'] = "%.2f" % diskfree(cfg.download_dir.get_path()) + header['diskspace2'] = "%.2f" % diskfree(cfg.complete_dir.get_path()) + header['diskspacetotal1'] = "%.2f" % disktotal(cfg.download_dir.get_path()) + header['diskspacetotal2'] = "%.2f" % disktotal(cfg.complete_dir.get_path()) header['loadavg'] = loadavg() header['speedlimit'] = "%s" % speed_limit header['restart_req'] = sabnzbd.RESTART_REQ header['have_warnings'] = str(sabnzbd.GUIHANDLER.count()) header['last_warning'] = sabnzbd.GUIHANDLER.last() - header['active_lang'] = cfg.LANGUAGE() + header['active_lang'] = cfg.language() if prim: header['webdir'] = sabnzbd.WEB_DIR else: @@ -2839,7 +2839,7 @@ def build_header(prim): header['darwin'] = sabnzbd.DARWIN header['power_options'] = sabnzbd.WIN32 or sabnzbd.DARWIN or sabnzbd.LINUX_POWER - header['session'] = cfg.API_KEY() + header['session'] = cfg.api_key() bytespersec = BPSMeter.do.get_bps() qnfo = nzbqueue.queue_info() @@ -2945,7 +2945,7 @@ class ConfigEmail: @cherrypy.expose def index(self, **kwargs): - if cfg.CONFIGLOCK(): + if cfg.configlock(): return Protected() conf, pnfo_list, bytespersec = build_header(self.__prim) @@ -3101,8 +3101,8 @@ def qstatus_data(): "mb" : qnfo[QNFO_BYTES_FIELD] / MEBI, "noofslots" : len(pnfo_list), "have_warnings" : str(sabnzbd.GUIHANDLER.count()), - "diskspace1" : diskfree(cfg.DOWNLOAD_DIR.get_path()), - "diskspace2" : diskfree(cfg.COMPLETE_DIR.get_path()), + "diskspace1" : diskfree(cfg.download_dir.get_path()), + "diskspace2" : diskfree(cfg.complete_dir.get_path()), "timeleft" : calc_timeleft(qnfo[QNFO_BYTES_LEFT_FIELD], bpsnow), "loadavg" : loadavg(), "jobs" : jobs @@ -3368,11 +3368,11 @@ def build_queue(web_dir=None, root=None, verbose=False, prim=True, verboseList=N else: info['queue_details'] = '0' - if cfg.USERNAME_NEWZBIN() and cfg.PASSWORD_NEWZBIN(): + if cfg.newzbin_username() and cfg.newzbin_password(): info['newzbinDetails'] = True - if cfg.REFRESH_RATE() > 0: - info['refresh_rate'] = str(cfg.REFRESH_RATE()) + if cfg.refresh_rate() > 0: + info['refresh_rate'] = str(cfg.refresh_rate()) else: info['refresh_rate'] = '' @@ -3578,7 +3578,7 @@ def rss_qstatus(): rss.channel.title = "SABnzbd Queue" rss.channel.description = "Overview of current downloads" rss.channel.link = "http://%s:%s/sabnzbd/queue" % ( \ - cfg.CHERRYHOST(), cfg.CHERRYPORT() ) + cfg.cherryhost(), cfg.cherryport() ) rss.channel.language = "en" item = Item() @@ -3614,7 +3614,7 @@ def rss_qstatus(): item.link = "https://newzbin.com/browse/post/%s/" % msgid else: item.link = "http://%s:%s/sabnzbd/history" % ( \ - cfg.CHERRYHOST(), cfg.CHERRYPORT() ) + cfg.cherryhost(), cfg.cherryport() ) statusLine = [] statusLine.append('') #Total MB/MB left diff --git a/main/sabnzbd/misc.py b/main/sabnzbd/misc.py index 74341fe..4ddc148 100644 --- a/main/sabnzbd/misc.py +++ b/main/sabnzbd/misc.py @@ -74,30 +74,30 @@ def cat_to_opts(cat, pp=None, script=None, priority=None): pp = config.get_categories()[safe_lower(cat)].pp() # Get the default pp if pp == '': - pp = cfg.DIRSCAN_PP() + pp = cfg.dirscan_pp() logging.debug('Job gets options %s', pp) except KeyError: - pp = cfg.DIRSCAN_PP() + pp = cfg.dirscan_pp() if not script: try: script = config.get_categories()[safe_lower(cat)].script() # Get the default script if script == '' or safe_lower(script) == 'default': - script = cfg.DIRSCAN_SCRIPT() + script = cfg.dirscan_script() logging.debug('Job gets script %s', script) except KeyError: - script = cfg.DIRSCAN_SCRIPT() + script = cfg.dirscan_script() if priority is None or priority == DEFAULT_PRIORITY: try: priority = config.get_categories()[safe_lower(cat)].priority() # Get the default priority if priority == DEFAULT_PRIORITY: - priority = cfg.DIRSCAN_PRIORITY() + priority = cfg.dirscan_priority() logging.debug('Job gets priority %s', script) except KeyError: - priority = cfg.DIRSCAN_PRIORITY() + priority = cfg.dirscan_priority() return cat, pp, script, priority @@ -215,7 +215,7 @@ def sanitize_foldername(name): illegal = FL_ILLEGAL legal = FL_LEGAL - repl = cfg.REPLACE_ILLEGAL.get() + repl = cfg.replace_illegal.get() lst = [] for ch in name.strip(): if ch in illegal: @@ -263,7 +263,7 @@ def create_all_dirs(path, umask=False): except: result = False if umask: - mask = cfg.UMASK() + mask = cfg.umask() if mask: try: os.chmod(path, int(mask, 8) | 0700) @@ -557,7 +557,7 @@ def panic_message(panic, a=None, b=None): if sabnzbd.WIN_SERVICE: sabnzbd.WIN_SERVICE.ErrLogger('Panic exit', msg) - if (not cfg.AUTOBROWSER()) or sabnzbd.DAEMON: + if (not cfg.autobrowser()) or sabnzbd.DAEMON: return msgfile, url = tempfile.mkstemp(suffix='.html') @@ -594,7 +594,7 @@ def panic(reason, remedy=""): def launch_a_browser(url, force=False): """Launch a browser pointing to the URL """ - if not force and not cfg.AUTOBROWSER() or sabnzbd.DAEMON: + if not force and not cfg.autobrowser() or sabnzbd.DAEMON: return logging.info("Lauching browser with %s", url) @@ -670,7 +670,7 @@ def convert_version(text): def check_latest_version(): """ Do an online check for the latest version """ - if not cfg.VERSION_CHECK(): + if not cfg.version_check(): return current, testver = convert_version(sabnzbd.__version__) @@ -967,7 +967,7 @@ def bad_fetch(nzo, url, msg='', retry=False, archive=False): else: nzbname = '' text = T('his-retryURL1@1')+', ' + T('his-retryURL2') + '' - parms = (msg, cfg.API_KEY(), urllib.quote(url), pp, cat, script, nzbname) + parms = (msg, cfg.api_key(), urllib.quote(url), pp, cat, script, nzbname) nzo.set_fail_msg(text % parms) else: if archive: @@ -984,11 +984,11 @@ def bad_fetch(nzo, url, msg='', retry=False, archive=False): def on_cleanup_list(filename, skip_nzb=False): """ Return True if a filename matches the clean-up list """ - if cfg.CLEANUP_LIST(): + if cfg.cleanup_list(): ext = os.path.splitext(filename)[1].strip().strip('.') if sabnzbd.WIN32: ext = ext.lower() - for k in cfg.CLEANUP_LIST(): + for k in cfg.cleanup_list(): item = k.strip().strip('.') if item == ext and not (skip_nzb and item == 'nzb'): return True diff --git a/main/sabnzbd/newsunpack.py b/main/sabnzbd/newsunpack.py index 37e108f..4245289 100644 --- a/main/sabnzbd/newsunpack.py +++ b/main/sabnzbd/newsunpack.py @@ -557,7 +557,7 @@ def RAR_Extract(rarfile, numrars, nzo, setname, extraction_path): p.wait() - if cfg.UNPACK_CHECK(): + if cfg.unpack_check(): if reliable_unpack_names(): all_found = True for path in expected_files: diff --git a/main/sabnzbd/newswrapper.py b/main/sabnzbd/newswrapper.py index 9bafe94..acb8e4e 100644 --- a/main/sabnzbd/newswrapper.py +++ b/main/sabnzbd/newswrapper.py @@ -150,7 +150,7 @@ class NNTP: if sslenabled and _ssl: # Some users benefit from SSLv2 not being capped. - ssl_type = sabnzbd.cfg.SSL_TYPE() + ssl_type = sabnzbd.cfg.ssl_type() if ssl_type == 'v2': ctx = _ssl.Context(_ssl.SSLv2_METHOD) elif ssl_type == 'v3': diff --git a/main/sabnzbd/newzbin.py b/main/sabnzbd/newzbin.py index b81fa42..8c5d29e 100644 --- a/main/sabnzbd/newzbin.py +++ b/main/sabnzbd/newzbin.py @@ -161,7 +161,7 @@ def _grabnzb(msgid): else: conn = httplib.HTTPConnection('www.newzbin.com') - postdata = { 'username': cfg.USERNAME_NEWZBIN(), 'password': cfg.PASSWORD_NEWZBIN(), 'reportid': msgid } + postdata = { 'username': cfg.newzbin_username(), 'password': cfg.newzbin_password(), 'reportid': msgid } postdata = urllib.urlencode(postdata) headers['Content-type'] = 'application/x-www-form-urlencoded' @@ -285,11 +285,11 @@ class Bookmarks: if delete: logging.debug('Trying to delete Newzbin bookmark %s', delete) - postdata = { 'username': cfg.USERNAME_NEWZBIN(), 'password': cfg.PASSWORD_NEWZBIN(), 'action': 'delete', \ + postdata = { 'username': cfg.newzbin_username(), 'password': cfg.newzbin_password(), 'action': 'delete', \ 'reportids' : delete } else: logging.info('Fetching Newzbin bookmarks') - postdata = { 'username': cfg.USERNAME_NEWZBIN(), 'password': cfg.PASSWORD_NEWZBIN(), 'action': 'fetch'} + postdata = { 'username': cfg.newzbin_username(), 'password': cfg.newzbin_password(), 'action': 'fetch'} postdata = urllib.urlencode(postdata) headers['Content-type'] = 'application/x-www-form-urlencoded' @@ -345,7 +345,7 @@ class Bookmarks: if msgid and (msgid not in self.bookmarks): self.bookmarks.append(msgid) logging.info("Found new bookmarked msgid %s (%s)", msgid, text) - sabnzbd.add_msgid(int(msgid), None, None, priority=cfg.DIRSCAN_PRIORITY()) + sabnzbd.add_msgid(int(msgid), None, None, priority=cfg.dirscan_priority()) else: logging.error(Ta('error-nbUnkownError@1'), rcode) @@ -359,7 +359,7 @@ class Bookmarks: return self.bookmarks def del_bookmark(self, msgid): - if cfg.NEWZBIN_BOOKMARKS() and cfg.NEWZBIN_UNBOOKMARK(): + if cfg.newzbin_bookmarks() and cfg.newzbin_unbookmark(): msgid = str(msgid) if msgid in self.bookmarks: self.run(msgid) diff --git a/main/sabnzbd/nzbqueue.py b/main/sabnzbd/nzbqueue.py index 508ae9b..8374f82 100644 --- a/main/sabnzbd/nzbqueue.py +++ b/main/sabnzbd/nzbqueue.py @@ -56,13 +56,13 @@ class NzbQueue(TryList): self.__downloaded_items = [] - self.__top_only = cfg.TOP_ONLY() + self.__top_only = cfg.top_only() self.__top_nzo = None self.__nzo_list = [] self.__nzo_table = {} - self.__auto_sort = cfg.AUTO_SORT() + self.__auto_sort = cfg.auto_sort() nzo_ids = [] @@ -75,11 +75,11 @@ class NzbQueue(TryList): logging.error(Ta('error-qBad')) self.__downloaded_items = [] nzo_ids = [] - panic_queue(os.path.join(cfg.CACHE_DIR.get_path(),QUEUE_FILE_NAME)) + panic_queue(os.path.join(cfg.cache_dir.get_path(),QUEUE_FILE_NAME)) exit_sab(2) except ValueError: logging.error(Ta('error-qCorruptFile@1'), - os.path.join(cfg.CACHE_DIR.get_path(), QUEUE_FILE_NAME)) + os.path.join(cfg.cache_dir.get_path(), QUEUE_FILE_NAME)) for nzo_id in nzo_ids: nzo = sabnzbd.load_data(nzo_id, remove = False) @@ -601,7 +601,7 @@ class NzbQueue(TryList): if not self.__nzo_list: # Close server connections - if cfg.AUTODISCONNECT(): + if cfg.autodisconnect(): sabnzbd.downloader.disconnect() # Sets the end-of-queue back on if disabled diff --git a/main/sabnzbd/nzbstuff.py b/main/sabnzbd/nzbstuff.py index 4e31206..08071b4 100644 --- a/main/sabnzbd/nzbstuff.py +++ b/main/sabnzbd/nzbstuff.py @@ -301,7 +301,7 @@ class NzbParser(xml.sax.handler.ContentHandler): self.nzf_list = [] def startDocument(self): - self.filter = cfg.IGNORE_SAMPLES() + self.filter = cfg.ignore_samples() def startElement(self, name, attrs): if name == 'segment' and self.in_nzb and self.in_file and self.in_segments: @@ -520,7 +520,7 @@ class NzbObject(TryList): self.extra5 = None self.extra6 = None - self.create_group_folder = cfg.CREATE_GROUP_FOLDERS() + self.create_group_folder = cfg.create_group_folders() # Remove leading msgid_XXXX and trailing .nzb self.__dirname, self.__msgid = SplitFileName(self.__dirname) @@ -533,10 +533,10 @@ class NzbObject(TryList): # Apply conversion option to final folder, called __original_dirname # Yeah, I know :( - if cfg.REPLACE_DOTS() and ' ' not in self.__original_dirname: + if cfg.replace_dots() and ' ' not in self.__original_dirname: logging.info('Replacing dots with spaces in %s', self.__original_dirname) self.__original_dirname = self.__original_dirname.replace('.',' ') - if cfg.REPLACE_SPACES(): + if cfg.replace_spaces(): logging.info('Replacing spaces with underscores in %s', self.__dirname) self.__original_dirname = self.__original_dirname.replace(' ','_') @@ -580,10 +580,10 @@ class NzbObject(TryList): self.__cat, pp, self.__script, self.__priority = cat_to_opts(cat, pp, script, self.__priority) self.__repair, self.__unpack, self.__delete = sabnzbd.pp_to_opts(pp) - if cfg.CREATE_GROUP_FOLDERS(): + if cfg.create_group_folders(): self.__dirprefix.append(self.get_group()) - if cfg.AUTO_SORT(): + if cfg.auto_sort(): self.__files.sort(cmp=_nzf_cmp_date) else: self.__files.sort(cmp=_nzf_cmp_name) diff --git a/main/sabnzbd/postproc.py b/main/sabnzbd/postproc.py index 347144a..ceed80e 100644 --- a/main/sabnzbd/postproc.py +++ b/main/sabnzbd/postproc.py @@ -146,12 +146,12 @@ class PostProcessor(Thread): if not nzo: break ## Pause downloader, if users wants that - if cfg.PAUSE_ON_POST_PROCESSING(): + if cfg.pause_on_post_processing(): sabnzbd.downloader.idle_downloader() start = time.time() - folder_rename = cfg.FOLDER_RENAME() + folder_rename = cfg.folder_rename() # keep track of if par2 fails parResult = True @@ -185,7 +185,7 @@ class PostProcessor(Thread): try: # Get the folder containing the download result - workdir = os.path.join(cfg.DOWNLOAD_DIR.get_path(), nzo.get_dirname()) + workdir = os.path.join(cfg.download_dir.get_path(), nzo.get_dirname()) # if the directory has not been made, no files were assembled if not os.path.exists(workdir): @@ -233,17 +233,17 @@ class PostProcessor(Thread): if parResult: jobResult = 0 ## Check if user allows unsafe post-processing - if not cfg.SAFE_POSTPROC(): + if not cfg.safe_postproc(): parResult = True ## Determine class directory if config.get_categories(): - complete_dir = Cat2Dir(cat, cfg.COMPLETE_DIR.get_path()) - elif cfg.CREATE_GROUP_FOLDERS(): - complete_dir = addPrefixes(cfg.COMPLETE_DIR.get_path(), nzo) + complete_dir = Cat2Dir(cat, cfg.complete_dir.get_path()) + elif cfg.create_group_folders(): + complete_dir = addPrefixes(cfg.complete_dir.get_path(), nzo) complete_dir = create_dirs(complete_dir) else: - complete_dir = cfg.COMPLETE_DIR.get_path() + complete_dir = cfg.complete_dir.get_path() base_dir = os.path.normpath(complete_dir) ## Determine destination directory @@ -297,7 +297,7 @@ class PostProcessor(Thread): ## Set permissions right if not sabnzbd.WIN32: - perm_script(tmp_workdir_complete, cfg.UMASK()) + perm_script(tmp_workdir_complete, cfg.umask()) if parResult: ## Remove files matching the cleanup list @@ -329,7 +329,7 @@ class PostProcessor(Thread): if unpackError: jobResult = jobResult + 2 - if cfg.IGNORE_SAMPLES() > 0: + if cfg.ignore_samples() > 0: remove_samples(workdir_complete) ## TV/Movie/Date Renaming code part 2 - rename and move files to parent folder @@ -340,9 +340,9 @@ class PostProcessor(Thread): ## Run the user script fname = "" - if parResult and (not nzb_list) and cfg.SCRIPT_DIR.get_path() and script and script!='None' and script!='Default': + if parResult and (not nzb_list) and cfg.script_dir.get_path() and script and script!='None' and script!='Default': #set the current nzo status to "Ext Script...". Used in History - script_path = os.path.join(cfg.SCRIPT_DIR.get_path(), script) + script_path = os.path.join(cfg.script_dir.get_path(), script) if os.path.exists(script_path): nzo.set_status('Running') nzo.set_action_line(T('msg-running'), unicoder(script)) @@ -361,8 +361,8 @@ class PostProcessor(Thread): script_ret = 0 ## Email the results - if (not nzb_list) and cfg.EMAIL_ENDJOB(): - if (cfg.EMAIL_ENDJOB() == 1) or (cfg.EMAIL_ENDJOB() == 2 and (unpackError or not parResult)): + if (not nzb_list) and cfg.email_endjob(): + if (cfg.email_endjob() == 1) or (cfg.email_endjob() == 2 and (unpackError or not parResult)): emailer.endjob(dirname, msgid, cat, mailResult, workdir_complete, nzo.get_bytes_downloaded(), nzo.get_unpack_info(), script, TRANS(script_log), script_ret) @@ -498,7 +498,7 @@ def Cat2Dir(cat, defdir): ddir = item.dir() else: return defdir - ddir = real_path(cfg.COMPLETE_DIR.get_path(), ddir) + ddir = real_path(cfg.complete_dir.get_path(), ddir) ddir = create_dirs(ddir) if not ddir: ddir = defdir @@ -540,7 +540,7 @@ def HandleEmptyQueue(): def CleanUpList(wdir, skip_nzb): """ Remove all files matching the cleanup list """ - if cfg.CLEANUP_LIST(): + if cfg.cleanup_list(): try: files = os.listdir(wdir) except: diff --git a/main/sabnzbd/rss.py b/main/sabnzbd/rss.py index a0ce605..e9f4740 100644 --- a/main/sabnzbd/rss.py +++ b/main/sabnzbd/rss.py @@ -277,7 +277,7 @@ class RSSQueue: newlinks.append(link) - if cfg.NO_DUPES() and dup_title(feed, title): + if cfg.no_dupes() and dup_title(feed, title): logging.info("Ignoring duplicate job %s", atitle) continue @@ -346,7 +346,7 @@ class RSSQueue: order += 1 # Send email if wanted and not "forced" - if new_downloads and cfg.EMAIL_RSS() and not force: + if new_downloads and cfg.email_rss() and not force: emailer.rss_mail(feed, new_downloads) # If links are in table for more than 4 weeks, remove diff --git a/main/sabnzbd/scheduler.py b/main/sabnzbd/scheduler.py index 0dc0223..1f70395 100644 --- a/main/sabnzbd/scheduler.py +++ b/main/sabnzbd/scheduler.py @@ -56,7 +56,7 @@ def init(): reset_guardian() __SCHED = kronos.ThreadedScheduler() - for schedule in cfg.SCHEDULES(): + for schedule in cfg.schedules(): arguments = [] argument_list = None try: @@ -118,14 +118,14 @@ def init(): kronos.method.sequential, None, None) # Set RSS check interval - interval = cfg.RSS_RATE() + interval = cfg.rss_rate() delay = random.randint(0, interval-1) logging.debug("Scheduling RSS interval task every %s min (delay=%s)", interval, delay) __SCHED.add_interval_task(rss.run_method, "RSS", delay*60, interval*60, kronos.method.sequential, None, None) __SCHED.add_single_task(rss.run_method, 'RSS', 15, kronos.method.sequential, None, None) - if cfg.VERSION_CHECK(): + if cfg.version_check(): # Check for new release, once per week on random time m = random.randint(0, 59) h = random.randint(0, 23) @@ -136,8 +136,8 @@ def init(): kronos.method.sequential, [], None) - if cfg.NEWZBIN_BOOKMARKS(): - interval = cfg.BOOKMARK_RATE() + if cfg.newzbin_bookmarks(): + interval = cfg.bookmark_rate() delay = random.randint(0, interval-1) logging.debug("Scheduling Bookmark interval task every %s min (delay=%s)", interval, delay) __SCHED.add_interval_task(Bookmarks.do.run, 'Bookmarks', delay*60, interval*60, @@ -146,9 +146,9 @@ def init(): # Subscribe to special schedule changes - cfg.NEWZBIN_BOOKMARKS.callback(schedule_guard) - cfg.BOOKMARK_RATE.callback(schedule_guard) - cfg.RSS_RATE.callback(schedule_guard) + cfg.newzbin_bookmarks.callback(schedule_guard) + cfg.bookmark_rate.callback(schedule_guard) + cfg.rss_rate.callback(schedule_guard) def start(): @@ -208,7 +208,7 @@ def sort_schedules(forward): now_hm = int(now[3])*60 + int(now[4]) now = int(now[6])*24*60 + now_hm - for schedule in cfg.SCHEDULES(): + for schedule in cfg.schedules(): parms = None try: m, h, d, action, parms = schedule.split(None, 4) diff --git a/main/sabnzbd/tvsort.py b/main/sabnzbd/tvsort.py index cafdf98..d79f20c 100644 --- a/main/sabnzbd/tvsort.py +++ b/main/sabnzbd/tvsort.py @@ -132,7 +132,7 @@ class Sorter: if self.type == 'movie': move_to_parent = True # check if we should leave the files inside an extra folder - if cfg.MOVIE_EXTRA_FOLDER(): + if cfg.movie_extra_folders(): #if there is a folder in the download, leave it in an extra folder move_to_parent = not check_for_folder(workdir_complete) if move_to_parent: @@ -151,8 +151,8 @@ class SeriesSorter: self.original_dirname = dirname self.original_path = path self.cat = cat - self.sort_string = cfg.TV_SORT_STRING() - self.cats = cfg.TV_CATEGORIES() + self.sort_string = cfg.tv_sort_string() + self.cats = cfg.tv_categories() self.filename_set = '' self.match_obj = None @@ -169,7 +169,7 @@ class SeriesSorter: def match(self): ''' Checks the regex for a match, if so set self.match to true ''' - if cfg.ENABLE_TV_SORTING() and cfg.TV_SORT_STRING(): + if cfg.enable_tv_sorting() and cfg.tv_sort_string(): if (self.cat and self.cat.lower() in self.cats) or (not self.cat and 'None' in self.cats): #First check if the show matches TV episode regular expressions. Returns regex match object self.match_obj, self.extras = check_regexs(self.original_dirname, series_match, double=True) @@ -456,9 +456,9 @@ class GenericSorter: self.original_dirname = dirname self.original_path = path - self.sort_string = cfg.MOVIE_SORT_STRING() - self.extra = cfg.MOVIE_SORT_EXTRA() - self.cats = cfg.MOVIE_CATEGORIES() + self.sort_string = cfg.movie_sort_string() + self.extra = cfg.movie_sort_extra() + self.cats = cfg.movie_categories() self.cat = cat self.filename_set = '' @@ -474,7 +474,7 @@ class GenericSorter: def match(self): ''' Checks the category for a match, if so set self.match to true ''' - if cfg.ENABLE_MOVIE_SORTING() and self.sort_string: + if cfg.enable_movie_sorting() and self.sort_string: #First check if the show matches TV episode regular expressions. Returns regex match object if (self.cat and self.cat.lower() in self.cats) or (not self.cat and 'None' in self.cats): logging.debug("Movie Sorting - Starting folder sort (%s)", self.original_dirname) @@ -645,8 +645,8 @@ class DateSorter: self.original_dirname = dirname self.original_path = path - self.sort_string = cfg.DATE_SORT_STRING() - self.cats = cfg.DATE_CATEGORIES() + self.sort_string = cfg.date_sort_string() + self.cats = cfg.date_categories() self.cat = cat self.filename_set = '' @@ -663,7 +663,7 @@ class DateSorter: def match(self): ''' Checks the category for a match, if so set self.matched to true ''' - if cfg.ENABLE_DATE_SORTING() and self.sort_string: + if cfg.enable_date_sorting() and self.sort_string: #First check if the show matches TV episode regular expressions. Returns regex match object if (self.cat and self.cat.lower() in self.cats) or (not self.cat and 'None' in self.cats): self.match_obj, self.date_type = checkForDate(self.original_dirname, date_match) @@ -827,7 +827,7 @@ def getTitles(match, name): name = name[:match.start()] # Replace .US. with (US) - if cfg.TV_SORT_COUNTRIES() == 1: + if cfg.tv_sort_countries() == 1: for rep in COUNTRY_REP: # (us) > (US) name = replace_word(name, rep.lower(), rep) @@ -837,7 +837,7 @@ def getTitles(match, name): dotted_country = '.%s.' % (rep.strip('()')) name = replace_word(name, dotted_country, rep) # Remove .US. and (US) - elif cfg.TV_SORT_COUNTRIES() == 2: + elif cfg.tv_sort_countries() == 2: for rep in COUNTRY_REP: # Remove (US) name = replace_word(name, rep, '') @@ -854,11 +854,11 @@ def getTitles(match, name): title = title.replace("'S", "'s") # Replace titled country names, (Us) with (US) and so on - if cfg.TV_SORT_COUNTRIES() == 1: + if cfg.tv_sort_countries() == 1: for rep in COUNTRY_REP: title = title.replace(titler(rep), rep) # Remove country names, ie (Us) - elif cfg.TV_SORT_COUNTRIES() == 2: + elif cfg.tv_sort_countries() == 2: for rep in COUNTRY_REP: title = title.replace(titler(rep), '').strip() diff --git a/main/sabnzbd/urlgrabber.py b/main/sabnzbd/urlgrabber.py index 532391e..e4deb79 100644 --- a/main/sabnzbd/urlgrabber.py +++ b/main/sabnzbd/urlgrabber.py @@ -171,8 +171,8 @@ def _matrix_url(url): if m: matrix_id = m.group(2) if not _RE_NZBMATRIX_USER.search(url) or not _RE_NZBMATRIX_API.search(url): - user = urllib.quote_plus(cfg.MATRIX_USERNAME()) - key = urllib.quote_plus(cfg.MATRIX_APIKEY()) + user = urllib.quote_plus(cfg.matrix_username()) + key = urllib.quote_plus(cfg.matrix_apikey()) url = '%s://nzbmatrix.com/api-nzb-download.php?id=%s&username=%s&apikey=%s' % \ (_PROTOCOL, matrix_id, user, key) return url, matrix_id diff --git a/main/sabnzbd/utils/upload.py b/main/sabnzbd/utils/upload.py index b57faeb..d593b41 100644 --- a/main/sabnzbd/utils/upload.py +++ b/main/sabnzbd/utils/upload.py @@ -31,13 +31,13 @@ def upload_file(url, fp): """ Function for uploading nzbs to a running sabnzbd instance """ try: fp = urllib.quote_plus(fp) - pp = cfg.DIRSCAN_PP() - script = cfg.DIRSCAN_SCRIPT() - priority = cfg.DIRSCAN_PRIORITY() + pp = cfg.dirscan_pp() + script = cfg.dirscan_script() + priority = cfg.dirscan_priority() url = '%sapi?mode=addlocalfile&name=%s&pp=%s&script=%s&priority=%s' % (url, fp, pp, script, priority) - username = cfg.USERNAME() - password = cfg.PASSWORD() - apikey = cfg.API_KEY() + username = cfg.username() + password = cfg.password() + apikey = cfg.api_key() if username and password: url = '%s&ma_username=%s&ma_password=%s' % (url, username, password) if apikey: @@ -53,9 +53,9 @@ def add_local(f): if os.path.exists(f): fn = get_filename(f) if fn: - pp = cfg.DIRSCAN_PP() - script = cfg.DIRSCAN_SCRIPT() - priority = cfg.DIRSCAN_PRIORITY() + pp = cfg.dirscan_pp() + script = cfg.dirscan_script() + priority = cfg.dirscan_priority() if get_ext(fn) in ('.zip','.rar', '.gz'): ProcessArchiveFile(fn, f, pp=pp, script=script, priority=priority, keep=True) elif get_ext(fn) in ('.nzb'): diff --git a/main/sabnzbd/wizard.py b/main/sabnzbd/wizard.py index 63c5374..816bff7 100644 --- a/main/sabnzbd/wizard.py +++ b/main/sabnzbd/wizard.py @@ -48,7 +48,7 @@ class Wizard: info = self.info.copy() info['num'] = '' info['number'] = 0 - info['lang'] = cfg.LANGUAGE() + info['lang'] = cfg.language() info['languages'] = list_languages(sabnzbd.DIR_LANGUAGE) if not os.path.exists(self.__web_dir): @@ -63,14 +63,14 @@ class Wizard: def one(self, **kwargs): # Handle special options language = kwargs.get('lang') - if language and language != cfg.LANGUAGE(): - cfg.LANGUAGE.set(language) + if language and language != cfg.language(): + cfg.language.set(language) reset_language(language) info = self.info.copy() info['num'] = '» %s' % T('wizard-step-one') info['number'] = 1 - info['skin'] = cfg.WEB_DIR().lower() + info['skin'] = cfg.web_dir().lower() template = Template(file=os.path.join(self.__web_dir, 'one.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) @@ -87,7 +87,7 @@ class Wizard: info['num'] = '» %s' % T('wizard-step-two') info['number'] = 2 - host = cfg.CHERRYHOST() + host = cfg.cherryhost() info['host'] = host # Allow special operation if host is not one of the defaults if host not in ('localhost','0.0.0.0'): @@ -100,10 +100,10 @@ class Wizard: else: info['have_ssl'] = False - info['enable_https'] = cfg.ENABLE_HTTPS() - info['autobrowser'] = cfg.AUTOBROWSER() - info['web_user'] = cfg.USERNAME() - info['web_pass'] = cfg.PASSWORD() + info['enable_https'] = cfg.enable_https() + info['autobrowser'] = cfg.autobrowser() + info['web_user'] = cfg.username() + info['web_pass'] = cfg.password() template = Template(file=os.path.join(self.__web_dir, 'two.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) @@ -114,17 +114,17 @@ class Wizard: # Save access/autobrowser/autostart if kwargs: if 'access' in kwargs: - cfg.CHERRYHOST.set(kwargs['access']) - cfg.ENABLE_HTTPS.set(kwargs.get('enable_https',0)) - cfg.AUTOBROWSER.set(kwargs.get('autobrowser',0)) - cfg.USERNAME.set(kwargs.get('web_user', '')) - cfg.PASSWORD.set(kwargs.get('web_pass', '')) - if not cfg.USERNAME() or not cfg.PASSWORD(): + cfg.cherryhost.set(kwargs['access']) + cfg.enable_https.set(kwargs.get('enable_https',0)) + cfg.autobrowser.set(kwargs.get('autobrowser',0)) + cfg.username.set(kwargs.get('web_user', '')) + cfg.password.set(kwargs.get('web_pass', '')) + if not cfg.username() or not cfg.password(): sabnzbd.interface.set_auth(cherrypy.config) info = self.info.copy() info['num'] = '» %s' % T('wizard-step-three') info['number'] = 3 - info['session'] = cfg.API_KEY() + info['session'] = cfg.api_key() servers = config.get_servers() if not servers: @@ -160,11 +160,11 @@ class Wizard: info = self.info.copy() info['num'] = '» %s' % T('wizard-step-four') info['number'] = 4 - info['newzbin_user'] = cfg.USERNAME_NEWZBIN() - info['newzbin_pass'] = cfg.PASSWORD_NEWZBIN.get_stars() - info['newzbin_bookmarks'] = cfg.NEWZBIN_BOOKMARKS() - info['matrix_user'] = cfg.MATRIX_USERNAME() - info['matrix_apikey'] = cfg.MATRIX_APIKEY() + info['newzbin_user'] = cfg.newzbin_username() + info['newzbin_pass'] = cfg.newzbin_password.get_stars() + info['newzbin_bookmarks'] = cfg.newzbin_bookmarks() + info['matrix_user'] = cfg.matrix_username() + info['matrix_apikey'] = cfg.matrix_apikey() template = Template(file=os.path.join(self.__web_dir, 'four.html'), searchList=[info], compilerSettings=sabnzbd.interface.DIRECTIVES) return template.respond() @@ -174,12 +174,12 @@ class Wizard: # Save server details if kwargs: if 'newzbin_user' in kwargs and 'newzbin_pass' in kwargs: - cfg.USERNAME_NEWZBIN.set(kwargs.get('newzbin_user','')) - cfg.PASSWORD_NEWZBIN.set(kwargs.get('newzbin_pass','')) - cfg.NEWZBIN_BOOKMARKS.set(kwargs.get('newzbin_bookmarks', '0')) + cfg.newzbin_username.set(kwargs.get('newzbin_user','')) + cfg.newzbin_password.set(kwargs.get('newzbin_pass','')) + cfg.newzbin_bookmarks.set(kwargs.get('newzbin_bookmarks', '0')) if 'matrix_user' in kwargs and 'matrix_apikey' in kwargs: - cfg.MATRIX_USERNAME.set(kwargs.get('matrix_user','')) - cfg.MATRIX_APIKEY.set(kwargs.get('matrix_apikey','')) + cfg.matrix_username.set(kwargs.get('matrix_user','')) + cfg.matrix_apikey.set(kwargs.get('matrix_apikey','')) config.save_config() @@ -187,7 +187,7 @@ class Wizard: info['num'] = '» %s' % T('wizard-step-five') info['number'] = 5 info['helpuri'] = 'http://wiki.sabnzbd.org/' - info['session'] = cfg.API_KEY() + info['session'] = cfg.api_key() info['access_url'], info['urls'] = self.get_access_info() @@ -199,7 +199,7 @@ class Wizard: ''' Build up a list of url's that sabnzbd can be accessed from ''' # Access_url is used to provide the user a link to sabnzbd depending on the host access_uri = 'localhost' - cherryhost = cfg.CHERRYHOST() + cherryhost = cfg.cherryhost() if cherryhost == '0.0.0.0': import socket @@ -252,17 +252,17 @@ class Wizard: urls = [] for sock in socks: if sock: - if cfg.ENABLE_HTTPS(): - url = 'https://%s:%s/sabnzbd/' % (sock, cfg.HTTPS_PORT()) + if cfg.enable_https(): + url = 'https://%s:%s/sabnzbd/' % (sock, cfg.https_port()) else: - url = 'http://%s:%s/sabnzbd/' % (sock, cfg.CHERRYPORT()) + url = 'http://%s:%s/sabnzbd/' % (sock, cfg.cherryport()) urls.append(url) - if cfg.ENABLE_HTTPS(): - access_url = 'https://%s:%s/sabnzbd/' % (access_uri, cfg.HTTPS_PORT()) + if cfg.enable_https(): + access_url = 'https://%s:%s/sabnzbd/' % (access_uri, cfg.https_port()) else: - access_url = 'http://%s:%s/sabnzbd/' % (access_uri, cfg.CHERRYPORT()) + access_url = 'http://%s:%s/sabnzbd/' % (access_uri, cfg.cherryport()) return access_url, urls