Browse Source

Additional cleanup of interface.py functions

pull/1904/head
Safihre 4 years ago
parent
commit
87da19caa3
  1. 32
      interfaces/Config/templates/config_notify.tmpl
  2. 2
      interfaces/Config/templates/staticcfg/js/script.js
  3. 17
      interfaces/Glitter/templates/static/javascripts/glitter.main.js
  4. 2
      interfaces/Plush/templates/_inc_header.tmpl
  5. 6
      interfaces/Plush/templates/_inc_modals.tmpl
  6. 21
      interfaces/Plush/templates/status.tmpl
  7. 2
      interfaces/wizard/index.html
  8. 1
      sabnzbd/__init__.py
  9. 1
      sabnzbd/api.py
  10. 1
      sabnzbd/cfg.py
  11. 1
      sabnzbd/constants.py
  12. 1
      sabnzbd/downloader.py
  13. 1
      sabnzbd/emailer.py
  14. 203
      sabnzbd/interface.py
  15. 1
      sabnzbd/osxmenu.py
  16. 1
      sabnzbd/zconfig.py

32
interfaces/Config/templates/config_notify.tmpl

@ -26,7 +26,7 @@
<!--#end def#--> <!--#end def#-->
<div class="colmask"> <div class="colmask">
<form action="saveEmail" method="post" name="fullform" class="fullform" autocomplete="off"> <form action="saveNotify" method="post" name="fullform" class="fullform" autocomplete="off">
<input type="hidden" id="apikey" name="apikey" value="$apikey" /> <input type="hidden" id="apikey" name="apikey" value="$apikey" />
<input type="hidden" id="ajax" name="ajax" value="1" /> <input type="hidden" id="ajax" name="ajax" value="1" />
<div class="section" id="email"> <div class="section" id="email">
@ -46,9 +46,9 @@
<div class="field-pair"> <div class="field-pair">
<label class="config" for="email_endjob">$T('opt-email_endjob')</label> <label class="config" for="email_endjob">$T('opt-email_endjob')</label>
<select name="email_endjob" id="email_endjob"> <select name="email_endjob" id="email_endjob">
<option value="0" <!--#if int($email_endjob) == 0 then 'selected="selected"' else ""#--> >$T('email-never')</option> <option value="0" <!--#if int($email_endjob) == "0" then 'selected="selected"' else ""#--> >$T('email-never')</option>
<option value="1" <!--#if int($email_endjob) == 1 then 'selected="selected"' else ""#--> >$T('email-always')</option> <option value="1" <!--#if int($email_endjob) == "1" then 'selected="selected"' else ""#--> >$T('email-always')</option>
<option value="2" <!--#if int($email_endjob) == 2 then 'selected="selected"' else ""#--> >$T('email-errorOnly')</option> <option value="2" <!--#if int($email_endjob) == "2" then 'selected="selected"' else ""#--> >$T('email-errorOnly')</option>
</select> </select>
</div> </div>
<div class="field-pair"> <div class="field-pair">
@ -238,12 +238,12 @@
$T($notify_types[$type]).replace('/', ' / ') $T($notify_types[$type]).replace('/', ' / ')
</label> </label>
<select name="${section_label}_prio_$type" id="${section_label}_prio_$type"> <select name="${section_label}_prio_$type" id="${section_label}_prio_$type">
<option value="-3" <!--#if $getVar($section_label + '_prio_' + $type) == -3 then 'selected="selected"' else ""#--> >$T('prowl-off')</option> <option value="-3" <!--#if $getVar($section_label + '_prio_' + $type) == "-3" then 'selected="selected"' else ""#--> >$T('prowl-off')</option>
<option value="-2" <!--#if $getVar($section_label + '_prio_' + $type) == -2 then 'selected="selected"' else ""#--> >$T('prowl-very-low')</option> <option value="-2" <!--#if $getVar($section_label + '_prio_' + $type) == "-2" then 'selected="selected"' else ""#--> >$T('prowl-very-low')</option>
<option value="-1" <!--#if $getVar($section_label + '_prio_' + $type) == -1 then 'selected="selected"' else ""#--> >$T('prowl-moderate')</option> <option value="-1" <!--#if $getVar($section_label + '_prio_' + $type) == "-1" then 'selected="selected"' else ""#--> >$T('prowl-moderate')</option>
<option value="0" <!--#if $getVar($section_label + '_prio_' + $type) == 0 then 'selected="selected"' else ""#--> >$T('prowl-normal')</option> <option value="0" <!--#if $getVar($section_label + '_prio_' + $type) == "0" then 'selected="selected"' else ""#--> >$T('prowl-normal')</option>
<option value="1" <!--#if $getVar($section_label + '_prio_' + $type) == 1 then 'selected="selected"' else ""#--> >$T('prowl-high')</option> <option value="1" <!--#if $getVar($section_label + '_prio_' + $type) == "1" then 'selected="selected"' else ""#--> >$T('prowl-high')</option>
<option value="2" <!--#if $getVar($section_label + '_prio_' + $type) == 2 then 'selected="selected"' else ""#--> >$T('prowl-emergency')</option> <option value="2" <!--#if $getVar($section_label + '_prio_' + $type) == "2" then 'selected="selected"' else ""#--> >$T('prowl-emergency')</option>
</select> </select>
</div> </div>
<!--#end for#--> <!--#end for#-->
@ -304,12 +304,12 @@
$T($notify_types[$type]).replace('/', ' / ') $T($notify_types[$type]).replace('/', ' / ')
</label> </label>
<select name="${section_label}_prio_$type" id="${section_label}_prio_$type"> <select name="${section_label}_prio_$type" id="${section_label}_prio_$type">
<option value="-3" <!--#if $getVar($section_label + '_prio_' + $type) == -3 then 'selected="selected"' else ""#--> >$T('pushover-off')</option> <option value="-3" <!--#if $getVar($section_label + '_prio_' + $type) == "-3" then 'selected="selected"' else ""#--> >$T('pushover-off')</option>
<option value="-2" <!--#if $getVar($section_label + '_prio_' + $type) == -2 then 'selected="selected"' else ""#--> >$T('prowl-very-low')</option> <option value="-2" <!--#if $getVar($section_label + '_prio_' + $type) == "-2" then 'selected="selected"' else ""#--> >$T('prowl-very-low')</option>
<option value="-1" <!--#if $getVar($section_label + '_prio_' + $type) == -1 then 'selected="selected"' else ""#--> >$T('pushover-low')</option> <option value="-1" <!--#if $getVar($section_label + '_prio_' + $type) == "-1" then 'selected="selected"' else ""#--> >$T('pushover-low')</option>
<option value="0" <!--#if $getVar($section_label + '_prio_' + $type) == 0 then 'selected="selected"' else ""#--> >$T('prowl-normal')</option> <option value="0" <!--#if $getVar($section_label + '_prio_' + $type) == "0" then 'selected="selected"' else ""#--> >$T('prowl-normal')</option>
<option value="1" <!--#if $getVar($section_label + '_prio_' + $type) == 1 then 'selected="selected"' else ""#--> >$T('pushover-high')</option> <option value="1" <!--#if $getVar($section_label + '_prio_' + $type) == "1" then 'selected="selected"' else ""#--> >$T('pushover-high')</option>
<option value="2" <!--#if $getVar($section_label + '_prio_' + $type) == 2 then 'selected="selected"' else ""#--> >$T('prowl-emergency')</option> <option value="2" <!--#if $getVar($section_label + '_prio_' + $type) == "2" then 'selected="selected"' else ""#--> >$T('prowl-emergency')</option>
</select> </select>
</div> </div>
<!--#end for#--> <!--#end for#-->

