Browse Source

More pep8 cleanup, (revert) unused variables by import / duplicate imports / misspelling / some minor renames to avoid using built-in names (list/set/id/etc). Will cleanup addID in another pull.

pull/360/merge
Jonathon Saine 10 years ago
committed by shypike
parent
commit
6fb4d7ece3
  1. 10
      SABnzbd.py
  2. 79
      sabnzbd/interface.py
  3. 30
      sabnzbd/misc.py
  4. 2
      sabnzbd/newsunpack.py
  5. 16
      sabnzbd/newswrapper.py
  6. 12
      sabnzbd/nzbqueue.py
  7. 4
      sabnzbd/nzbstuff.py
  8. 14
      sabnzbd/osxmenu.py
  9. 16
      sabnzbd/postproc.py
  10. 2
      sabnzbd/sabtray.py
  11. 34
      sabnzbd/scheduler.py
  12. 6
      sabnzbd/urlgrabber.py
  13. 4
      sabnzbd/zconfig.py

10
SABnzbd.py

@ -297,7 +297,7 @@ GNU GENERAL PUBLIC LICENSE Version 2 or (at your option) any later version.
def daemonize(): def daemonize():
try: try:
pid = os.fork() # @UndefinedVariable - only available in UNIX pid = os.fork()
if pid > 0: if pid > 0:
sys.exit(0) sys.exit(0)
except OSError: except OSError:
@ -305,13 +305,13 @@ def daemonize():
sys.exit(1) sys.exit(1)
os.chdir(sabnzbd.DIR_PROG) os.chdir(sabnzbd.DIR_PROG)
os.setsid() # @UndefinedVariable - only available in UNIX os.setsid()
# Make sure I can read my own files and shut out others # Make sure I can read my own files and shut out others
prev = os.umask(0) prev = os.umask(0)
os.umask(prev and int('077', 8)) os.umask(prev and int('077', 8))
try: try:
pid = os.fork() # @UndefinedVariable - only available in UNIX pid = os.fork()
if pid > 0: if pid > 0:
sys.exit(0) sys.exit(0)
except OSError: except OSError:
@ -1659,7 +1659,7 @@ def main():
sabnzbd.halt() sabnzbd.halt()
cherrypy.engine.exit() cherrypy.engine.exit()
sabnzbd.SABSTOP = True sabnzbd.SABSTOP = True
if sabnzbd.downloader.Downloader.do.paused: # @UndefinedVariable if sabnzbd.downloader.Downloader.do.paused:
re_argv.append('-p') re_argv.append('-p')
if autorestarted: if autorestarted:
re_argv.append('--autorestarted') re_argv.append('--autorestarted')
@ -1676,7 +1676,7 @@ def main():
logging.info(os.getpid()) logging.info(os.getpid())
os.system('kill -9 %s && open "%s"' % (os.getpid(), sabnzbd.MY_FULLNAME.replace("/Contents/MacOS/SABnzbd", ""))) os.system('kill -9 %s && open "%s"' % (os.getpid(), sabnzbd.MY_FULLNAME.replace("/Contents/MacOS/SABnzbd", "")))
else: else:
pid = os.fork() # @UndefinedVariable - only available in UNIX pid = os.fork()
if pid == 0: if pid == 0:
os.execv(sys.executable, args) os.execv(sys.executable, args)
elif sabnzbd.WIN_SERVICE and mail: elif sabnzbd.WIN_SERVICE and mail:

79
sabnzbd/interface.py

