Browse Source

Fix old code throughout

pull/945/head
Safihre 8 years ago
parent
commit
b3a9dc9eeb
  1. 1
      SABnzbd.py
  2. 6
      sabnzbd/__init__.py
  3. 2
      sabnzbd/api.py
  4. 4
      sabnzbd/assembler.py
  5. 2
      sabnzbd/database.py
  6. 2
      sabnzbd/emailer.py
  7. 19
      sabnzbd/newsunpack.py
  8. 2
      sabnzbd/nzbstuff.py
  9. 2
      sabnzbd/urlgrabber.py
  10. 4
      sabnzbd/utils/systrayiconthread.py
  11. 1
      sabnzbd/wizard.py

1
SABnzbd.py

@ -1333,7 +1333,6 @@ def main():
'error_page.404': sabnzbd.panic.error_page_404 'error_page.404': sabnzbd.panic.error_page_404
}) })
# Do we want CherryPy Logging? Cannot be done via the config # Do we want CherryPy Logging? Cannot be done via the config
if cherrypylogging: if cherrypylogging:
sabnzbd.WEBLOGFILE = os.path.join(logdir, DEF_LOG_CHERRY) sabnzbd.WEBLOGFILE = os.path.join(logdir, DEF_LOG_CHERRY)

6
sabnzbd/__init__.py

@ -108,7 +108,7 @@ import sabnzbd.lang as lang
import sabnzbd.api import sabnzbd.api
from sabnzbd.decorators import synchronized, synchronized_CV, IO_LOCK from sabnzbd.decorators import synchronized, synchronized_CV, IO_LOCK
from sabnzbd.constants import NORMAL_PRIORITY, VALID_ARCHIVES, GIGI, \ from sabnzbd.constants import NORMAL_PRIORITY, VALID_ARCHIVES, GIGI, \
REPAIR_REQUEST, QUEUE_FILE_NAME, QUEUE_VERSION, QUEUE_FILE_TMPL REPAIR_REQUEST, QUEUE_FILE_NAME, QUEUE_VERSION, QUEUE_FILE_TMPL
import sabnzbd.getipaddress as getipaddress import sabnzbd.getipaddress as getipaddress
LINUX_POWER = powersup.HAVE_DBUS LINUX_POWER = powersup.HAVE_DBUS
@ -173,10 +173,10 @@ __SHUTTING_DOWN__ = False
############################################################################## ##############################################################################
def sig_handler(signum=None, frame=None): def sig_handler(signum=None, frame=None):
global SABSTOP, WINTRAY global SABSTOP, WINTRAY
if sabnzbd.WIN32 and type(signum) != type(None) and DAEMON and signum == 5: if sabnzbd.WIN32 and signum is not None and DAEMON and signum == 5:
# Ignore the "logoff" event when running as a Win32 daemon # Ignore the "logoff" event when running as a Win32 daemon
return True return True
if type(signum) != type(None): if signum is not None:
logging.warning(T('Signal %s caught, saving and exiting...'), signum) logging.warning(T('Signal %s caught, saving and exiting...'), signum)
try: try:
save_state() save_state()

2
sabnzbd/api.py

@ -1584,6 +1584,7 @@ def Tspec(txt):
else: else:
return txt return txt
_SKIN_CACHE = {} # Stores pre-translated acronyms _SKIN_CACHE = {} # Stores pre-translated acronyms
# This special is to be used in interface.py for template processing # This special is to be used in interface.py for template processing
# to be passed for the $T function: so { ..., 'T' : Ttemplate, ...} # to be passed for the $T function: so { ..., 'T' : Ttemplate, ...}
@ -1654,7 +1655,6 @@ def build_header(webdir='', output=None):
header['session'] = cfg.api_key() header['session'] = cfg.api_key()
header['new_release'], header['new_rel_url'] = sabnzbd.NEW_VERSION header['new_release'], header['new_rel_url'] = sabnzbd.NEW_VERSION
header['version'] = sabnzbd.__version__ header['version'] = sabnzbd.__version__
header['paused'] = Downloader.do.paused or Downloader.do.postproc header['paused'] = Downloader.do.paused or Downloader.do.postproc
header['pause_int'] = scheduler.pause_int() header['pause_int'] = scheduler.pause_int()

4
sabnzbd/assembler.py

