diff --git a/interfaces/Config/templates/config_notify.tmpl b/interfaces/Config/templates/config_notify.tmpl index 2153ccd..50f392e 100644 --- a/interfaces/Config/templates/config_notify.tmpl +++ b/interfaces/Config/templates/config_notify.tmpl @@ -26,7 +26,7 @@
-
+
@@ -46,9 +46,9 @@
@@ -238,12 +238,12 @@ $T($notify_types[$type]).replace('/', ' / ')
@@ -304,12 +304,12 @@ $T($notify_types[$type]).replace('/', ' / ')
diff --git a/interfaces/Config/templates/staticcfg/js/script.js b/interfaces/Config/templates/staticcfg/js/script.js index 3fd8d4b..43a17bf 100644 --- a/interfaces/Config/templates/staticcfg/js/script.js +++ b/interfaces/Config/templates/staticcfg/js/script.js @@ -261,7 +261,7 @@ function do_restart() { $('.main-restarting .restarting-url').text(urlTotal) // Initiate restart - $.ajax({ url: '../../config/restart?apikey=' + sabSession, + $.ajax({ url: '../../api?mode=restart&apikey=' + sabSession, complete: function() { // Keep counter of failures var loopCounter = 0; diff --git a/interfaces/Glitter/templates/static/javascripts/glitter.main.js b/interfaces/Glitter/templates/static/javascripts/glitter.main.js index 9bfdde7..50d6e7e 100644 --- a/interfaces/Glitter/templates/static/javascripts/glitter.main.js +++ b/interfaces/Glitter/templates/static/javascripts/glitter.main.js @@ -550,10 +550,12 @@ function ViewModel() { }); }) - // Clear warnings through this special URL.. + // Clear warnings self.clearWarnings = function() { - // Activate - callSpecialAPI("./status/clearwarnings/").done(self.refresh) + callAPI({ + mode: "status", + name: "clear" + }).done(self.refresh) } // Clear messages @@ -1029,7 +1031,7 @@ function ViewModel() { self.restartSAB = function() { if(!confirm(glitterTranslate.restart)) return; // Call restart function - callSpecialAPI("./config/restart/") + callAPI({ mode: "restart" }) // Set counter, we need at least 15 seconds self.isRestarting(Math.max(1, Math.floor(15 / self.refreshRate()))); @@ -1056,16 +1058,17 @@ function ViewModel() { $("#modal-options").modal("hide"); showNotification('.main-notification-box-queue-repair') // Call the API - callSpecialAPI("./config/repair/").then(function() { - hideNotification(true) + callAPI({ mode: "restart_repair" }).then(function() { + $("#modal-options").modal("hide"); }) + } // Force disconnect self.forceDisconnect = function() { // Show notification showNotification('.main-notification-box-disconnect', 3000) // Call API - callSpecialAPI("./status/disconnect/").then(function() { + callAPI({ mode: "disconnect" }).then(function() { $("#modal-options").modal("hide"); }) } diff --git a/interfaces/Plush/templates/_inc_header.tmpl b/interfaces/Plush/templates/_inc_header.tmpl index 46d0d31..d77f568 100644 --- a/interfaces/Plush/templates/_inc_header.tmpl +++ b/interfaces/Plush/templates/_inc_header.tmpl @@ -103,7 +103,7 @@ $have_warnings $T('warnings') #if $pane=="Main"# #if $new_release#⋅ $T('Plush-updateAvailable').replace(' ',' ')#end if# - This skin is no longer actively maintained! We recommend using the Glitter skin. + This skin is no longer actively maintained and some features are no longer available! We recommend using the Glitter skin. #end if#
diff --git a/interfaces/Plush/templates/_inc_modals.tmpl b/interfaces/Plush/templates/_inc_modals.tmpl index 343bc53..579b986 100644 --- a/interfaces/Plush/templates/_inc_modals.tmpl +++ b/interfaces/Plush/templates/_inc_modals.tmpl @@ -33,10 +33,8 @@
- -

$T('link-forceDisc')

-

","\n")#">$T('sch-restart') - $T('sch-shutdown')

+

Go to Config - General to restart.

+

$T('sch-shutdown')


$T('Plush-refreshRate'): diff --git a/interfaces/Plush/templates/status.tmpl b/interfaces/Plush/templates/status.tmpl index 2eb48e5..4e85bea 100644 --- a/interfaces/Plush/templates/status.tmpl +++ b/interfaces/Plush/templates/status.tmpl @@ -5,14 +5,12 @@

- $T('clearWarnings').capitalize() $T('link-showLog') $T('logging'): - -

$T('explain-Repair')

- -
- -
-

$T('explain-Restart')

- +

Go to Config - General to restart.




@@ -88,12 +75,6 @@
- - - -
diff --git a/interfaces/wizard/index.html b/interfaces/wizard/index.html index 6b968ef..6fecbf8 100644 --- a/interfaces/wizard/index.html +++ b/interfaces/wizard/index.html @@ -27,7 +27,7 @@
diff --git a/sabnzbd/__init__.py b/sabnzbd/__init__.py index 6031364..a7a2d5f 100644 --- a/sabnzbd/__init__.py +++ b/sabnzbd/__init__.py @@ -20,7 +20,6 @@ import logging import datetime import tempfile import pickle -import ctypes import ctypes.util import gzip import time diff --git a/sabnzbd/api.py b/sabnzbd/api.py index fe88698..35c67db 100644 --- a/sabnzbd/api.py +++ b/sabnzbd/api.py @@ -1541,7 +1541,6 @@ def build_header(webdir="", output=None, trans_functions=True): header["color_scheme"] = sabnzbd.WEB_COLOR or "" header["helpuri"] = "https://sabnzbd.org/wiki/" - header["restart_req"] = sabnzbd.RESTART_REQ header["pid"] = os.getpid() header["active_lang"] = cfg.language() header["rtl"] = is_rtl(header["active_lang"]) diff --git a/sabnzbd/cfg.py b/sabnzbd/cfg.py index 099f3df..cc54c57 100644 --- a/sabnzbd/cfg.py +++ b/sabnzbd/cfg.py @@ -46,7 +46,6 @@ from sabnzbd.constants import ( DEF_SCANRATE, DEF_COMPLETE_DIR, DEF_FOLDER_MAX, - DEF_FILE_MAX, ) ############################################################################## diff --git a/sabnzbd/constants.py b/sabnzbd/constants.py index 0eb2c80..ac54233 100644 --- a/sabnzbd/constants.py +++ b/sabnzbd/constants.py @@ -75,7 +75,6 @@ DEF_INTERFACES = "interfaces" DEF_EMAIL_TMPL = "email" DEF_STDCONFIG = "Config" DEF_STDINTF = "Glitter" -DEF_SKIN_COLORS = {"Glitter": "Auto", "plush": "gold"} DEF_MAIN_TMPL = os.path.normpath("templates/main.tmpl") DEF_INI_FILE = "sabnzbd.ini" DEF_HOST = "127.0.0.1" diff --git a/sabnzbd/downloader.py b/sabnzbd/downloader.py index c7f5176..c89981a 100644 --- a/sabnzbd/downloader.py +++ b/sabnzbd/downloader.py @@ -401,6 +401,7 @@ class Downloader(Thread): @NzbQueueLocker def disconnect(self): + logging.info("Forcing disconnect") self.force_disconnect = True def limit_speed(self, value: Union[str, int]): diff --git a/sabnzbd/emailer.py b/sabnzbd/emailer.py index aff17c7..f5cb409 100644 --- a/sabnzbd/emailer.py +++ b/sabnzbd/emailer.py @@ -27,7 +27,6 @@ import glob from Cheetah.Template import Template from email.message import EmailMessage -from email import policy from sabnzbd.constants import * import sabnzbd diff --git a/sabnzbd/interface.py b/sabnzbd/interface.py index 42d8983..61a6987 100644 --- a/sabnzbd/interface.py +++ b/sabnzbd/interface.py @@ -30,8 +30,6 @@ import hashlib import socket import ssl import functools -import ipaddress -from threading import Thread from random import randint from xml.sax.saxutils import escape from Cheetah.Template import Template @@ -53,9 +51,17 @@ from sabnzbd.misc import ( is_lan_addr, is_loopback_addr, ip_in_subnet, - strip_ipv4_mapped_notation, ) -from sabnzbd.filesystem import real_path, long_path, globber, globber_full, remove_all, clip_path, same_file +from sabnzbd.filesystem import ( + real_path, + long_path, + globber, + globber_full, + remove_all, + clip_path, + same_file, + setname_from_path, +) from sabnzbd.encoding import xml_name, utob import sabnzbd.config as config import sabnzbd.cfg as cfg @@ -66,7 +72,7 @@ from sabnzbd.utils.diskspeed import diskspeedmeasure from sabnzbd.utils.getperformance import getpystone from sabnzbd.utils.internetspeed import internetspeed import sabnzbd.utils.ssdp -from sabnzbd.constants import MEBI, DEF_SKIN_COLORS, DEF_STDCONFIG, DEF_MAIN_TMPL, DEFAULT_PRIORITY, CHEETAH_DIRECTIVES +from sabnzbd.constants import MEBI, DEF_STDCONFIG, DEFAULT_PRIORITY, CHEETAH_DIRECTIVES from sabnzbd.lang import list_languages from sabnzbd.api import ( list_scripts, @@ -78,7 +84,6 @@ from sabnzbd.api import ( retry_job, build_header, build_history, - del_hist_job, Ttemplate, build_queue_header, ) @@ -396,10 +401,6 @@ def Raiser(root: str = "", **kwargs): return cherrypy.HTTPRedirect(root) -def queueRaiser(root, kwargs): - return Raiser(root, start=kwargs.get("start"), limit=kwargs.get("limit"), search=kwargs.get("search")) - - def rssRaiser(root, kwargs): return Raiser(root, feed=kwargs.get("feed")) @@ -586,12 +587,6 @@ class Wizard: ) return template.respond() - @secured_expose - def exit(self, **kwargs): - """Stop SABnzbd""" - sabnzbd.shutdown_program() - return T("SABnzbd shutdown finished") - def get_access_info(): """Build up a list of url's that sabnzbd can be accessed from""" @@ -925,7 +920,7 @@ class HistoryPage: @secured_expose(check_api_key=True) def retry_pp(self, **kwargs): retry_job(kwargs.get("job"), kwargs.get("nzbfile"), kwargs.get("password")) - raise queueRaiser(self.__root, kwargs) + raise Raiser(self.__root) ############################################################################## @@ -965,25 +960,6 @@ class ConfigPage: ) return template.respond() - @secured_expose(check_api_key=True) - def restart(self, **kwargs): - logging.info("Restart requested by interface") - # Do the shutdown async to still send goodbye to browser - Thread(target=sabnzbd.trigger_restart, kwargs={"timeout": 1}).start() - return T( - ' 
SABnzbd shutdown finished.
Wait for about 5 second and then click the button below.

Refresh
' - ) - - @secured_expose(check_api_key=True) - def repair(self, **kwargs): - logging.info("Queue repair requested by interface") - sabnzbd.request_repair() - # Do the shutdown async to still send goodbye to browser - Thread(target=sabnzbd.trigger_restart, kwargs={"timeout": 1}).start() - return T( - ' 
SABnzbd shutdown finished.
Wait for about 5 second and then click the button below.

Refresh
' - ) - ############################################################################## LIST_DIRPAGE = ( @@ -1290,51 +1266,24 @@ class ConfigGeneral: @secured_expose(check_configlock=True) def index(self, **kwargs): - def ListColors(web_dir): - lst = [] - web_dir = os.path.join(sabnzbd.DIR_INTERFACES, web_dir) - dd = os.path.abspath(web_dir + "/templates/static/stylesheets/colorschemes") - if (not dd) or (not os.access(dd, os.R_OK)): - return lst - for color in globber(dd): - col = color.replace(".css", "") - lst.append(col) - return lst - - def add_color(skin_dir, color): - if skin_dir: - if not color: - try: - color = DEF_SKIN_COLORS[skin_dir.lower()] - except KeyError: - return skin_dir - return "%s - %s" % (skin_dir, color) - else: - return "" conf = build_header(sabnzbd.WEB_DIR_CONFIG) conf["configfn"] = config.get_filename() conf["certificate_validation"] = sabnzbd.CERTIFICATE_VALIDATION - wlist = [] - interfaces = globber_full(sabnzbd.DIR_INTERFACES) - for k in interfaces: - if k.endswith(DEF_STDCONFIG): - interfaces.remove(k) - continue - - for web in interfaces: - rweb = os.path.basename(web) - if os.access(os.path.join(web, DEF_MAIN_TMPL), os.R_OK): - cols = ListColors(rweb) - if cols: - for col in cols: - wlist.append(add_color(rweb, col)) - else: - wlist.append(rweb) - conf["web_list"] = wlist - conf["web_dir"] = add_color(cfg.web_dir(), cfg.web_color()) + web_list = [] + for interface_dir in globber_full(sabnzbd.DIR_INTERFACES): + # Ignore the config + if not interface_dir.endswith(DEF_STDCONFIG): + # Check the available templates + for colorscheme in globber( + os.path.join(interface_dir, "templates", "static", "stylesheets", "colorschemes") + ): + web_list.append("%s - %s" % (setname_from_path(interface_dir), setname_from_path(colorscheme))) + + conf["web_list"] = web_list + conf["web_dir"] = "%s - %s" % (cfg.web_dir(), cfg.web_color()) conf["password"] = cfg.password.get_stars() conf["language"] = cfg.language() @@ -1392,14 +1341,7 @@ class ConfigGeneral: def change_web_dir(web_dir): - try: - web_dir, web_color = web_dir.split(" - ") - except: - try: - web_color = DEF_SKIN_COLORS[web_dir.lower()] - except: - web_color = "" - + web_dir, web_color = web_dir.split(" - ") web_dir_path = real_path(sabnzbd.DIR_INTERFACES, web_dir) if not os.path.exists(web_dir_path): @@ -2264,11 +2206,6 @@ class Status: return template.respond() @secured_expose(check_api_key=True) - def disconnect(self, **kwargs): - sabnzbd.Downloader.disconnect() - raise Raiser(self.__root) - - @secured_expose(check_api_key=True) def showlog(self, **kwargs): try: sabnzbd.LOGHANDLER.flush() @@ -2309,11 +2246,6 @@ class Status: return log_data @secured_expose(check_api_key=True) - def clearwarnings(self, **kwargs): - sabnzbd.GUIHANDLER.clear() - raise Raiser(self.__root) - - @secured_expose(check_api_key=True) def change_loglevel(self, **kwargs): cfg.log_level.set(kwargs.get("loglevel")) config.save_config() @@ -2524,7 +2456,8 @@ def GetRssLog(feed): ############################################################################## -LIST_EMAIL = ( +NOTIFY_OPTIONS = {} +NOTIFY_OPTIONS["misc"] = ( "email_endjob", "email_cats", "email_full", @@ -2535,7 +2468,7 @@ LIST_EMAIL = ( "email_pwd", "email_rss", ) -LIST_NCENTER = ( +NOTIFY_OPTIONS["ncenter"] = ( "ncenter_enable", "ncenter_cats", "ncenter_prio_startup", @@ -2552,7 +2485,7 @@ LIST_NCENTER = ( "ncenter_prio_other", "ncenter_prio_new_login", ) -LIST_ACENTER = ( +NOTIFY_OPTIONS["acenter"] = ( "acenter_enable", "acenter_cats", "acenter_prio_startup", @@ -2568,7 +2501,7 @@ LIST_ACENTER = ( "acenter_prio_other", "acenter_prio_new_login", ) -LIST_NTFOSD = ( +NOTIFY_OPTIONS["ntfosd"] = ( "ntfosd_enable", "ntfosd_cats", "ntfosd_prio_startup", @@ -2584,7 +2517,7 @@ LIST_NTFOSD = ( "ntfosd_prio_other", "ntfosd_prio_new_login", ) -LIST_PROWL = ( +NOTIFY_OPTIONS["prowl"] = ( "prowl_enable", "prowl_cats", "prowl_apikey", @@ -2601,7 +2534,7 @@ LIST_PROWL = ( "prowl_prio_other", "prowl_prio_new_login", ) -LIST_PUSHOVER = ( +NOTIFY_OPTIONS["pushover"] = ( "pushover_enable", "pushover_cats", "pushover_token", @@ -2622,7 +2555,7 @@ LIST_PUSHOVER = ( "pushover_emergency_retry", "pushover_emergency_expire", ) -LIST_PUSHBULLET = ( +NOTIFY_OPTIONS["pushbullet"] = ( "pushbullet_enable", "pushbullet_cats", "pushbullet_apikey", @@ -2640,7 +2573,7 @@ LIST_PUSHBULLET = ( "pushbullet_prio_other", "pushbullet_prio_new_login", ) -LIST_NSCRIPT = ( +NOTIFY_OPTIONS["nscript"] = ( "nscript_enable", "nscript_cats", "nscript_script", @@ -2663,35 +2596,20 @@ LIST_NSCRIPT = ( class ConfigNotify: def __init__(self, root): self.__root = root - self.__lastmail = None @secured_expose(check_configlock=True) def index(self, **kwargs): conf = build_header(sabnzbd.WEB_DIR_CONFIG) - + conf["notify_types"] = sabnzbd.notifier.NOTIFICATION conf["categories"] = list_cats(False) - conf["lastmail"] = self.__lastmail conf["have_ntfosd"] = sabnzbd.notifier.have_ntfosd() conf["have_ncenter"] = sabnzbd.DARWIN and sabnzbd.FOUNDATION conf["scripts"] = list_scripts(default=False, none=True) - for kw in LIST_EMAIL: - conf[kw] = config.get_config("misc", kw).get_string() - for kw in LIST_PROWL: - conf[kw] = config.get_config("prowl", kw)() - for kw in LIST_PUSHOVER: - conf[kw] = config.get_config("pushover", kw)() - for kw in LIST_PUSHBULLET: - conf[kw] = config.get_config("pushbullet", kw)() - for kw in LIST_NCENTER: - conf[kw] = config.get_config("ncenter", kw)() - for kw in LIST_ACENTER: - conf[kw] = config.get_config("acenter", kw)() - for kw in LIST_NTFOSD: - conf[kw] = config.get_config("ntfosd", kw)() - for kw in LIST_NSCRIPT: - conf[kw] = config.get_config("nscript", kw)() - conf["notify_types"] = sabnzbd.notifier.NOTIFICATION + for section in NOTIFY_OPTIONS: + for option in NOTIFY_OPTIONS[section]: + # Use get_string to make sure lists are displayed correctly + conf[option] = config.get_config(section, option).get_string() template = Template( file=os.path.join(sabnzbd.WEB_DIR_CONFIG, "config_notify.tmpl"), @@ -2701,45 +2619,12 @@ class ConfigNotify: return template.respond() @secured_expose(check_api_key=True, check_configlock=True) - def saveEmail(self, **kwargs): - ajax = kwargs.get("ajax") - - for kw in LIST_EMAIL: - msg = config.get_config("misc", kw).set(kwargs.get(kw)) - if msg: - return badParameterResponse(T("Incorrect value for %s: %s") % (kw, msg), ajax) - for kw in LIST_NCENTER: - msg = config.get_config("ncenter", kw).set(kwargs.get(kw)) - if msg: - return badParameterResponse(T("Incorrect value for %s: %s") % (kw, msg), ajax) - for kw in LIST_ACENTER: - msg = config.get_config("acenter", kw).set(kwargs.get(kw)) - if msg: - return badParameterResponse(T("Incorrect value for %s: %s") % (kw, msg), ajax) - for kw in LIST_NTFOSD: - msg = config.get_config("ntfosd", kw).set(kwargs.get(kw)) - if msg: - return badParameterResponse(T("Incorrect value for %s: %s") % (kw, msg), ajax) - for kw in LIST_PROWL: - msg = config.get_config("prowl", kw).set(kwargs.get(kw)) - if msg: - return badParameterResponse(T("Incorrect value for %s: %s") % (kw, msg), ajax) - for kw in LIST_PUSHOVER: - msg = config.get_config("pushover", kw).set(kwargs.get(kw)) - if msg: - return badParameterResponse(T("Incorrect value for %s: %s") % (kw, msg), ajax) - for kw in LIST_PUSHBULLET: - msg = config.get_config("pushbullet", kw).set(kwargs.get(kw, 0)) - if msg: - return badParameterResponse(T("Incorrect value for %s: %s") % (kw, msg), ajax) - for kw in LIST_NSCRIPT: - msg = config.get_config("nscript", kw).set(kwargs.get(kw, 0)) - if msg: - return badParameterResponse(T("Incorrect value for %s: %s") % (kw, msg), ajax) - + def saveNotify(self, **kwargs): + for section in NOTIFY_OPTIONS: + for option in NOTIFY_OPTIONS[section]: + config.get_config(section, option).set(kwargs.get(option)) config.save_config() - self.__lastmail = None - if ajax: + if kwargs.get("ajax"): return sabnzbd.api.report("json") else: raise Raiser(self.__root) diff --git a/sabnzbd/osxmenu.py b/sabnzbd/osxmenu.py index 31f44be..aeb93d9 100644 --- a/sabnzbd/osxmenu.py +++ b/sabnzbd/osxmenu.py @@ -37,7 +37,6 @@ from sabnzbd.filesystem import diskspace from sabnzbd.misc import to_units from sabnzbd.constants import VALID_ARCHIVES, VALID_NZB_FILES, MEBI, Status from sabnzbd.panic import launch_a_browser -import sabnzbd.notifier as notifier from sabnzbd.api import fast_queue import sabnzbd.config as config diff --git a/sabnzbd/zconfig.py b/sabnzbd/zconfig.py index 2c34ffe..67a992b 100644 --- a/sabnzbd/zconfig.py +++ b/sabnzbd/zconfig.py @@ -19,7 +19,6 @@ sabnzbd.zconfig - bonjour/zeroconfig support """ -import os import logging import socket