@ -52,9 +52,9 @@ from sabnzbd.utils.servertests import test_nntp_server_dict
from sabnzbd.constants import \ from sabnzbd.constants import \
REC_RAR_VERSION, NORMAL_PRIORITY, PNFO_NZO_ID_FIELD, PNFO_REPAIR_FIELD, \ REC_RAR_VERSION, NORMAL_PRIORITY, PNFO_NZO_ID_FIELD, PNFO_REPAIR_FIELD, \
PNFO_UNPACK_FIELD, PNFO_DELETE_FIELD, PNFO_SCRIPT_FIELD, PNFO_EXTRA_FIELD1, \ PNFO_UNPACK_FIELD, PNFO_DELETE_FIELD, PNFO_SCRIPT_FIELD, PNFO_EXTRA_FIELD1, \
PNFO_PRIORITY_FIELD, PNFO_NZO_ID_FIELD, PNFO_FILENAME_FIELD, PNFO_ACTIVE_FILES_FIELD, \ PNFO_PRIORITY_FIELD, PNFO_FILENAME_FIELD, PNFO_ACTIVE_FILES_FIELD, \
MEBI, DEF_SKIN_COLORS, DEF_STDINTF, DEF_STDCONFIG, DEF_MAIN_TMPL, \ MEBI, DEF_SKIN_COLORS, DEF_STDINTF, DEF_STDCONFIG, DEF_MAIN_TMPL, \
DEF_SKIN_COLORS, DEFAULT_PRIORITY DEFAULT_PRIORITY
from sabnzbd.lang import list_languages, set_language from sabnzbd.lang import list_languages, set_language
@ -135,7 +135,7 @@ def rssRaiser(root, kwargs):
def IsNone(value): def IsNone(value):
""" Return True if either None, 'None' or '' """ """ Return True if either None, 'None' or '' """
return value == None or value == "" or value.lower() == 'none' return value is None or value == "" or value.lower() == 'none'
def Strip(txt): def Strip(txt):
@ -290,7 +290,7 @@ class MainPage(object):
config.save_config() config.save_config()
if kwargs.get('skip_wizard') or config.get_servers(): if kwargs.get('skip_wizard') or config.get_servers():
info, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir, search=kwargs.get('search')) info, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir, search=kwargs.get('search'))
info['script_list'] = list_scripts(default=True) info['script_list'] = list_scripts(default=True)
info['script'] = 'Default' info['script'] = 'Default'
@ -333,6 +333,7 @@ class MainPage(object):
def add_handler(self, kwargs): def add_handler(self, kwargs):
if not check_access(): if not check_access():
return Protected() return Protected()
# TODO: cleanup id / addID / Plush
id = kwargs.get('id', '') id = kwargs.get('id', '')
if not id: if not id:
id = kwargs.get('url', '') id = kwargs.get('url', '')
@ -516,7 +517,7 @@ class NzoPage(object):
break break
if nzo_id and NzbQueue.do.get_nzo(nzo_id): if nzo_id and NzbQueue.do.get_nzo(nzo_id):
info, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) info, pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
# /SABnzbd_nzo_xxxxx/bulk_operation # /SABnzbd_nzo_xxxxx/bulk_operation
if 'bulk_operation' in args: if 'bulk_operation' in args:
@ -631,12 +632,12 @@ class NzoPage(object):
priority = kwargs.get('priority', None) priority = kwargs.get('priority', None)
nzo = sabnzbd.nzbqueue.get_nzo(nzo_id) nzo = sabnzbd.nzbqueue.get_nzo(nzo_id)
if index != None: if index is not None:
NzbQueue.do.switch(nzo_id, index) NzbQueue.do.switch(nzo_id, index)
if name != None: if name is not None:
NzbQueue.do.change_name(nzo_id, special_fixer(name), password) NzbQueue.do.change_name(nzo_id, special_fixer(name), password)
if cat != None and nzo.cat != cat and not (nzo.cat == '*' and cat == 'Default'): if cat is not None and nzo.cat is not cat and not (nzo.cat == '*' and cat == 'Default'):
NzbQueue.do.change_cat(nzo_id, cat, priority) NzbQueue.do.change_cat(nzo_id, cat, priority)
# Category changed, so make sure "Default" attributes aren't set again # Category changed, so make sure "Default" attributes aren't set again
if script == 'Default': if script == 'Default':
@ -705,7 +706,7 @@ class QueuePage(object):
dummy2 = kwargs.get('dummy2') dummy2 = kwargs.get('dummy2')
search = kwargs.get('search') search = kwargs.get('search')
info, pnfo_list, bytespersec, self.__verbose_list, self.__dict__ = build_queue(self.__web_dir, self.__root, self.__verbose, info, _pnfo_list, _bytespersec, self.__verbose_list, self.__dict__ = build_queue(self.__web_dir, self.__root, self.__verbose,
self.__prim, self.__web_dir, self.__verbose_list, self.__prim, self.__web_dir, self.__verbose_list,
self.__dict__, start=start, limit=limit, self.__dict__, start=start, limit=limit,
dummy2=dummy2, trans=True, search=search) dummy2=dummy2, trans=True, search=search)
@ -949,7 +950,7 @@ class HistoryPage(object):
if failed_only is None: if failed_only is None:
failed_only = self.__failed_only failed_only = self.__failed_only
history, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) history, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
history['isverbose'] = self.__verbose history['isverbose'] = self.__verbose
history['failed_only'] = failed_only history['failed_only'] = failed_only
@ -1153,7 +1154,7 @@ class ConfigPage(object):
def index(self, **kwargs): def index(self, **kwargs):
if not check_access(): if not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
conf['configfn'] = config.get_filename() conf['configfn'] = config.get_filename()
conf['cmdline'] = sabnzbd.CMDLINE conf['cmdline'] = sabnzbd.CMDLINE
@ -1246,7 +1247,7 @@ class ConfigFolders(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
for kw in LIST_DIRPAGE: for kw in LIST_DIRPAGE:
conf[kw] = config.get_config('misc', kw)() conf[kw] = config.get_config('misc', kw)()
@ -1266,7 +1267,7 @@ class ConfigFolders(object):
for kw in LIST_DIRPAGE: for kw in LIST_DIRPAGE:
value = kwargs.get(kw) value = kwargs.get(kw)
if value != None: if value is not None:
value = platform_encode(value) value = platform_encode(value)
if kw in ('complete_dir', 'dirscan_dir'): if kw in ('complete_dir', 'dirscan_dir'):
msg = config.get_config('misc', kw).set(value, create=True) msg = config.get_config('misc', kw).set(value, create=True)
@ -1319,7 +1320,7 @@ class ConfigSwitches(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
conf['have_multicore'] = sabnzbd.WIN32 or sabnzbd.DARWIN_INTEL conf['have_multicore'] = sabnzbd.WIN32 or sabnzbd.DARWIN_INTEL
conf['have_nice'] = bool(sabnzbd.newsunpack.NICE_COMMAND) conf['have_nice'] = bool(sabnzbd.newsunpack.NICE_COMMAND)
@ -1397,7 +1398,7 @@ class ConfigSpecial(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
conf['nt'] = sabnzbd.WIN32 conf['nt'] = sabnzbd.WIN32
@ -1454,21 +1455,21 @@ class ConfigGeneral(object):
lst.append(col) lst.append(col)
return lst return lst
def add_color(dir, color): def add_color(skin_dir, color):
if dir: if skin_dir:
if not color: if not color:
try: try:
color = DEF_SKIN_COLORS[dir.lower()] color = DEF_SKIN_COLORS[skin_dir.lower()]
except KeyError: except KeyError:
return dir return skin_dir
return '%s - %s' % (dir, color) return '%s - %s' % (skin_dir, color)
else: else:
return '' return ''
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
conf['configfn'] = config.get_filename() conf['configfn'] = config.get_filename()
@ -1505,10 +1506,10 @@ class ConfigGeneral(object):
conf['web_dir2'] = add_color(cfg.web_dir2(), cfg.web_color2()) conf['web_dir2'] = add_color(cfg.web_dir2(), cfg.web_color2())
conf['language'] = cfg.language() conf['language'] = cfg.language()
list = list_languages() lang_list = list_languages()
if len(list) < 2: if len(lang_list) < 2:
list = [] lang_list = []
conf['lang_list'] = list conf['lang_list'] = lang_list
conf['disable_api_key'] = cfg.disable_key() conf['disable_api_key'] = cfg.disable_key()
conf['host'] = cfg.cherryhost() conf['host'] = cfg.cherryhost()
@ -1581,10 +1582,10 @@ class ConfigGeneral(object):
cfg.web_color2.set(web_color2) cfg.web_color2.set(web_color2)
bandwidth_max = kwargs.get('bandwidth_max') bandwidth_max = kwargs.get('bandwidth_max')
if bandwidth_max != None: if bandwidth_max is not None:
cfg.bandwidth_max.set(bandwidth_max) cfg.bandwidth_max.set(bandwidth_max)
bandwidth_perc = kwargs.get('bandwidth_perc') bandwidth_perc = kwargs.get('bandwidth_perc')
if bandwidth_perc != None: if bandwidth_perc is not None:
cfg.bandwidth_perc.set(bandwidth_perc) cfg.bandwidth_perc.set(bandwidth_perc)
bandwidth_perc = cfg.bandwidth_perc() bandwidth_perc = cfg.bandwidth_perc()
if bandwidth_perc and not bandwidth_max: if bandwidth_perc and not bandwidth_max:
@ -1653,7 +1654,7 @@ class ConfigServer(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
new = [] new = []
servers = config.get_servers() servers = config.get_servers()
@ -1798,7 +1799,7 @@ def handle_server(kwargs, root=None, new_svr=False):
def handle_server_test(kwargs, root): def handle_server_test(kwargs, root):
result, msg = test_nntp_server_dict(kwargs) _result, msg = test_nntp_server_dict(kwargs)
return msg return msg
@ -1820,7 +1821,7 @@ class ConfigRss(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
conf['script_list'] = list_scripts(default=True) conf['script_list'] = list_scripts(default=True)
pick_script = conf['script_list'] != [] pick_script = conf['script_list'] != []
@ -2143,7 +2144,7 @@ class ConfigScheduling(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
actions = [] actions = []
actions.extend(_SCHED_ACTIONS) actions.extend(_SCHED_ACTIONS)
@ -2292,7 +2293,7 @@ class ConfigCats(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
conf['script_list'] = list_scripts(default=True) conf['script_list'] = list_scripts(default=True)
@ -2367,7 +2368,7 @@ class ConfigSorting(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
conf['complete_dir'] = cfg.complete_dir.get_path() conf['complete_dir'] = cfg.complete_dir.get_path()
for kw in SORT_LIST: for kw in SORT_LIST:
@ -2420,7 +2421,7 @@ class Status(object):
def index(self, **kwargs): def index(self, **kwargs):
if not check_access(): if not check_access():
return Protected() return Protected()
header, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) header, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
# anything in header[] will be known to the python templates # anything in header[] will be known to the python templates
# header['blabla'] will be known as $blabla # header['blabla'] will be known as $blabla
@ -2455,7 +2456,7 @@ class Status(object):
# Dashboard: Speed of Download directory: # Dashboard: Speed of Download directory:
header['downloaddir'] = sabnzbd.cfg.download_dir.get_path() header['downloaddir'] = sabnzbd.cfg.download_dir.get_path()
try: try:
sabnzbd.downloaddirspeed # The persistent var sabnzbd.downloaddirspeed # The persistent var @UndefinedVariable
except: except:
# does not yet exist, so create it: # does not yet exist, so create it:
sabnzbd.downloaddirspeed = -1 # -1 means ... not yet determined sabnzbd.downloaddirspeed = -1 # -1 means ... not yet determined
@ -2463,14 +2464,14 @@ class Status(object):
# Dashboard: Speed of Complete directory: # Dashboard: Speed of Complete directory:
header['completedir'] = sabnzbd.cfg.complete_dir.get_path() header['completedir'] = sabnzbd.cfg.complete_dir.get_path()
try: try:
sabnzbd.completedirspeed # The persistent var sabnzbd.completedirspeed # The persistent var @UndefinedVariable
except: except:
# does not yet exist, so create it: # does not yet exist, so create it:
sabnzbd.completedirspeed = -1 # -1 means ... not yet determined sabnzbd.completedirspeed = -1 # -1 means ... not yet determined
header['completedirspeed'] = sabnzbd.completedirspeed header['completedirspeed'] = sabnzbd.completedirspeed
try: try:
sabnzbd.dashrefreshcounter # The persistent var sabnzbd.dashrefreshcounter # The persistent var @UndefinedVariable
except: except:
sabnzbd.dashrefreshcounter = 0 sabnzbd.dashrefreshcounter = 0
header['dashrefreshcounter'] = sabnzbd.dashrefreshcounter header['dashrefreshcounter'] = sabnzbd.dashrefreshcounter
@ -2769,7 +2770,7 @@ class ConfigNotify(object):
if cfg.configlock() or not check_access(): if cfg.configlock() or not check_access():
return Protected() return Protected()
conf, pnfo_list, bytespersec = build_header(self.__prim, self.__web_dir) conf, _pnfo_list, _bytespersec = build_header(self.__prim, self.__web_dir)
conf['my_home'] = sabnzbd.DIR_HOME conf['my_home'] = sabnzbd.DIR_HOME
conf['lastmail'] = self.__lastmail conf['lastmail'] = self.__lastmail
@ -2871,7 +2872,7 @@ def rss_history(url, limit=50, search=None):
rss.channel.link = "http://sourceforge.net/projects/sabnzbdplus/" rss.channel.link = "http://sourceforge.net/projects/sabnzbdplus/"
rss.channel.language = "en" rss.channel.language = "en"
items, fetched_items, max_items = build_history(limit=limit, search=search) items, _fetched_items, _max_items = build_history(limit=limit, search=search)
for history in items: for history in items:
item = Item() item = Item()

30
sabnzbd/misc.py

@ -234,16 +234,19 @@ def sanitize_filename(name):
ext = lowext ext = lowext
return name + ext return name + ext
FL_ILLEGAL = CH_ILLEGAL + ':\x92"'
FL_LEGAL = CH_LEGAL + "-''"
uFL_ILLEGAL = FL_ILLEGAL.decode('cp1252')
uFL_LEGAL = FL_LEGAL.decode('cp1252')
def sanitize_foldername(name, limit=True): def sanitize_foldername(name, limit=True):
""" Return foldername with dodgy chars converted to safe ones """ Return foldername with dodgy chars converted to safe ones
Remove any leading and trailing dot and space characters Remove any leading and trailing dot and space characters
""" """
if not name: if not name:
return name return name
FL_ILLEGAL = CH_ILLEGAL + ':\x92"'
FL_LEGAL = CH_LEGAL + "-''"
uFL_ILLEGAL = FL_ILLEGAL.decode('cp1252')
uFL_LEGAL = FL_LEGAL.decode('cp1252')
if isinstance(name, unicode): if isinstance(name, unicode):
illegal = uFL_ILLEGAL illegal = uFL_ILLEGAL
legal = uFL_LEGAL legal = uFL_LEGAL
@ -432,7 +435,7 @@ def windows_variant():
import _winreg import _winreg
vista_plus = x64 = False vista_plus = x64 = False
maj, minor, buildno, plat, csd = GetVersionEx() maj, _minor, _buildno, plat, _csd = GetVersionEx()
if plat == VER_PLATFORM_WIN32_NT: if plat == VER_PLATFORM_WIN32_NT:
vista_plus = maj > 5 vista_plus = maj > 5
@ -444,7 +447,7 @@ def windows_variant():
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment") r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment")
for n in xrange(_winreg.QueryInfoKey(key)[1]): for n in xrange(_winreg.QueryInfoKey(key)[1]):
name, value, val_type = _winreg.EnumValue(key, n) name, value, _val_type = _winreg.EnumValue(key, n)
if name == 'PROCESSOR_ARCHITECTURE': if name == 'PROCESSOR_ARCHITECTURE':
x64 = value.upper() == u'AMD64' x64 = value.upper() == u'AMD64'
break break
@ -465,7 +468,7 @@ def get_serv_parms(service):
try: try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, _SERVICE_KEY + service) key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, _SERVICE_KEY + service)
for n in xrange(_winreg.QueryInfoKey(key)[1]): for n in xrange(_winreg.QueryInfoKey(key)[1]):
name, value, val_type = _winreg.EnumValue(key, n) name, value, _val_type = _winreg.EnumValue(key, n)
if name == _SERVICE_PARM: if name == _SERVICE_PARM:
break break
_winreg.CloseKey(key) _winreg.CloseKey(key)
@ -682,7 +685,7 @@ def exit_sab(value):
sys.stdout.flush() sys.stdout.flush()
if getattr(sys, 'frozen', None) == 'macosx_app': if getattr(sys, 'frozen', None) == 'macosx_app':
sabnzbd.SABSTOP = True sabnzbd.SABSTOP = True
from PyObjCTools import AppHelper from PyObjCTools import AppHelper # @UnresolvedImport
AppHelper.stopEventLoop() AppHelper.stopEventLoop()
sys.exit(value) sys.exit(value)
@ -1092,7 +1095,7 @@ else:
def create_https_certificates(ssl_cert, ssl_key): def create_https_certificates(ssl_cert, ssl_key):
""" Create self-signed HTTPS certificares and store in paths 'ssl_cert' and 'ssl_key' """ """ Create self-signed HTTPS certificates and store in paths 'ssl_cert' and 'ssl_key' """
try: try:
from OpenSSL import crypto from OpenSSL import crypto
from sabnzbd.utils.certgen import createKeyPair, createCertRequest, createCertificate, \ from sabnzbd.utils.certgen import createKeyPair, createCertRequest, createCertificate, \
@ -1263,10 +1266,9 @@ def format_source_url(url):
prot = 'http:' prot = 'http:'
return url return url
RE_URL = re.compile(r'://([^/]+)/')
def get_base_url(url): def get_base_url(url):
RE_URL = re.compile(r'://([^/]+)/')
m = RE_URL.search(url) m = RE_URL.search(url)
if m: if m:
return m.group(1) return m.group(1)
@ -1284,7 +1286,7 @@ def match_str(text, matches):
def starts_with_path(path, prefix): def starts_with_path(path, prefix):
""" Return True if 'path' starts with 'prefix', """ Return True if 'path' starts with 'prefix',
considering case-sensitivity of filesystem considering case-sensitivity of the file system
""" """
if sabnzbd.WIN32: if sabnzbd.WIN32:
return clip_path(path).lower().startswith(prefix.lower()) return clip_path(path).lower().startswith(prefix.lower())
@ -1326,7 +1328,7 @@ def set_permissions(path, recursive=True):
if os.path.isdir(path): if os.path.isdir(path):
if recursive: if recursive:
# Parse the dir/file tree and set permissions # Parse the dir/file tree and set permissions
for root, dirs, files in os.walk(path): for root, _dirs, files in os.walk(path):
set_chmod(root, umask, report) set_chmod(root, umask, report)
for name in files: for name in files:
set_chmod(os.path.join(root, name), umask_file, report) set_chmod(os.path.join(root, name), umask_file, report)
@ -1337,7 +1339,7 @@ def set_permissions(path, recursive=True):
def short_path(path, always=True): def short_path(path, always=True):
""" For Windows, return shortended ASCII path, for others same path """ For Windows, return shortened ASCII path, for others same path
When `always` is off, only return a short path when size is above 259 When `always` is off, only return a short path when size is above 259
""" """
if sabnzbd.WIN32: if sabnzbd.WIN32:

2
sabnzbd/newsunpack.py

@ -430,7 +430,7 @@ def rar_unpack(nzo, workdir, workdir_complete, delete, one_folder, rars):
rar_set = os.path.splitext(os.path.basename(rar))[0] rar_set = os.path.splitext(os.path.basename(rar))[0]
if RAR_RE_V3.search(rar_set): if RAR_RE_V3.search(rar_set):
rar_set = os.path.splitext(rar_set)[0] rar_set = os.path.splitext(rar_set)[0]
if not rar_set in rar_sets: if rar_set not in rar_sets:
rar_sets[rar_set] = [] rar_sets[rar_set] = []
rar_sets[rar_set].append(rar) rar_sets[rar_set].append(rar)

16
sabnzbd/newswrapper.py

@ -108,7 +108,7 @@ def GetServerParms(host, port):
try: try:
# Standard IPV4 or IPV6 # Standard IPV4 or IPV6
ips = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM) ips = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)
if opt == 2 or (opt == 1 and sabnzbd.EXTERNAL_IPV6) or (opt == 1 and sabnzbd.cfg.load_balancing()==2): if opt == 2 or (opt == 1 and sabnzbd.EXTERNAL_IPV6) or (opt == 1 and sabnzbd.cfg.load_balancing() == 2):
# IPv6 forced by user, or IPv6 allowed and reachable, or IPv6 allowed and loadbalancing-with-IPv6 activated # IPv6 forced by user, or IPv6 allowed and reachable, or IPv6 allowed and loadbalancing-with-IPv6 activated
# So return all IP addresses, no matter IPv4 or IPv6: # So return all IP addresses, no matter IPv4 or IPv6:
return ips return ips
@ -116,7 +116,7 @@ def GetServerParms(host, port):
# IPv6 unreachable or not allowed by user, so only return IPv4 address(es): # IPv6 unreachable or not allowed by user, so only return IPv4 address(es):
return [ip for ip in ips if ':' not in ip[4][0]] return [ip for ip in ips if ':' not in ip[4][0]]
except: except:
if opt == 2 or (opt == 1 and sabnzbd.EXTERNAL_IPV6) or (opt == 1 and sabnzbd.cfg.load_balancing()==2): if opt == 2 or (opt == 1 and sabnzbd.EXTERNAL_IPV6) or (opt == 1 and sabnzbd.cfg.load_balancing() == 2):
try: try:
# Try IPV6 explicitly # Try IPV6 explicitly
return socket.getaddrinfo(host, port, socket.AF_INET6, return socket.getaddrinfo(host, port, socket.AF_INET6,
@ -181,12 +181,14 @@ def probablyipv4(ip):
else: else:
return False return False
def probablyipv6(ip): def probablyipv6(ip):
if ip.count(':') >= 2 and re.sub('[0123456789abcdefABCDEF:]', '', ip) == '' : if ip.count(':') >= 2 and re.sub('[0123456789abcdefABCDEF:]', '', ip) == '':
return True return True
else: else:
return False return False
class NNTP(object): class NNTP(object):
def __init__(self, host, port, info, sslenabled, ssl_type, send_group, nw, user=None, password=None, block=False, write_fds=None): def __init__(self, host, port, info, sslenabled, ssl_type, send_group, nw, user=None, password=None, block=False, write_fds=None):
@ -205,9 +207,11 @@ class NNTP(object):
af, socktype, proto, canonname, sa = info[0] af, socktype, proto, canonname, sa = info[0]
# there wil be a connect to host (or self.host, so let's force set 'af' to the correct value # there will be a connect to host (or self.host, so let's force set 'af' to the correct value
if probablyipv4(host): af = socket.AF_INET if probablyipv4(host):
if probablyipv6(host): af = socket.AF_INET6 af = socket.AF_INET
if probablyipv6(host):
af = socket.AF_INET6
if sslenabled and _ssl: if sslenabled and _ssl:
ctx = _ssl.Context(_SSL_TYPES.get(ssl_type, _ssl.TLSv1_METHOD)) ctx = _ssl.Context(_SSL_TYPES.get(ssl_type, _ssl.TLSv1_METHOD))

12
sabnzbd/nzbqueue.py

@ -283,7 +283,7 @@ class NzbQueue(TryList):
sabnzbd.remove_data(nzo_id, future.workpath) sabnzbd.remove_data(nzo_id, future.workpath)
logging.info("Regenerating item: %s", nzo_id) logging.info("Regenerating item: %s", nzo_id)
r, u, d = future.repair_opts r, u, d = future.repair_opts
if not r is None: if r is not None:
pp = sabnzbd.opts_to_pp(r, u, d) pp = sabnzbd.opts_to_pp(r, u, d)
scr = future.script scr = future.script
if scr is None: if scr is None:
@ -596,7 +596,7 @@ class NzbQueue(TryList):
@synchronized(NZBQUEUE_LOCK) @synchronized(NZBQUEUE_LOCK)
def move_up_bulk(self, nzo_id, nzf_ids, size): def move_up_bulk(self, nzo_id, nzf_ids, size):
if nzo_id in self.__nzo_table: if nzo_id in self.__nzo_table:
for x in range(size): for unused in range(size):
self.__nzo_table[nzo_id].move_up_bulk(nzf_ids) self.__nzo_table[nzo_id].move_up_bulk(nzf_ids)
@synchronized(NZBQUEUE_LOCK) @synchronized(NZBQUEUE_LOCK)
@ -607,7 +607,7 @@ class NzbQueue(TryList):
@synchronized(NZBQUEUE_LOCK) @synchronized(NZBQUEUE_LOCK)
def move_down_bulk(self, nzo_id, nzf_ids, size): def move_down_bulk(self, nzo_id, nzf_ids, size):
if nzo_id in self.__nzo_table: if nzo_id in self.__nzo_table:
for x in range(size): for unused in range(size):
self.__nzo_table[nzo_id].move_down_bulk(nzf_ids) self.__nzo_table[nzo_id].move_down_bulk(nzf_ids)
@synchronized(NZBQUEUE_LOCK) @synchronized(NZBQUEUE_LOCK)
@ -646,7 +646,7 @@ class NzbQueue(TryList):
elif field.lower() == 'avg_age': elif field.lower() == 'avg_age':
self.sort_by_avg_age(reverse) self.sort_by_avg_age(reverse)
else: else:
logging.debug("Sort: %s not recognised", field) logging.debug("Sort: %s not recognized", field)
def __set_priority(self, nzo_id, priority): def __set_priority(self, nzo_id, priority):
""" Sets the priority on the nzo and places it in the queue at the appropriate position """ """ Sets the priority on the nzo and places it in the queue at the appropriate position """
@ -842,10 +842,10 @@ class NzbQueue(TryList):
if nzo.precheck: if nzo.precheck:
nzo.save_to_disk() nzo.save_to_disk()
# Check result # Check result
enough, ratio = nzo.check_quality() enough, _ratio = nzo.check_quality()
if enough: if enough:
# Enough data present, do real download # Enough data present, do real download
workdir = nzo.downpath _workdir = nzo.downpath
self.cleanup_nzo(nzo, keep_basic=True) self.cleanup_nzo(nzo, keep_basic=True)
self.send_back(nzo) self.send_back(nzo)
return return

4
sabnzbd/nzbstuff.py

@ -1259,7 +1259,7 @@ class NzbObject(TryList):
self.files.remove(nzf) self.files.remove(nzf)
# If cleanup emptied the active files list, end this job # If cleanup emptied the active files list, end this job
if nzf_remove_list and not self.files: if nzf_remove_list and not self.files:
sabnzbd.NzbQueue.do.end_job(self) # @UndefinedVariable sabnzbd.NzbQueue.do.end_job(self)
if not article: if not article:
# No articles for this server, block for next time # No articles for this server, block for next time
@ -1343,7 +1343,7 @@ class NzbObject(TryList):
fields = {} fields = {}
for k in rating_types: for k in rating_types:
fields[k] = _get_first_meta(k) fields[k] = _get_first_meta(k)
Rating.do.add_rating(_get_first_meta('id'), self.nzo_id, self.meta.get('x-rating-host'), fields) # @UndefinedVariable Rating.do.add_rating(_get_first_meta('id'), self.nzo_id, self.meta.get('x-rating-host'), fields)
except: except:
pass pass

14
sabnzbd/osxmenu.py

@ -110,7 +110,7 @@ class SABnzbdDelegate(NSObject):
# Variables # Variables
self.state = "Idle" self.state = "Idle"
try: try:
self.speed = sabnzbd.downloader.Downloader.do.get_limit() # @UndefinedVariable self.speed = sabnzbd.downloader.Downloader.do.get_limit()
except: except:
self.speed = 0 self.speed = 0
self.version_notify = 1 self.version_notify = 1
@ -500,7 +500,7 @@ class SABnzbdDelegate(NSObject):
def iconUpdate(self): def iconUpdate(self):
try: try:
if sabnzbd.downloader.Downloader.do.paused: # @UndefinedVariable if sabnzbd.downloader.Downloader.do.paused:
self.status_item.setImage_(self.icons['pause']) self.status_item.setImage_(self.icons['pause'])
else: else:
self.status_item.setImage_(self.icons['idle']) self.status_item.setImage_(self.icons['idle'])
@ -509,7 +509,7 @@ class SABnzbdDelegate(NSObject):
def pauseUpdate(self): def pauseUpdate(self):
try: try:
if sabnzbd.downloader.Downloader.do.paused: # @UndefinedVariable if sabnzbd.downloader.Downloader.do.paused:
if self.isLeopard: if self.isLeopard:
self.resume_menu_item.setHidden_(NO) self.resume_menu_item.setHidden_(NO)
self.pause_menu_item.setHidden_(YES) self.pause_menu_item.setHidden_(YES)
@ -528,7 +528,7 @@ class SABnzbdDelegate(NSObject):
def speedlimitUpdate(self): def speedlimitUpdate(self):
try: try:
speed = int(sabnzbd.downloader.Downloader.do.get_limit()) # @UndefinedVariable speed = int(sabnzbd.downloader.Downloader.do.get_limit())
if self.speed != speed: if self.speed != speed:
self.speed = speed self.speed = speed
speedsValues = self.menu_speed.numberOfItems() speedsValues = self.menu_speed.numberOfItems()
@ -685,14 +685,14 @@ class SABnzbdDelegate(NSObject):
# logging.info("[osx] speed limit to %s" % (sender.representedObject())) # logging.info("[osx] speed limit to %s" % (sender.representedObject()))
speed = int(sender.representedObject()) speed = int(sender.representedObject())
if speed != self.speed: if speed != self.speed:
sabnzbd.downloader.Downloader.do.limit_speed(speed) # @UndefinedVariable sabnzbd.downloader.Downloader.do.limit_speed(speed)
self.speedlimitUpdate() self.speedlimitUpdate()
def purgeAction_(self, sender): def purgeAction_(self, sender):
mode = sender.representedObject() mode = sender.representedObject()
# logging.info("[osx] purge %s" % (mode)) # logging.info("[osx] purge %s" % (mode))
if mode == "queue": if mode == "queue":
NzbQueue.do.remove_all() # @UndefinedVariable NzbQueue.do.remove_all()
elif mode == "history": elif mode == "history":
if not self.history_db: if not self.history_db:
self.history_db = sabnzbd.database.get_history_handle() self.history_db = sabnzbd.database.get_history_handle()
@ -704,7 +704,7 @@ class SABnzbdDelegate(NSObject):
if minutes: if minutes:
scheduler.plan_resume(minutes) scheduler.plan_resume(minutes)
else: else:
sabnzbd.downloader.Downloader.do.pause() # @UndefinedVariable sabnzbd.downloader.Downloader.do.pause()
def resumeAction_(self, sender): def resumeAction_(self, sender):
scheduler.plan_resume(0) scheduler.plan_resume(0)

16
sabnzbd/postproc.py

@ -183,7 +183,7 @@ class PostProcessor(Thread):
# Pause downloader, if users wants that # Pause downloader, if users wants that
if cfg.pause_on_post_processing(): if cfg.pause_on_post_processing():
sabnzbd.downloader.Downloader.do.wait_for_postproc() # @UndefinedVariable sabnzbd.downloader.Downloader.do.wait_for_postproc()
self.__busy = True self.__busy = True
process_job(nzo) process_job(nzo)
@ -191,7 +191,7 @@ class PostProcessor(Thread):
check_eoq = True check_eoq = True
# Allow download to proceed # Allow download to proceed
sabnzbd.downloader.Downloader.do.resume_from_postproc() # @UndefinedVariable sabnzbd.downloader.Downloader.do.resume_from_postproc()
def process_job(nzo): def process_job(nzo):
@ -495,13 +495,13 @@ def process_job(nzo):
# Update indexer with results # Update indexer with results
if cfg.rating_enable(): if cfg.rating_enable():
if nzo.encrypted > 0: if nzo.encrypted > 0:
Rating.do.update_auto_flag(nzo.nzo_id, Rating.FLAG_ENCRYPTED) # @UndefinedVariable Rating.do.update_auto_flag(nzo.nzo_id, Rating.FLAG_ENCRYPTED)
if empty: if empty:
hosts = map(lambda s: s.host, sabnzbd.downloader.Downloader.do.nzo_servers(nzo)) # @UndefinedVariable hosts = map(lambda s: s.host, sabnzbd.downloader.Downloader.do.nzo_servers(nzo))
if not hosts: if not hosts:
hosts = [None] hosts = [None]
for host in hosts: for host in hosts:
Rating.do.update_auto_flag(nzo.nzo_id, Rating.FLAG_EXPIRED, host) # @UndefinedVariable Rating.do.update_auto_flag(nzo.nzo_id, Rating.FLAG_EXPIRED, host)
# Show final status in history # Show final status in history
if all_ok: if all_ok:
@ -545,7 +545,7 @@ def process_job(nzo):
# Clean up the NZO # Clean up the NZO
try: try:
logging.info('Cleaning up %s (keep_basic=%s)', filename, str(not all_ok)) logging.info('Cleaning up %s (keep_basic=%s)', filename, str(not all_ok))
sabnzbd.nzbqueue.NzbQueue.do.cleanup_nzo(nzo, keep_basic=not all_ok) # @UndefinedVariable sabnzbd.nzbqueue.NzbQueue.do.cleanup_nzo(nzo, keep_basic=not all_ok)
except: except:
logging.error(T('Cleanup of %s failed.'), nzo.final_name) logging.error(T('Cleanup of %s failed.'), nzo.final_name)
logging.info("Traceback: ", exc_info=True) logging.info("Traceback: ", exc_info=True)
@ -616,7 +616,7 @@ def parring(nzo, workdir):
if nzo.priority != TOP_PRIORITY: if nzo.priority != TOP_PRIORITY:
nzo.priority = REPAIR_PRIORITY nzo.priority = REPAIR_PRIORITY
sabnzbd.nzbqueue.add_nzo(nzo) sabnzbd.nzbqueue.add_nzo(nzo)
sabnzbd.downloader.Downloader.do.resume_from_postproc() # @UndefinedVariable sabnzbd.downloader.Downloader.do.resume_from_postproc()
sabnzbd.save_data(verified, VERIFIED_FILE, nzo.workpath) sabnzbd.save_data(verified, VERIFIED_FILE, nzo.workpath)
@ -670,7 +670,7 @@ def addPrefixes(path, dirprefix):
def handle_empty_queue(): def handle_empty_queue():
""" Check if empty queue calls for action """ """ Check if empty queue calls for action """
if sabnzbd.nzbqueue.NzbQueue.do.actives() == 0: # @UndefinedVariable if sabnzbd.nzbqueue.NzbQueue.do.actives() == 0:
sabnzbd.save_state() sabnzbd.save_state()
logging.info("Queue has finished, launching: %s (%s)", logging.info("Queue has finished, launching: %s (%s)",
sabnzbd.QUEUECOMPLETEACTION, sabnzbd.QUEUECOMPLETEARG) sabnzbd.QUEUECOMPLETEACTION, sabnzbd.QUEUECOMPLETEARG)

2
sabnzbd/sabtray.py

@ -170,7 +170,7 @@ class SABTrayThread(SysTrayIconThread):
# adapted from interface.py # adapted from interface.py
def pause(self): def pause(self):
scheduler.plan_resume(0) scheduler.plan_resume(0)
Downloader.do.pause() # @UndefinedVariable Downloader.do.pause()
# adapted from interface.py # adapted from interface.py
def resume(self): def resume(self):

34
sabnzbd/scheduler.py

@ -94,7 +94,7 @@ def init():
action = scheduled_resume action = scheduled_resume
arguments = [] arguments = []
elif action_name == 'pause': elif action_name == 'pause':
action = sabnzbd.downloader.Downloader.do.pause # @UndefinedVariable action = sabnzbd.downloader.Downloader.do.pause
arguments = [] arguments = []
elif action_name == 'pause_all': elif action_name == 'pause_all':
action = sabnzbd.pause_all action = sabnzbd.pause_all
@ -110,7 +110,7 @@ def init():
elif action_name == 'resume_post': elif action_name == 'resume_post':
action = pp_resume action = pp_resume
elif action_name == 'speedlimit' and arguments != []: elif action_name == 'speedlimit' and arguments != []:
action = sabnzbd.downloader.Downloader.do.limit_speed # @UndefinedVariable action = sabnzbd.downloader.Downloader.do.limit_speed
elif action_name == 'enable_server' and arguments != []: elif action_name == 'enable_server' and arguments != []:
action = sabnzbd.enable_server action = sabnzbd.enable_server
elif action_name == 'disable_server' and arguments != []: elif action_name == 'disable_server' and arguments != []:
@ -123,28 +123,28 @@ def init():
elif action_name == 'remove_failed': elif action_name == 'remove_failed':
action = sabnzbd.api.history_remove_failed action = sabnzbd.api.history_remove_failed
elif action_name == 'enable_quota': elif action_name == 'enable_quota':
action = sabnzbd.bpsmeter.BPSMeter.do.set_status # @UndefinedVariable action = sabnzbd.bpsmeter.BPSMeter.do.set_status
arguments = [True] arguments = [True]
elif action_name == 'disable_quota': elif action_name == 'disable_quota':
action = sabnzbd.bpsmeter.BPSMeter.do.set_status # @UndefinedVariable action = sabnzbd.bpsmeter.BPSMeter.do.set_status
arguments = [False] arguments = [False]
elif action_name == 'pause_all_low': elif action_name == 'pause_all_low':
action = sabnzbd.nzbqueue.NzbQueue.do.pause_on_prio # @UndefinedVariable action = sabnzbd.nzbqueue.NzbQueue.do.pause_on_prio
arguments = [LOW_PRIORITY] arguments = [LOW_PRIORITY]
elif action_name == 'pause_all_normal': elif action_name == 'pause_all_normal':
action = sabnzbd.nzbqueue.NzbQueue.do.pause_on_prio # @UndefinedVariable action = sabnzbd.nzbqueue.NzbQueue.do.pause_on_prio
arguments = [NORMAL_PRIORITY] arguments = [NORMAL_PRIORITY]
elif action_name == 'pause_all_high': elif action_name == 'pause_all_high':
action = sabnzbd.nzbqueue.NzbQueue.do.pause_on_prio # @UndefinedVariable action = sabnzbd.nzbqueue.NzbQueue.do.pause_on_prio
arguments = [HIGH_PRIORITY] arguments = [HIGH_PRIORITY]
elif action_name == 'resume_all_low': elif action_name == 'resume_all_low':
action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio # @UndefinedVariable action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio
arguments = [LOW_PRIORITY] arguments = [LOW_PRIORITY]
elif action_name == 'resume_all_normal': elif action_name == 'resume_all_normal':
action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio # @UndefinedVariable action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio
arguments = [NORMAL_PRIORITY] arguments = [NORMAL_PRIORITY]
elif action_name == 'resume_all_high': elif action_name == 'resume_all_high':
action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio # @UndefinedVariable action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio
arguments = [HIGH_PRIORITY] arguments = [HIGH_PRIORITY]
else: else:
logging.warning(T('Unknown action: %s'), action_name) logging.warning(T('Unknown action: %s'), action_name)
@ -179,7 +179,7 @@ def init():
__SCHED.add_daytime_task(sabnzbd.misc.check_latest_version, 'VerCheck', d, None, (h, m), __SCHED.add_daytime_task(sabnzbd.misc.check_latest_version, 'VerCheck', d, None, (h, m),
kronos.method.sequential, [], None) kronos.method.sequential, [], None)
action, hour, minute = sabnzbd.bpsmeter.BPSMeter.do.get_quota() # @UndefinedVariable action, hour, minute = sabnzbd.bpsmeter.BPSMeter.do.get_quota()
if action: if action:
logging.info('Setting schedule for quota check daily at %s:%s', hour, minute) logging.info('Setting schedule for quota check daily at %s:%s', hour, minute)
__SCHED.add_daytime_task(action, 'quota_reset', range(1, 8), None, (hour, minute), __SCHED.add_daytime_task(action, 'quota_reset', range(1, 8), None, (hour, minute),
@ -212,7 +212,7 @@ def restart(force=False):
SCHEDULE_GUARD_FLAG = False SCHEDULE_GUARD_FLAG = False
stop() stop()
analyse(sabnzbd.downloader.Downloader.do.paused) # @UndefinedVariable analyse(sabnzbd.downloader.Downloader.do.paused)
init() init()
start() start()
@ -364,13 +364,13 @@ def analyse(was_paused=False, priority=None):
sabnzbd.pause_all() sabnzbd.pause_all()
else: else:
sabnzbd.unpause_all() sabnzbd.unpause_all()
sabnzbd.downloader.Downloader.do.set_paused_state(paused or paused_all) # @UndefinedVariable sabnzbd.downloader.Downloader.do.set_paused_state(paused or paused_all)
PostProcessor.do.paused = pause_post PostProcessor.do.paused = pause_post
if speedlimit is not None: if speedlimit is not None:
sabnzbd.downloader.Downloader.do.limit_speed(speedlimit) # @UndefinedVariable sabnzbd.downloader.Downloader.do.limit_speed(speedlimit)
sabnzbd.bpsmeter.BPSMeter.do.set_status(quota, action=False) # @UndefinedVariable sabnzbd.bpsmeter.BPSMeter.do.set_status(quota, action=False)
for serv in servers: for serv in servers:
try: try:
@ -378,7 +378,7 @@ def analyse(was_paused=False, priority=None):
value = servers[serv] value = servers[serv]
if bool(item.enable()) != bool(value): if bool(item.enable()) != bool(value):
item.enable.set(value) item.enable.set(value)
sabnzbd.downloader.Downloader.do.init_server(serv, serv) # @UndefinedVariable sabnzbd.downloader.Downloader.do.init_server(serv, serv)
except: except:
pass pass
config.save_config() config.save_config()
@ -415,7 +415,7 @@ def plan_resume(interval):
__PAUSE_END = time.time() + (interval * 60) __PAUSE_END = time.time() + (interval * 60)
logging.debug('Schedule resume at %s', __PAUSE_END) logging.debug('Schedule resume at %s', __PAUSE_END)
__SCHED.add_single_task(__oneshot_resume, '', interval * 60, kronos.method.sequential, [__PAUSE_END], None) __SCHED.add_single_task(__oneshot_resume, '', interval * 60, kronos.method.sequential, [__PAUSE_END], None)
sabnzbd.downloader.Downloader.do.pause() # @UndefinedVariable sabnzbd.downloader.Downloader.do.pause()
else: else:
__PAUSE_END = None __PAUSE_END = None
sabnzbd.unpause_all() sabnzbd.unpause_all()

6
sabnzbd/urlgrabber.py

@ -48,7 +48,7 @@ class URLGrabber(Thread):
def __init__(self): def __init__(self):
Thread.__init__(self) Thread.__init__(self)
self.queue = Queue.Queue() self.queue = Queue.Queue()
for tup in NzbQueue.do.get_urls(): # @UndefinedVariable for tup in NzbQueue.do.get_urls():
url, nzo = tup url, nzo = tup
self.queue.put((url, nzo)) self.queue.put((url, nzo))
self.shutdown = False self.shutdown = False
@ -217,7 +217,7 @@ class URLGrabber(Thread):
when = 300 when = 300
elif res == -1: elif res == -1:
# Error, but no reason to retry. Warning is already given # Error, but no reason to retry. Warning is already given
NzbQueue.do.remove(future_nzo.nzo_id, add_to_history=False) # @UndefinedVariable NzbQueue.do.remove(future_nzo.nzo_id, add_to_history=False)
continue continue
else: else:
logging.info('Unknown error fetching NZB, retry after 2 min %s', url) logging.info('Unknown error fetching NZB, retry after 2 min %s', url)
@ -309,4 +309,4 @@ def bad_fetch(nzo, url, msg='', content=False):
if cfg.email_endjob() > 0: if cfg.email_endjob() > 0:
emailer.badfetch_mail(msg, url) emailer.badfetch_mail(msg, url)
NzbQueue.do.remove(nzo.nzo_id, add_to_history=True) # @UndefinedVariable NzbQueue.do.remove(nzo.nzo_id, add_to_history=True)

4
sabnzbd/zconfig.py

@ -44,7 +44,7 @@ def hostname():
if sabnzbd.WIN32: if sabnzbd.WIN32:
return os.environ.get('computername', 'unknown') return os.environ.get('computername', 'unknown')
try: try:
return os.uname()[1] # @UndefinedVariable return os.uname()[1]
except: except:
return 'unknown' return 'unknown'
@ -97,7 +97,7 @@ def set_bonjour(host=None, port=None):
port=int(port), port=int(port),
txtRecord=pybonjour.TXTRecord({'path': '/sabnzbd/'}), txtRecord=pybonjour.TXTRecord({'path': '/sabnzbd/'}),
callBack=_zeroconf_callback) callBack=_zeroconf_callback)
except sabnzbd.utils.pybonjour.BonjourError: # @UndefinedVariable except sabnzbd.utils.pybonjour.BonjourError:
_BONJOUR_OBJECT = None _BONJOUR_OBJECT = None
logging.debug('Failed to start Bonjour service') logging.debug('Failed to start Bonjour service')
else: else:

Loading…
Cancel
Save