@ -134,10 +134,10 @@ class Assembler(Thread):
filter, reason = nzo_filtered_by_rating(nzo) filter, reason = nzo_filtered_by_rating(nzo)
if filter == 1: if filter == 1:
logging.warning(Ta('WARNING: Paused job "%s" because of rating (%s)'), nzo.final_name, reason) logging.warning(T('WARNING: Paused job "%s" because of rating (%s)'), nzo.final_name, reason)
nzo.pause() nzo.pause()
elif filter == 2: elif filter == 2:
logging.warning(Ta('WARNING: Aborted job "%s" because of rating (%s)'), nzo.final_name, reason) logging.warning(T('WARNING: Aborted job "%s" because of rating (%s)'), nzo.final_name, reason)
nzo.fail_msg = T('Aborted, rating filter matched (%s)') % reason nzo.fail_msg = T('Aborted, rating filter matched (%s)') % reason
sabnzbd.nzbqueue.NzbQueue.do.end_job(nzo) sabnzbd.nzbqueue.NzbQueue.do.end_job(nzo)
else: else:

2
sabnzbd/database.py

@ -531,7 +531,7 @@ def unpack_history_info(item):
if item['script_log']: if item['script_log']:
item['script_log'] = '' item['script_log'] = ''
# The action line is only available for items in the postproc queue # The action line is only available for items in the postproc queue
if not item.has_key('action_line'): if 'action_line' not in item:
item['action_line'] = '' item['action_line'] = ''
return item return item

2
sabnzbd/emailer.py

@ -354,7 +354,7 @@ def _prepare_message(txt):
msg.set_payload('\n'.join(payload), code) msg.set_payload('\n'.join(payload), code)
# Check for proper encoding, else call it explicitly # Check for proper encoding, else call it explicitly
if not msg.has_key('Content-Transfer-Encoding'): if 'Content-Transfer-Encoding' not in msg:
encode_quopri(msg) encode_quopri(msg)
return msg.as_string() return msg.as_string()

19
sabnzbd/newsunpack.py

