@ -301,35 +301,18 @@ def check_apikey(kwargs, nokey=False):
return None
class NoPage ( object ) :
def __init__ ( self ) :
pass
@cherrypy . expose
def index ( self , * * kwargs ) :
return badParameterResponse ( T ( ' Error: No secondary interface defined. ' ) )
##############################################################################
class MainPage ( object ) :
def __init__ ( self , web_dir , root , web_dir_config = None , sub_mount = False ) :
self . __root = root
self . __web_dir = web_dir
def __init__ ( self ) :
# Add all sub-pages
self . login = LoginPage ( web_dir_config , root + ' login/ ' )
self . queue = QueuePage ( web_dir , root + ' queue/ ' )
self . history = HistoryPage ( web_dir , root + ' history/ ' )
self . status = Status ( web_dir , root + ' status/ ' )
self . config = ConfigPage ( web_dir_config , root + ' config/ ' )
self . nzb = NzoPage ( web_dir , root + ' nzb/ ' )
self . wizard = sabnzbd . wizard . Wizard ( web_dir , root + ' wizard/ ' )
# Add them again for the /sabnzbd/ links
if not sub_mount :
self . sabnzbd = MainPage ( web_dir , ' /sabnzbd/ ' , web_dir_config = web_dir_config , sub_mount = True )
self . login = LoginPage ( )
self . queue = QueuePage ( ' /queue/ ' )
self . history = HistoryPage ( ' /history/ ' )
self . status = Status ( ' /status/ ' )
self . config = ConfigPage ( ' /config/ ' )
self . nzb = NzoPage ( ' /nzb/ ' )
self . wizard = sabnzbd . wizard . Wizard ( ' /wizard/ ' )
@cherrypy . expose
def index ( self , * * kwargs ) :
@ -337,7 +320,7 @@ class MainPage(object):
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
if sabnzbd . OLD_QUEUE and not cfg . warned_old_queue ( ) :
cfg . warned_old_queue . set ( True )
@ -351,7 +334,7 @@ class MainPage(object):
config . save_config ( )
if kwargs . get ( ' skip_wizard ' ) or config . get_servers ( ) :
info = build_header ( self . __web_dir )
info = build_header ( )
info [ ' script_list ' ] = list_scripts ( default = True )
info [ ' script ' ] = ' Default '
@ -381,7 +364,7 @@ class MainPage(object):
info [ ' warning ' ] = T ( ' No PAR2 program found, repairs not possible<br /> ' )
# For Glitter we pre-load the JSON output
if ' Glitter ' in self . __web_dir :
if ' Glitter ' in sabnzbd . WEB_DIR :
# Queue
queue = build_queue ( limit = cfg . queue_limit ( ) , output = ' json ' ) [ 0 ]
queue [ ' categories ' ] = info . pop ( ' cat_list ' )
@ -403,20 +386,13 @@ class MainPage(object):
info [ ' preload_queue ' ] = ' false '
info [ ' preload_history ' ] = ' false '
template = Template ( file = os . path . join ( self . __web_dir , ' main.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR , ' main.tmpl ' ) ,
filter = FILTER , searchList = [ info ] , compilerSettings = DIRECTIVES )
return template . respond ( )
else :
# Redirect to the setup wizard
raise cherrypy . HTTPRedirect ( ' /sabnzbd/wizard/ ' )
#@cherrypy.expose
# def reset_lang(self, **kwargs):
# msg = check_session(kwargs)
# if msg: return msg
# set_language(cfg.language())
# raise dcRaiser(self.__root, kwargs)
def add_handler ( self , kwargs ) :
if not check_access ( ) :
return Protected ( )
@ -582,14 +558,10 @@ class MainPage(object):
##############################################################################
class LoginPage ( object ) :
def __init__ ( self , web_dir , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
# Base output var
info = build_header ( self . __web_dir )
info = build_header ( sabnzbd . WEB_DIR_CONFIG )
info [ ' error ' ] = ' '
# Logout?
@ -598,8 +570,8 @@ class LoginPage(object):
raise dcRaiser ( ' . ' , kwargs )
# Check if there's even a username/password set
#if check_login() :
# raise dcRaiser('../', kwargs )
if check_login ( ) :
raise cherrypy . HTTPRedirect ( cherrypy . request . script_name + ' / ' )
# Check login info
if kwargs . get ( ' username ' ) == cfg . username ( ) and kwargs . get ( ' password ' ) == cfg . password ( ) :
@ -611,7 +583,7 @@ class LoginPage(object):
info [ ' error ' ] = T ( ' Authentication failed, check username/password. ' )
# Show login
template = Template ( file = os . path . join ( self . __web_dir , ' login ' , ' main.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' login ' , ' main.tmpl ' ) ,
filter = FILTER , searchList = [ info ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -619,9 +591,8 @@ class LoginPage(object):
##############################################################################
class NzoPage ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
self . __cached_selection = { } # None
@cherrypy . expose
@ -635,7 +606,7 @@ class NzoPage(object):
if not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
nzo_id = None
for a in args :
@ -645,7 +616,7 @@ class NzoPage(object):
nzo = NzbQueue . do . get_nzo ( nzo_id )
if nzo_id and nzo :
info , pnfo_list , bytespersec , q_size , bytes_left_previous_page = build_queue_header ( self . __web_dir )
info , pnfo_list , bytespersec , q_size , bytes_left_previous_page = build_queue_header ( )
# /SABnzbd_nzo_xxxxx/bulk_operation
if ' bulk_operation ' in args :
@ -669,7 +640,7 @@ class NzoPage(object):
info = self . nzo_details ( info , pnfo_list , nzo_id )
info = self . nzo_files ( info , pnfo_list , nzo_id )
template = Template ( file = os . path . join ( self . __web_dir , ' nzo.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR , ' nzo.tmpl ' ) ,
filter = FILTER , searchList = [ info ] , compilerSettings = DIRECTIVES )
return template . respond ( )
else :
@ -814,24 +785,22 @@ class NzoPage(object):
##############################################################################
class QueuePage ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
if not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
start = int_conv ( kwargs . get ( ' start ' ) )
limit = int_conv ( kwargs . get ( ' limit ' ) )
search = kwargs . get ( ' search ' )
info , _pnfo_list , _bytespersec = build_queue ( self . __web_dir , self . __root , self . __web_dir ,
start = start , limit = limit , trans = True , search = search )
info , _pnfo_list , _bytespersec = build_queue ( start = start , limit = limit , trans = True , search = search )
template = Template ( file = os . path . join ( self . __web_dir , ' queue.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR , ' queue.tmpl ' ) ,
filter = FILTER , searchList = [ info ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -1030,9 +999,8 @@ class QueuePage(object):
##############################################################################
class HistoryPage ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
self . __verbose = False
self . __verbose_list = [ ]
self . __failed_only = False
@ -1042,7 +1010,7 @@ class HistoryPage(object):
if not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
start = int_conv ( kwargs . get ( ' start ' ) )
limit = int_conv ( kwargs . get ( ' limit ' ) )
@ -1051,7 +1019,7 @@ class HistoryPage(object):
if failed_only is None :
failed_only = self . __failed_only
history = build_header ( self . __web_dir )
history = build_header ( )
history [ ' isverbose ' ] = self . __verbose
history [ ' failed_only ' ] = failed_only
@ -1080,7 +1048,7 @@ class HistoryPage(object):
history [ ' finish ' ] = history [ ' fetched ' ]
history [ ' time_format ' ] = time_format
template = Template ( file = os . path . join ( self . __web_dir , ' history.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR , ' history.tmpl ' ) ,
filter = FILTER , searchList = [ history ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -1230,28 +1198,27 @@ class HistoryPage(object):
##############################################################################
class ConfigPage ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
self . folders = ConfigFolders ( web_dir , root + ' folders/ ' )
self . notify = ConfigNotify ( web_dir , root + ' notify/ ' )
self . general = ConfigGeneral ( web_dir , root + ' general/ ' )
self . rss = ConfigRss ( web_dir , root + ' rss/ ' )
self . scheduling = ConfigScheduling ( web_dir , root + ' scheduling/ ' )
self . server = ConfigServer ( web_dir , root + ' server/ ' )
self . switches = ConfigSwitches ( web_dir , root + ' switches/ ' )
self . categories = ConfigCats ( web_dir , root + ' categories/ ' )
self . sorting = ConfigSorting ( web_dir , root + ' sorting/ ' )
self . special = ConfigSpecial ( web_dir , root + ' special/ ' )
self . folders = ConfigFolders ( ' /folders/ ' )
self . notify = ConfigNotify ( ' /notify/ ' )
self . general = ConfigGeneral ( ' /general/ ' )
self . rss = ConfigRss ( ' /rss/ ' )
self . scheduling = ConfigScheduling ( ' /scheduling/ ' )
self . server = ConfigServer ( ' /server/ ' )
self . switches = ConfigSwitches ( ' /switches/ ' )
self . categories = ConfigCats ( ' /categories/ ' )
self . sorting = ConfigSorting ( ' /sorting/ ' )
self . special = ConfigSpecial ( ' /special/ ' )
@cherrypy . expose
def index ( self , * * kwargs ) :
if not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
conf = build_header ( self . __web_dir )
raise NeedLogin ( )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
conf [ ' configfn ' ] = config . get_filename ( )
conf [ ' cmdline ' ] = sabnzbd . CMDLINE
conf [ ' build ' ] = sabnzbd . version . __baseline__ [ : 7 ]
@ -1273,7 +1240,7 @@ class ConfigPage(object):
conf [ ' folders ' ] = sabnzbd . nzbqueue . scan_jobs ( all = False , action = False )
template = Template ( file = os . path . join ( self . __web_dir , ' config.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -1352,18 +1319,17 @@ LIST_DIRPAGE = (
class ConfigFolders ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
for kw in LIST_DIRPAGE :
conf [ kw ] = config . get_config ( ' misc ' , kw ) ( )
@ -1371,7 +1337,7 @@ class ConfigFolders(object):
# Temporary fix, problem with build_header
conf [ ' restart_req ' ] = sabnzbd . RESTART_REQ
template = Template ( file = os . path . join ( self . __web_dir , ' config_folders.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_folders.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -1424,18 +1390,17 @@ SWITCH_LIST = \
class ConfigSwitches ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
conf [ ' have_ssl_context ' ] = sabnzbd . HAVE_SSL_CONTEXT
conf [ ' have_multicore ' ] = sabnzbd . WIN32 or sabnzbd . DARWIN_INTEL
@ -1449,7 +1414,7 @@ class ConfigSwitches(object):
conf [ ' script_list ' ] = list_scripts ( ) or [ ' None ' ]
template = Template ( file = os . path . join ( self . __web_dir , ' config_switches.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_switches.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -1501,18 +1466,17 @@ SPECIAL_LIST_LIST = \
class ConfigSpecial ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
conf [ ' nt ' ] = sabnzbd . WIN32
@ -1520,7 +1484,7 @@ class ConfigSpecial(object):
conf [ ' entries ' ] = [ ( kw , config . get_config ( ' misc ' , kw ) ( ) , config . get_config ( ' misc ' , kw ) . default ( ) ) for kw in SPECIAL_VALUE_LIST ]
conf [ ' entries ' ] . extend ( [ ( kw , config . get_config ( ' misc ' , kw ) . get_string ( ) , ' ' ) for kw in SPECIAL_LIST_LIST ] )
template = Template ( file = os . path . join ( self . __web_dir , ' config_special.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_special.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -1552,9 +1516,8 @@ GENERAL_LIST = (
class ConfigGeneral ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
@ -1583,9 +1546,9 @@ class ConfigGeneral(object):
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
conf [ ' configfn ' ] = config . get_filename ( )
@ -1634,7 +1597,7 @@ class ConfigGeneral(object):
conf [ ' my_lcldata ' ] = cfg . admin_dir . get_path ( )
conf [ ' caller_url ' ] = cherrypy . request . base + ' /sabnzbd/ '
template = Template ( file = os . path . join ( self . __web_dir , ' config_general.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_general.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -1733,18 +1696,17 @@ def change_web_dir(web_dir):
##############################################################################
class ConfigServer ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
new = [ ]
servers = config . get_servers ( )
@ -1758,7 +1720,7 @@ class ConfigServer(object):
conf [ ' cats ' ] = list_cats ( default = True )
conf [ ' have_ssl_context ' ] = sabnzbd . HAVE_SSL_CONTEXT
template = Template ( file = os . path . join ( self . __web_dir , ' config_server.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_server.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -1892,9 +1854,8 @@ def handle_server_test(kwargs, root):
##############################################################################
class ConfigRss ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
self . __refresh_readout = None # Set to URL when new readout is needed
self . __refresh_download = False # True when feed needs to be read
self . __refresh_force = False # True if forced download of all matches is required
@ -1908,9 +1869,9 @@ class ConfigRss(object):
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
conf [ ' script_list ' ] = list_scripts ( default = True )
pick_script = conf [ ' script_list ' ] != [ ]
@ -1973,7 +1934,7 @@ class ConfigRss(object):
unum + = 1
conf [ ' feed ' ] = txt + str ( unum )
template = Template ( file = os . path . join ( self . __web_dir , ' config_rss.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_rss.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -2245,9 +2206,8 @@ _SCHED_ACTIONS = ('resume', 'pause', 'pause_all', 'shutdown', 'restart', 'speedl
class ConfigScheduling ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
@ -2266,9 +2226,9 @@ class ConfigScheduling(object):
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
actions = [ ]
actions . extend ( _SCHED_ACTIONS )
@ -2332,7 +2292,7 @@ class ConfigScheduling(object):
conf [ ' actions ' ] = actions
conf [ ' actions_lng ' ] = actions_lng
template = Template ( file = os . path . join ( self . __web_dir , ' config_scheduling.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_scheduling.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -2402,18 +2362,17 @@ class ConfigScheduling(object):
##############################################################################
class ConfigCats ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
conf [ ' script_list ' ] = list_scripts ( default = True )
conf [ ' defdir ' ] = cfg . complete_dir . get_path ( )
@ -2431,7 +2390,7 @@ class ConfigCats(object):
slotinfo . insert ( 1 , empty )
conf [ ' slotinfo ' ] = slotinfo
template = Template ( file = os . path . join ( self . __web_dir , ' config_cat.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_cat.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -2478,25 +2437,24 @@ SORT_LIST = (
class ConfigSorting ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
conf [ ' complete_dir ' ] = cfg . complete_dir . get_path ( )
for kw in SORT_LIST :
conf [ kw ] = config . get_config ( ' misc ' , kw ) ( )
conf [ ' cat_list ' ] = list_cats ( False )
template = Template ( file = os . path . join ( self . __web_dir , ' config_sorting.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_sorting.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -2540,20 +2498,19 @@ LOG_HASH_RE = re.compile(r"([a-fA-F\d]{25})", re.I)
class Status ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
@cherrypy . expose
def index ( self , * * kwargs ) :
if not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
header = build_status ( web_dir = self . __web_dir , skip_dashboard = kwargs . get ( ' skip_dashboard ' ) )
header = build_status ( skip_dashboard = kwargs . get ( ' skip_dashboard ' ) )
template = Template ( file = os . path . join ( self . __web_dir , ' status.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR , ' status.tmpl ' ) ,
filter = FILTER , searchList = [ header ] , compilerSettings = DIRECTIVES )
return template . respond ( )
@ -2712,8 +2669,13 @@ def Protected():
cherrypy . response . status = 403
return ' Access denied '
def NeedLogin ( url , kwargs ) :
raise dcRaiser ( url + ' login/ ' , kwargs )
def NeedLogin ( ) :
# Is it / or /sabnzbd/?
if cherrypy . request . script_name :
url = ' /sabnzbd/login/ '
else :
url = ' /login/ '
raise cherrypy . HTTPRedirect ( url )
def badParameterResponse ( msg , ajax = None ) :
""" Return a html page with error message and a ' back ' button """
@ -2867,9 +2829,8 @@ LIST_NSCRIPT = ('nscript_enable', 'nscript_script', 'nscript_parameters',
class ConfigNotify ( object ) :
def __init__ ( self , web_dir , root ) :
def __init__ ( self , root ) :
self . __root = root
self . __web_dir = web_dir
self . __lastmail = None
@cherrypy . expose
@ -2877,9 +2838,9 @@ class ConfigNotify(object):
if cfg . configlock ( ) or not check_access ( ) :
return Protected ( )
if not check_login ( ) :
raise NeedLogin ( self . __root , kwargs )
raise NeedLogin ( )
conf = build_header ( self . __web_dir )
conf = build_header ( sabnzbd . WEB_DIR_CONFIG )
conf [ ' my_home ' ] = sabnzbd . DIR_HOME
conf [ ' lastmail ' ] = self . __lastmail
@ -2912,7 +2873,7 @@ class ConfigNotify(object):
conf [ ' notify_keys ' ] = sabnzbd . constants . NOTIFY_KEYS
conf [ ' notify_texts ' ] = sabnzbd . notifier . NOTIFICATION
template = Template ( file = os . path . join ( self . __web_dir , ' config_notify.tmpl ' ) ,
template = Template ( file = os . path . join ( sabnzbd . WEB_DIR_CONFIG , ' config_notify.tmpl ' ) ,
filter = FILTER , searchList = [ conf ] , compilerSettings = DIRECTIVES )
return template . respond ( )