2
interfaces/Config/templates/staticcfg/js/script.js

@ -261,7 +261,7 @@ function do_restart() {
$('.main-restarting .restarting-url').text(urlTotal) $('.main-restarting .restarting-url').text(urlTotal)
// Initiate restart // Initiate restart
$.ajax({ url: '../../config/restart?apikey=' + sabSession, $.ajax({ url: '../../api?mode=restart&apikey=' + sabSession,
complete: function() { complete: function() {
// Keep counter of failures // Keep counter of failures
var loopCounter = 0; var loopCounter = 0;

17
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() { self.clearWarnings = function() {
// Activate callAPI({
callSpecialAPI("./status/clearwarnings/").done(self.refresh) mode: "status",
name: "clear"
}).done(self.refresh)
} }
// Clear messages // Clear messages
@ -1029,7 +1031,7 @@ function ViewModel() {
self.restartSAB = function() { self.restartSAB = function() {
if(!confirm(glitterTranslate.restart)) return; if(!confirm(glitterTranslate.restart)) return;
// Call restart function // Call restart function
callSpecialAPI("./config/restart/") callAPI({ mode: "restart" })
// Set counter, we need at least 15 seconds // Set counter, we need at least 15 seconds
self.isRestarting(Math.max(1, Math.floor(15 / self.refreshRate()))); self.isRestarting(Math.max(1, Math.floor(15 / self.refreshRate())));
@ -1056,16 +1058,17 @@ function ViewModel() {
$("#modal-options").modal("hide"); $("#modal-options").modal("hide");
showNotification('.main-notification-box-queue-repair') showNotification('.main-notification-box-queue-repair')
// Call the API // Call the API
callSpecialAPI("./config/repair/").then(function() { callAPI({ mode: "restart_repair" }).then(function() {
hideNotification(true) $("#modal-options").modal("hide");
}) })
} }
// Force disconnect // Force disconnect
self.forceDisconnect = function() { self.forceDisconnect = function() {
// Show notification // Show notification
showNotification('.main-notification-box-disconnect', 3000) showNotification('.main-notification-box-disconnect', 3000)
// Call API // Call API
callSpecialAPI("./status/disconnect/").then(function() { callAPI({ mode: "disconnect" }).then(function() {
$("#modal-options").modal("hide"); $("#modal-options").modal("hide");
}) })
} }

2
interfaces/Plush/templates/_inc_header.tmpl

@ -103,7 +103,7 @@
<span id="warning_box"><b><a href="${path}status/#tabs-warnings" id="last_warning"><span id="have_warnings">$have_warnings</span> $T('warnings')</a></b></span> <span id="warning_box"><b><a href="${path}status/#tabs-warnings" id="last_warning"><span id="have_warnings">$have_warnings</span> $T('warnings')</a></b></span>
#if $pane=="Main"# #if $pane=="Main"#
#if $new_release#&sdot; <a href="$new_rel_url" id="new_release" target="_blank">$T('Plush-updateAvailable').replace(' ','&nbsp;')</a>#end if# #if $new_release#&sdot; <a href="$new_rel_url" id="new_release" target="_blank">$T('Plush-updateAvailable').replace(' ','&nbsp;')</a>#end if#
This skin is no longer actively maintained! <a href="${path}config/general/#web_dir"><strong>We recommend using the Glitter skin.</strong></a> This skin is no longer actively maintained and some features are no longer available! <a href="${path}config/general/#web_dir"><strong>We recommend using the Glitter skin.</strong></a>
#end if# #end if#
</div> </div>
</div> </div>

6
interfaces/Plush/templates/_inc_modals.tmpl

@ -33,10 +33,8 @@
</div> </div>
<div id="plush_options_modal"> <div id="plush_options_modal">
<p>Go to Config - General to restart.</p>
<p><a href="status/disconnect?apikey=$apikey" class="juiButton">$T('link-forceDisc')</a></p> <p><a href="shutdown?apikey=$apikey&amp;pid=$pid" class="juiButton" id="sabnzbd_shutdown" rel="$T('shutdownOK?')">$T('sch-shutdown')</a></p>
<p><a href="config/restart?apikey=$apikey" class="juiButton" id="sabnzbd_restart" rel="#echo $T('explain-Restart').replace("<br />","\n")#">$T('sch-restart')</a>
<a href="shutdown?apikey=$apikey&amp;pid=$pid" class="juiButton" id="sabnzbd_shutdown" rel="$T('shutdownOK?')">$T('sch-shutdown')</a></p>
<br/> <br/>
$T('Plush-refreshRate'): $T('Plush-refreshRate'):

21
interfaces/Plush/templates/status.tmpl

@ -5,14 +5,12 @@
<div class="tabs"> <div class="tabs">
<ul> <ul>
<li><a href="#tabs-warnings">$T('lastWarnings')</a></li> <li><a href="#tabs-warnings">$T('lastWarnings')</a></li>
<li><a href="#tabs-connections">$T('connections').capitalize()</a></li>
<li><a href="#tabs-repair">$T('Plush-tab-repair')</a></li> <li><a href="#tabs-repair">$T('Plush-tab-repair')</a></li>
<li><a href="#tabs-dashboard">$T('dashboard-title')</a></li> <li><a href="#tabs-dashboard">$T('dashboard-title')</a></li>
</ul> </ul>
<div id="tabs-warnings"> <div id="tabs-warnings">
<p> <p>
<a href="clearwarnings?apikey=$apikey" class="juiButton">$T('clearWarnings').capitalize()</a>
<a href="showlog?apikey=$apikey" class="juiButton">$T('link-showLog')</a> <a href="showlog?apikey=$apikey" class="juiButton">$T('link-showLog')</a>
<strong>$T('logging'):</strong> <select class="xsmall" id="logging_level"> <strong>$T('logging'):</strong> <select class="xsmall" id="logging_level">
<option value="0" <!--#if $loglevel == "0" then "selected" else ""#-->>$T('log-errWarn')</option> <option value="0" <!--#if $loglevel == "0" then "selected" else ""#-->>$T('log-errWarn')</option>
@ -46,18 +44,7 @@
</div> </div>
<div id="tabs-repair"> <div id="tabs-repair">
<table> <p>Go to Config - General to restart.</p>
<tr><td>
<form action="saveGeneral" method="post">
<input type="submit" class="juiButton" onclick="this.form.action='../config/repair?apikey=$apikey'; this.form.submit(); return false;" value="$T('button-repair')"/>
</form>
</td><td style="padding-left:20px;"><p>$T('explain-Repair')</p></td></tr>
<tr><td>
<form action="saveGeneral" method="post">
<input type="submit" class="juiButton" onclick="this.form.action='../config/restart?apikey=$apikey'; this.form.submit(); return false;" value="$T('button-restart')"/>
</form>
</td><td style="padding-left:20px;"><p>$T('explain-Restart')</p></td></tr>
</table>
<!--#if $folders#--> <!--#if $folders#-->
<br/><hr/><br/> <br/><hr/><br/>
@ -88,12 +75,6 @@
<!--#end if#--> <!--#end if#-->
</div> </div>
<div id="tabs-connections">
<a href="disconnect?apikey=$apikey" class="juiButton">$T('link-forceDisc')</a>
</div>
<div id="tabs-dashboard"> <div id="tabs-dashboard">
<table class="rssTable"> <table class="rssTable">
<tr> <tr>

2
interfaces/wizard/index.html

@ -27,7 +27,7 @@
<hr /> <hr />
<div class="row"> <div class="row">
<div class="col-xs-4 text-center"> <div class="col-xs-4 text-center">
<a class="btn btn-danger" href="./exit"><span class="glyphicon glyphicon-remove"></span> $T('wizard-exit')</a> <a class="btn btn-danger" href="../shutdown/?apikey=$apikey&amp;pid=$pid"><span class="glyphicon glyphicon-remove"></span> $T('wizard-exit')</a>
</div> </div>
<div class="col-xs-4 text-center"> <div class="col-xs-4 text-center">
</div> </div>

1
sabnzbd/__init__.py

@ -20,7 +20,6 @@ import logging
import datetime import datetime
import tempfile import tempfile
import pickle import pickle
import ctypes
import ctypes.util import ctypes.util
import gzip import gzip
import time import time

1
sabnzbd/api.py

@ -1541,7 +1541,6 @@ def build_header(webdir="", output=None, trans_functions=True):
header["color_scheme"] = sabnzbd.WEB_COLOR or "" header["color_scheme"] = sabnzbd.WEB_COLOR or ""
header["helpuri"] = "https://sabnzbd.org/wiki/" header["helpuri"] = "https://sabnzbd.org/wiki/"
header["restart_req"] = sabnzbd.RESTART_REQ
header["pid"] = os.getpid() header["pid"] = os.getpid()
header["active_lang"] = cfg.language() header["active_lang"] = cfg.language()
header["rtl"] = is_rtl(header["active_lang"]) header["rtl"] = is_rtl(header["active_lang"])

1
sabnzbd/cfg.py

@ -46,7 +46,6 @@ from sabnzbd.constants import (
DEF_SCANRATE, DEF_SCANRATE,
DEF_COMPLETE_DIR, DEF_COMPLETE_DIR,
DEF_FOLDER_MAX, DEF_FOLDER_MAX,
DEF_FILE_MAX,
) )
############################################################################## ##############################################################################

1
sabnzbd/constants.py

@ -75,7 +75,6 @@ DEF_INTERFACES = "interfaces"
DEF_EMAIL_TMPL = "email" DEF_EMAIL_TMPL = "email"
DEF_STDCONFIG = "Config" DEF_STDCONFIG = "Config"
DEF_STDINTF = "Glitter" DEF_STDINTF = "Glitter"
DEF_SKIN_COLORS = {"Glitter": "Auto", "plush": "gold"}
DEF_MAIN_TMPL = os.path.normpath("templates/main.tmpl") DEF_MAIN_TMPL = os.path.normpath("templates/main.tmpl")
DEF_INI_FILE = "sabnzbd.ini" DEF_INI_FILE = "sabnzbd.ini"
DEF_HOST = "127.0.0.1" DEF_HOST = "127.0.0.1"

1
sabnzbd/downloader.py

@ -401,6 +401,7 @@ class Downloader(Thread):
@NzbQueueLocker @NzbQueueLocker
def disconnect(self): def disconnect(self):
logging.info("Forcing disconnect")
self.force_disconnect = True self.force_disconnect = True
def limit_speed(self, value: Union[str, int]): def limit_speed(self, value: Union[str, int]):

1
sabnzbd/emailer.py

@ -27,7 +27,6 @@ import glob
from Cheetah.Template import Template from Cheetah.Template import Template
from email.message import EmailMessage from email.message import EmailMessage
from email import policy
from sabnzbd.constants import * from sabnzbd.constants import *
import sabnzbd import sabnzbd

203
sabnzbd/interface.py

@ -30,8 +30,6 @@ import hashlib
import socket import socket
import ssl import ssl
import functools import functools
import ipaddress
from threading import Thread
from random import randint from random import randint
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
from Cheetah.Template import Template from Cheetah.Template import Template
@ -53,9 +51,17 @@ from sabnzbd.misc import (
is_lan_addr, is_lan_addr,
is_loopback_addr, is_loopback_addr,
ip_in_subnet, 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 from sabnzbd.encoding import xml_name, utob
import sabnzbd.config as config import sabnzbd.config as config
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
@ -66,7 +72,7 @@ from sabnzbd.utils.diskspeed import diskspeedmeasure
from sabnzbd.utils.getperformance import getpystone from sabnzbd.utils.getperformance import getpystone
from sabnzbd.utils.internetspeed import internetspeed from sabnzbd.utils.internetspeed import internetspeed
import sabnzbd.utils.ssdp 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.lang import list_languages
from sabnzbd.api import ( from sabnzbd.api import (
list_scripts, list_scripts,
@ -78,7 +84,6 @@ from sabnzbd.api import (
retry_job, retry_job,
build_header, build_header,
build_history, build_history,
del_hist_job,
Ttemplate, Ttemplate,
build_queue_header, build_queue_header,
) )
@ -396,10 +401,6 @@ def Raiser(root: str = "", **kwargs):
return cherrypy.HTTPRedirect(root) 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): def rssRaiser(root, kwargs):
return Raiser(root, feed=kwargs.get("feed")) return Raiser(root, feed=kwargs.get("feed"))
@ -586,12 +587,6 @@ class Wizard:
) )
return template.respond() return template.respond()
@secured_expose
def exit(self, **kwargs):
"""Stop SABnzbd"""
sabnzbd.shutdown_program()
return T("SABnzbd shutdown finished")
def get_access_info(): def get_access_info():
"""Build up a list of url's that sabnzbd can be accessed from""" """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) @secured_expose(check_api_key=True)
def retry_pp(self, **kwargs): def retry_pp(self, **kwargs):
retry_job(kwargs.get("job"), kwargs.get("nzbfile"), kwargs.get("password")) 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() 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(
'&nbsp<br />SABnzbd shutdown finished.<br />Wait for about 5 second and then click the button below.<br /><br /><strong><a href="..">Refresh</a></strong><br />'
)
@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(
'&nbsp<br />SABnzbd shutdown finished.<br />Wait for about 5 second and then click the button below.<br /><br /><strong><a href="..">Refresh</a></strong><br />'
)
############################################################################## ##############################################################################
LIST_DIRPAGE = ( LIST_DIRPAGE = (
@ -1290,51 +1266,24 @@ class ConfigGeneral:
@secured_expose(check_configlock=True) @secured_expose(check_configlock=True)
def index(self, **kwargs): 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 = build_header(sabnzbd.WEB_DIR_CONFIG)
conf["configfn"] = config.get_filename() conf["configfn"] = config.get_filename()
conf["certificate_validation"] = sabnzbd.CERTIFICATE_VALIDATION conf["certificate_validation"] = sabnzbd.CERTIFICATE_VALIDATION
wlist = [] web_list = []
interfaces = globber_full(sabnzbd.DIR_INTERFACES) for interface_dir in globber_full(sabnzbd.DIR_INTERFACES):
for k in interfaces: # Ignore the config
if k.endswith(DEF_STDCONFIG): if not interface_dir.endswith(DEF_STDCONFIG):
interfaces.remove(k) # Check the available templates
continue for colorscheme in globber(
os.path.join(interface_dir, "templates", "static", "stylesheets", "colorschemes")
for web in interfaces: ):
rweb = os.path.basename(web) web_list.append("%s - %s" % (setname_from_path(interface_dir), setname_from_path(colorscheme)))
if os.access(os.path.join(web, DEF_MAIN_TMPL), os.R_OK):
cols = ListColors(rweb) conf["web_list"] = web_list
if cols: conf["web_dir"] = "%s - %s" % (cfg.web_dir(), cfg.web_color())
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())
conf["password"] = cfg.password.get_stars() conf["password"] = cfg.password.get_stars()
conf["language"] = cfg.language() conf["language"] = cfg.language()
@ -1392,14 +1341,7 @@ class ConfigGeneral:
def change_web_dir(web_dir): def change_web_dir(web_dir):
try: web_dir, web_color = web_dir.split(" - ")
web_dir, web_color = web_dir.split(" - ")
except:
try:
web_color = DEF_SKIN_COLORS[web_dir.lower()]
except:
web_color = ""
web_dir_path = real_path(sabnzbd.DIR_INTERFACES, web_dir) web_dir_path = real_path(sabnzbd.DIR_INTERFACES, web_dir)
if not os.path.exists(web_dir_path): if not os.path.exists(web_dir_path):
@ -2264,11 +2206,6 @@ class Status:
return template.respond() return template.respond()
@secured_expose(check_api_key=True) @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): def showlog(self, **kwargs):
try: try:
sabnzbd.LOGHANDLER.flush() sabnzbd.LOGHANDLER.flush()
@ -2309,11 +2246,6 @@ class Status:
return log_data return log_data
@secured_expose(check_api_key=True) @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): def change_loglevel(self, **kwargs):
cfg.log_level.set(kwargs.get("loglevel")) cfg.log_level.set(kwargs.get("loglevel"))
config.save_config() config.save_config()
@ -2524,7 +2456,8 @@ def GetRssLog(feed):
############################################################################## ##############################################################################
LIST_EMAIL = ( NOTIFY_OPTIONS = {}
NOTIFY_OPTIONS["misc"] = (
"email_endjob", "email_endjob",
"email_cats", "email_cats",
"email_full", "email_full",
@ -2535,7 +2468,7 @@ LIST_EMAIL = (
"email_pwd", "email_pwd",
"email_rss", "email_rss",
) )
LIST_NCENTER = ( NOTIFY_OPTIONS["ncenter"] = (
"ncenter_enable", "ncenter_enable",
"ncenter_cats", "ncenter_cats",
"ncenter_prio_startup", "ncenter_prio_startup",
@ -2552,7 +2485,7 @@ LIST_NCENTER = (
"ncenter_prio_other", "ncenter_prio_other",
"ncenter_prio_new_login", "ncenter_prio_new_login",
) )
LIST_ACENTER = ( NOTIFY_OPTIONS["acenter"] = (
"acenter_enable", "acenter_enable",
"acenter_cats", "acenter_cats",
"acenter_prio_startup", "acenter_prio_startup",
@ -2568,7 +2501,7 @@ LIST_ACENTER = (
"acenter_prio_other", "acenter_prio_other",
"acenter_prio_new_login", "acenter_prio_new_login",
) )
LIST_NTFOSD = ( NOTIFY_OPTIONS["ntfosd"] = (
"ntfosd_enable", "ntfosd_enable",
"ntfosd_cats", "ntfosd_cats",
"ntfosd_prio_startup", "ntfosd_prio_startup",
@ -2584,7 +2517,7 @@ LIST_NTFOSD = (
"ntfosd_prio_other", "ntfosd_prio_other",
"ntfosd_prio_new_login", "ntfosd_prio_new_login",
) )
LIST_PROWL = ( NOTIFY_OPTIONS["prowl"] = (
"prowl_enable", "prowl_enable",
"prowl_cats", "prowl_cats",
"prowl_apikey", "prowl_apikey",
@ -2601,7 +2534,7 @@ LIST_PROWL = (
"prowl_prio_other", "prowl_prio_other",
"prowl_prio_new_login", "prowl_prio_new_login",
) )
LIST_PUSHOVER = ( NOTIFY_OPTIONS["pushover"] = (
"pushover_enable", "pushover_enable",
"pushover_cats", "pushover_cats",
"pushover_token", "pushover_token",
@ -2622,7 +2555,7 @@ LIST_PUSHOVER = (
"pushover_emergency_retry", "pushover_emergency_retry",
"pushover_emergency_expire", "pushover_emergency_expire",
) )
LIST_PUSHBULLET = ( NOTIFY_OPTIONS["pushbullet"] = (
"pushbullet_enable", "pushbullet_enable",
"pushbullet_cats", "pushbullet_cats",
"pushbullet_apikey", "pushbullet_apikey",
@ -2640,7 +2573,7 @@ LIST_PUSHBULLET = (
"pushbullet_prio_other", "pushbullet_prio_other",
"pushbullet_prio_new_login", "pushbullet_prio_new_login",
) )
LIST_NSCRIPT = ( NOTIFY_OPTIONS["nscript"] = (
"nscript_enable", "nscript_enable",
"nscript_cats", "nscript_cats",
"nscript_script", "nscript_script",
@ -2663,35 +2596,20 @@ LIST_NSCRIPT = (
class ConfigNotify: class ConfigNotify:
def __init__(self, root): def __init__(self, root):
self.__root = root self.__root = root
self.__lastmail = None
@secured_expose(check_configlock=True) @secured_expose(check_configlock=True)
def index(self, **kwargs): def index(self, **kwargs):
conf = build_header(sabnzbd.WEB_DIR_CONFIG) conf = build_header(sabnzbd.WEB_DIR_CONFIG)
conf["notify_types"] = sabnzbd.notifier.NOTIFICATION
conf["categories"] = list_cats(False) conf["categories"] = list_cats(False)
conf["lastmail"] = self.__lastmail
conf["have_ntfosd"] = sabnzbd.notifier.have_ntfosd() conf["have_ntfosd"] = sabnzbd.notifier.have_ntfosd()
conf["have_ncenter"] = sabnzbd.DARWIN and sabnzbd.FOUNDATION conf["have_ncenter"] = sabnzbd.DARWIN and sabnzbd.FOUNDATION
conf["scripts"] = list_scripts(default=False, none=True) conf["scripts"] = list_scripts(default=False, none=True)
for kw in LIST_EMAIL: for section in NOTIFY_OPTIONS:
conf[kw] = config.get_config("misc", kw).get_string() for option in NOTIFY_OPTIONS[section]:
for kw in LIST_PROWL: # Use get_string to make sure lists are displayed correctly
conf[kw] = config.get_config("prowl", kw)() conf[option] = config.get_config(section, option).get_string()
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
template = Template( template = Template(
file=os.path.join(sabnzbd.WEB_DIR_CONFIG, "config_notify.tmpl"), file=os.path.join(sabnzbd.WEB_DIR_CONFIG, "config_notify.tmpl"),
@ -2701,45 +2619,12 @@ class ConfigNotify:
return template.respond() return template.respond()
@secured_expose(check_api_key=True, check_configlock=True) @secured_expose(check_api_key=True, check_configlock=True)
def saveEmail(self, **kwargs): def saveNotify(self, **kwargs):
ajax = kwargs.get("ajax") for section in NOTIFY_OPTIONS:
for option in NOTIFY_OPTIONS[section]:
for kw in LIST_EMAIL: config.get_config(section, option).set(kwargs.get(option))
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)
config.save_config() config.save_config()
self.__lastmail = None if kwargs.get("ajax"):
if ajax:
return sabnzbd.api.report("json") return sabnzbd.api.report("json")
else: else:
raise Raiser(self.__root) raise Raiser(self.__root)

1
sabnzbd/osxmenu.py

@ -37,7 +37,6 @@ from sabnzbd.filesystem import diskspace
from sabnzbd.misc import to_units from sabnzbd.misc import to_units
from sabnzbd.constants import VALID_ARCHIVES, VALID_NZB_FILES, MEBI, Status from sabnzbd.constants import VALID_ARCHIVES, VALID_NZB_FILES, MEBI, Status
from sabnzbd.panic import launch_a_browser from sabnzbd.panic import launch_a_browser
import sabnzbd.notifier as notifier
from sabnzbd.api import fast_queue from sabnzbd.api import fast_queue
import sabnzbd.config as config import sabnzbd.config as config

1
sabnzbd/zconfig.py

@ -19,7 +19,6 @@
sabnzbd.zconfig - bonjour/zeroconfig support sabnzbd.zconfig - bonjour/zeroconfig support
""" """
import os
import logging import logging
import socket import socket

Loading…
Cancel
Save