@ -37,7 +37,6 @@ from sabnzbd.misc import format_time_string, find_on_path, make_script_path, int
from sabnzbd.tvsort import SeriesSorter from sabnzbd.tvsort import SeriesSorter
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.constants import Status, QCHECK_FILE, RENAMES_FILE from sabnzbd.constants import Status, QCHECK_FILE, RENAMES_FILE
load_data = save_data = None
if sabnzbd.WIN32: if sabnzbd.WIN32:
try: try:
@ -85,8 +84,6 @@ RAR_VERSION = 0
def find_programs(curdir): def find_programs(curdir):
""" Find external programs """ """ Find external programs """
global load_data, save_data
def check(path, program): def check(path, program):
p = os.path.abspath(os.path.join(path, program)) p = os.path.abspath(os.path.join(path, program))
if os.access(p, os.X_OK): if os.access(p, os.X_OK):
@ -94,10 +91,6 @@ def find_programs(curdir):
else: else:
return None return None
# Another crazy Python import bug work-around
load_data = sabnzbd.load_data
save_data = sabnzbd.save_data
if sabnzbd.DARWIN: if sabnzbd.DARWIN:
sabnzbd.newsunpack.PAR2C_COMMAND = check(curdir, 'osx/par2/par2-classic') sabnzbd.newsunpack.PAR2C_COMMAND = check(curdir, 'osx/par2/par2-classic')
sabnzbd.newsunpack.PAR2_COMMAND = check(curdir, 'osx/par2/par2-sl64') sabnzbd.newsunpack.PAR2_COMMAND = check(curdir, 'osx/par2/par2-sl64')
@ -1590,10 +1583,10 @@ def PAR_Verify(parfile, parfile_nzf, nzo, setname, joinables, classic=False, sin
# If successful, add renamed files to the collection # If successful, add renamed files to the collection
if finished and renames: if finished and renames:
previous = load_data(RENAMES_FILE, nzo.workpath, remove=False) previous = sabnzbd.load_data(RENAMES_FILE, nzo.workpath, remove=False)
for name in previous or {}: for name in previous or {}:
renames[name] = previous[name] renames[name] = previous[name]
save_data(renames, RENAMES_FILE, nzo.workpath) sabnzbd.save_data(renames, RENAMES_FILE, nzo.workpath)
# If successful and files were reconstructed, remove incomplete original files # If successful and files were reconstructed, remove incomplete original files
if finished and reconstructed: if finished and reconstructed:
@ -1969,10 +1962,10 @@ def MultiPar_Verify(parfile, parfile_nzf, nzo, setname, joinables, classic=False
# But the ones in 'Finding available slices'-section will only be renamed after succesfull repair # But the ones in 'Finding available slices'-section will only be renamed after succesfull repair
if renames: if renames:
# Adding to the collection # Adding to the collection
previous = load_data(RENAMES_FILE, nzo.workpath, remove=False) previous = sabnzbd.load_data(RENAMES_FILE, nzo.workpath, remove=False)
for name in previous or {}: for name in previous or {}:
renames[name] = previous[name] renames[name] = previous[name]
save_data(renames, RENAMES_FILE, nzo.workpath) sabnzbd.save_data(renames, RENAMES_FILE, nzo.workpath)
# If succes, we also remove the possibly previously renamed ones # If succes, we also remove the possibly previously renamed ones
if finished and previous: if finished and previous:
@ -2233,10 +2226,10 @@ def QuickCheck(set, nzo):
# Save renames # Save renames
if renames: if renames:
previous = load_data(RENAMES_FILE, nzo.workpath, remove=False) previous = sabnzbd.load_data(RENAMES_FILE, nzo.workpath, remove=False)
for name in previous or {}: for name in previous or {}:
renames[name] = previous[name] renames[name] = previous[name]
save_data(renames, RENAMES_FILE, nzo.workpath) sabnzbd.save_data(renames, RENAMES_FILE, nzo.workpath)
return result return result

2
sabnzbd/nzbstuff.py

@ -1128,7 +1128,7 @@ class NzbObject(TryList):
if self.unwanted_ext and self.status == 'Paused': if self.unwanted_ext and self.status == 'Paused':
prefix += T('UNWANTED') + ' / ' # : Queue indicator for unwanted extensions prefix += T('UNWANTED') + ' / ' # : Queue indicator for unwanted extensions
if self.rating_filtered and self.status == 'Paused': if self.rating_filtered and self.status == 'Paused':
prefix += Ta('FILTERED') + ' / ' # : Queue indicator for filtered prefix += T('FILTERED') + ' / ' # : Queue indicator for filtered
if isinstance(self.wait, float): if isinstance(self.wait, float):
dif = int(self.wait - time.time() + 0.5) dif = int(self.wait - time.time() + 0.5)
if dif > 0: if dif > 0:

2
sabnzbd/urlgrabber.py

@ -42,7 +42,7 @@ import sabnzbd.notifier as notifier
_BAD_GZ_HOSTS = ('.zip', 'nzbsa.co.za', 'newshost.za.net') _BAD_GZ_HOSTS = ('.zip', 'nzbsa.co.za', 'newshost.za.net')
_RARTING_FIELDS = ('x-rating-id', 'x-rating-url', 'x-rating-host', 'x-rating-video', 'x-rating-videocnt', 'x-rating-audio', 'x-rating-audiocnt', _RARTING_FIELDS = ('x-rating-id', 'x-rating-url', 'x-rating-host', 'x-rating-video', 'x-rating-videocnt', 'x-rating-audio', 'x-rating-audiocnt',
'x-rating-voteup', 'x-rating-votedown', 'x-rating-spam', 'x-rating-confirmed-spam', 'x-rating-passworded', 'x-rating-confirmed-passworded') 'x-rating-voteup', 'x-rating-votedown', 'x-rating-spam', 'x-rating-confirmed-spam', 'x-rating-passworded', 'x-rating-confirmed-passworded')
class URLGrabber(Thread): class URLGrabber(Thread):

4
sabnzbd/utils/systrayiconthread.py

@ -6,8 +6,6 @@
# override doUpdates to perform actions inside the icon thread # override doUpdates to perform actions inside the icon thread
import os import os
import sys
import pywintypes import pywintypes
import win32api import win32api
import win32con import win32con
@ -204,7 +202,7 @@ class SysTrayIconThread(Thread):
win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0) win32gui.PostMessage(self.hwnd, win32con.WM_NULL, 0, 0)
except pywintypes.error: except pywintypes.error:
# Weird PyWin/win32gui bug, just ignore it for now # Weird PyWin/win32gui bug, just ignore it for now
logging.debug('win32gui problem, cannot show SysTray menu') pass
def create_menu(self, menu, menu_options): def create_menu(self, menu, menu_options):
for option_text, option_icon, option_action, option_id in menu_options[::-1]: for option_text, option_icon, option_action, option_id in menu_options[::-1]:

1
sabnzbd/wizard.py

@ -27,7 +27,6 @@ from Cheetah.Template import Template
import sabnzbd import sabnzbd
import sabnzbd.api import sabnzbd.api
from sabnzbd.lang import list_languages, set_language from sabnzbd.lang import list_languages, set_language
from sabnzbd.utils.servertests import test_nntp_server_dict
from sabnzbd.api import Ttemplate from sabnzbd.api import Ttemplate
import sabnzbd.interface import sabnzbd.interface
import sabnzbd.config as config import sabnzbd.config as config

Loading…
Cancel
Save