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('