diff --git a/SABnzbd.py b/SABnzbd.py index d9b64bb..4f9b7b0 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -297,7 +297,7 @@ GNU GENERAL PUBLIC LICENSE Version 2 or (at your option) any later version. def daemonize(): try: - pid = os.fork() # @UndefinedVariable - only available in UNIX + pid = os.fork() if pid > 0: sys.exit(0) except OSError: @@ -305,13 +305,13 @@ def daemonize(): sys.exit(1) 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 prev = os.umask(0) os.umask(prev and int('077', 8)) try: - pid = os.fork() # @UndefinedVariable - only available in UNIX + pid = os.fork() if pid > 0: sys.exit(0) except OSError: @@ -1659,7 +1659,7 @@ def main(): sabnzbd.halt() cherrypy.engine.exit() sabnzbd.SABSTOP = True - if sabnzbd.downloader.Downloader.do.paused: # @UndefinedVariable + if sabnzbd.downloader.Downloader.do.paused: re_argv.append('-p') if autorestarted: re_argv.append('--autorestarted') @@ -1676,7 +1676,7 @@ def main(): logging.info(os.getpid()) os.system('kill -9 %s && open "%s"' % (os.getpid(), sabnzbd.MY_FULLNAME.replace("/Contents/MacOS/SABnzbd", ""))) else: - pid = os.fork() # @UndefinedVariable - only available in UNIX + pid = os.fork() if pid == 0: os.execv(sys.executable, args) elif sabnzbd.WIN_SERVICE and mail: diff --git a/sabnzbd/interface.py b/sabnzbd/interface.py index 715500c..50bed26 100644 --- a/sabnzbd/interface.py +++ b/sabnzbd/interface.py @@ -52,9 +52,9 @@ from sabnzbd.utils.servertests import test_nntp_server_dict from sabnzbd.constants import \ 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_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, \ - DEF_SKIN_COLORS, DEFAULT_PRIORITY + DEFAULT_PRIORITY from sabnzbd.lang import list_languages, set_language @@ -135,7 +135,7 @@ def rssRaiser(root, kwargs): def IsNone(value): """ 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): @@ -290,7 +290,7 @@ class MainPage(object): config.save_config() 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'] = 'Default' @@ -333,6 +333,7 @@ class MainPage(object): def add_handler(self, kwargs): if not check_access(): return Protected() + # TODO: cleanup id / addID / Plush id = kwargs.get('id', '') if not id: id = kwargs.get('url', '') @@ -516,7 +517,7 @@ class NzoPage(object): break 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 if 'bulk_operation' in args: @@ -631,12 +632,12 @@ class NzoPage(object): priority = kwargs.get('priority', None) nzo = sabnzbd.nzbqueue.get_nzo(nzo_id) - if index != None: + if index is not None: NzbQueue.do.switch(nzo_id, index) - if name != None: + if name is not None: 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) # Category changed, so make sure "Default" attributes aren't set again if script == 'Default': @@ -705,7 +706,7 @@ class QueuePage(object): dummy2 = kwargs.get('dummy2') 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.__dict__, start=start, limit=limit, dummy2=dummy2, trans=True, search=search) @@ -949,7 +950,7 @@ class HistoryPage(object): if failed_only is None: 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['failed_only'] = failed_only @@ -1153,7 +1154,7 @@ class ConfigPage(object): def index(self, **kwargs): if not check_access(): 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['cmdline'] = sabnzbd.CMDLINE @@ -1246,7 +1247,7 @@ class ConfigFolders(object): if cfg.configlock() or not check_access(): 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: conf[kw] = config.get_config('misc', kw)() @@ -1266,7 +1267,7 @@ class ConfigFolders(object): for kw in LIST_DIRPAGE: value = kwargs.get(kw) - if value != None: + if value is not None: value = platform_encode(value) if kw in ('complete_dir', 'dirscan_dir'): msg = config.get_config('misc', kw).set(value, create=True) @@ -1319,7 +1320,7 @@ class ConfigSwitches(object): if cfg.configlock() or not check_access(): 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_nice'] = bool(sabnzbd.newsunpack.NICE_COMMAND) @@ -1397,7 +1398,7 @@ class ConfigSpecial(object): if cfg.configlock() or not check_access(): 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 @@ -1454,21 +1455,21 @@ class ConfigGeneral(object): lst.append(col) return lst - def add_color(dir, color): - if dir: + def add_color(skin_dir, color): + if skin_dir: if not color: try: - color = DEF_SKIN_COLORS[dir.lower()] + color = DEF_SKIN_COLORS[skin_dir.lower()] except KeyError: - return dir - return '%s - %s' % (dir, color) + return skin_dir + return '%s - %s' % (skin_dir, color) else: return '' if cfg.configlock() or not check_access(): 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() @@ -1505,10 +1506,10 @@ class ConfigGeneral(object): conf['web_dir2'] = add_color(cfg.web_dir2(), cfg.web_color2()) conf['language'] = cfg.language() - list = list_languages() - if len(list) < 2: - list = [] - conf['lang_list'] = list + lang_list = list_languages() + if len(lang_list) < 2: + lang_list = [] + conf['lang_list'] = lang_list conf['disable_api_key'] = cfg.disable_key() conf['host'] = cfg.cherryhost() @@ -1581,10 +1582,10 @@ class ConfigGeneral(object): cfg.web_color2.set(web_color2) bandwidth_max = kwargs.get('bandwidth_max') - if bandwidth_max != None: + if bandwidth_max is not None: cfg.bandwidth_max.set(bandwidth_max) bandwidth_perc = kwargs.get('bandwidth_perc') - if bandwidth_perc != None: + if bandwidth_perc is not None: cfg.bandwidth_perc.set(bandwidth_perc) bandwidth_perc = cfg.bandwidth_perc() if bandwidth_perc and not bandwidth_max: @@ -1653,7 +1654,7 @@ class ConfigServer(object): if cfg.configlock() or not check_access(): 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 = [] servers = config.get_servers() @@ -1798,7 +1799,7 @@ def handle_server(kwargs, root=None, new_svr=False): def handle_server_test(kwargs, root): - result, msg = test_nntp_server_dict(kwargs) + _result, msg = test_nntp_server_dict(kwargs) return msg @@ -1820,7 +1821,7 @@ class ConfigRss(object): if cfg.configlock() or not check_access(): 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) pick_script = conf['script_list'] != [] @@ -2143,7 +2144,7 @@ class ConfigScheduling(object): if cfg.configlock() or not check_access(): 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.extend(_SCHED_ACTIONS) @@ -2292,7 +2293,7 @@ class ConfigCats(object): if cfg.configlock() or not check_access(): 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) @@ -2367,7 +2368,7 @@ class ConfigSorting(object): if cfg.configlock() or not check_access(): 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() for kw in SORT_LIST: @@ -2420,7 +2421,7 @@ class Status(object): def index(self, **kwargs): if not check_access(): 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 # header['blabla'] will be known as $blabla @@ -2455,7 +2456,7 @@ class Status(object): # Dashboard: Speed of Download directory: header['downloaddir'] = sabnzbd.cfg.download_dir.get_path() try: - sabnzbd.downloaddirspeed # The persistent var + sabnzbd.downloaddirspeed # The persistent var @UndefinedVariable except: # does not yet exist, so create it: sabnzbd.downloaddirspeed = -1 # -1 means ... not yet determined @@ -2463,14 +2464,14 @@ class Status(object): # Dashboard: Speed of Complete directory: header['completedir'] = sabnzbd.cfg.complete_dir.get_path() try: - sabnzbd.completedirspeed # The persistent var + sabnzbd.completedirspeed # The persistent var @UndefinedVariable except: # does not yet exist, so create it: sabnzbd.completedirspeed = -1 # -1 means ... not yet determined header['completedirspeed'] = sabnzbd.completedirspeed try: - sabnzbd.dashrefreshcounter # The persistent var + sabnzbd.dashrefreshcounter # The persistent var @UndefinedVariable except: sabnzbd.dashrefreshcounter = 0 header['dashrefreshcounter'] = sabnzbd.dashrefreshcounter @@ -2769,7 +2770,7 @@ class ConfigNotify(object): if cfg.configlock() or not check_access(): 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['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.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: item = Item() diff --git a/sabnzbd/misc.py b/sabnzbd/misc.py index a3c4de4..8da455b 100644 --- a/sabnzbd/misc.py +++ b/sabnzbd/misc.py @@ -234,16 +234,19 @@ def sanitize_filename(name): ext = lowext 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): """ Return foldername with dodgy chars converted to safe ones Remove any leading and trailing dot and space characters """ if not 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): illegal = uFL_ILLEGAL legal = uFL_LEGAL @@ -432,7 +435,7 @@ def windows_variant(): import _winreg vista_plus = x64 = False - maj, minor, buildno, plat, csd = GetVersionEx() + maj, _minor, _buildno, plat, _csd = GetVersionEx() if plat == VER_PLATFORM_WIN32_NT: vista_plus = maj > 5 @@ -444,7 +447,7 @@ def windows_variant(): key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment") 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': x64 = value.upper() == u'AMD64' break @@ -465,7 +468,7 @@ def get_serv_parms(service): try: key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, _SERVICE_KEY + service) 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: break _winreg.CloseKey(key) @@ -682,7 +685,7 @@ def exit_sab(value): sys.stdout.flush() if getattr(sys, 'frozen', None) == 'macosx_app': sabnzbd.SABSTOP = True - from PyObjCTools import AppHelper + from PyObjCTools import AppHelper # @UnresolvedImport AppHelper.stopEventLoop() sys.exit(value) @@ -1092,7 +1095,7 @@ else: 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: from OpenSSL import crypto from sabnzbd.utils.certgen import createKeyPair, createCertRequest, createCertificate, \ @@ -1263,10 +1266,9 @@ def format_source_url(url): prot = 'http:' return url -RE_URL = re.compile(r'://([^/]+)/') - def get_base_url(url): + RE_URL = re.compile(r'://([^/]+)/') m = RE_URL.search(url) if m: return m.group(1) @@ -1284,7 +1286,7 @@ def match_str(text, matches): def starts_with_path(path, prefix): """ Return True if 'path' starts with 'prefix', - considering case-sensitivity of filesystem + considering case-sensitivity of the file system """ if sabnzbd.WIN32: return clip_path(path).lower().startswith(prefix.lower()) @@ -1326,7 +1328,7 @@ def set_permissions(path, recursive=True): if os.path.isdir(path): if recursive: # 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) for name in files: 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): - """ 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 """ if sabnzbd.WIN32: diff --git a/sabnzbd/newsunpack.py b/sabnzbd/newsunpack.py index 7718d2b..9204b7f 100644 --- a/sabnzbd/newsunpack.py +++ b/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] if RAR_RE_V3.search(rar_set): 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].append(rar) diff --git a/sabnzbd/newswrapper.py b/sabnzbd/newswrapper.py index 589c598..e787e65 100644 --- a/sabnzbd/newswrapper.py +++ b/sabnzbd/newswrapper.py @@ -108,7 +108,7 @@ def GetServerParms(host, port): try: # Standard IPV4 or IPV6 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 # So return all IP addresses, no matter IPv4 or IPv6: return ips @@ -116,7 +116,7 @@ def GetServerParms(host, port): # 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]] 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 IPV6 explicitly return socket.getaddrinfo(host, port, socket.AF_INET6, @@ -181,12 +181,14 @@ def probablyipv4(ip): else: return False + def probablyipv6(ip): - if ip.count(':') >= 2 and re.sub('[0123456789abcdefABCDEF:]', '', ip) == '' : + if ip.count(':') >= 2 and re.sub('[0123456789abcdefABCDEF:]', '', ip) == '': return True else: return False + class NNTP(object): 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] - # there wil 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 probablyipv6(host): af = socket.AF_INET6 + # 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 probablyipv6(host): + af = socket.AF_INET6 if sslenabled and _ssl: ctx = _ssl.Context(_SSL_TYPES.get(ssl_type, _ssl.TLSv1_METHOD)) diff --git a/sabnzbd/nzbqueue.py b/sabnzbd/nzbqueue.py index 3c560ef..8e82717 100644 --- a/sabnzbd/nzbqueue.py +++ b/sabnzbd/nzbqueue.py @@ -283,7 +283,7 @@ class NzbQueue(TryList): sabnzbd.remove_data(nzo_id, future.workpath) logging.info("Regenerating item: %s", nzo_id) r, u, d = future.repair_opts - if not r is None: + if r is not None: pp = sabnzbd.opts_to_pp(r, u, d) scr = future.script if scr is None: @@ -596,7 +596,7 @@ class NzbQueue(TryList): @synchronized(NZBQUEUE_LOCK) def move_up_bulk(self, nzo_id, nzf_ids, size): 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) @synchronized(NZBQUEUE_LOCK) @@ -607,7 +607,7 @@ class NzbQueue(TryList): @synchronized(NZBQUEUE_LOCK) def move_down_bulk(self, nzo_id, nzf_ids, size): 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) @synchronized(NZBQUEUE_LOCK) @@ -646,7 +646,7 @@ class NzbQueue(TryList): elif field.lower() == 'avg_age': self.sort_by_avg_age(reverse) else: - logging.debug("Sort: %s not recognised", field) + logging.debug("Sort: %s not recognized", field) def __set_priority(self, nzo_id, priority): """ 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: nzo.save_to_disk() # Check result - enough, ratio = nzo.check_quality() + enough, _ratio = nzo.check_quality() if enough: # Enough data present, do real download - workdir = nzo.downpath + _workdir = nzo.downpath self.cleanup_nzo(nzo, keep_basic=True) self.send_back(nzo) return diff --git a/sabnzbd/nzbstuff.py b/sabnzbd/nzbstuff.py index 6ef5a43..7b98a03 100644 --- a/sabnzbd/nzbstuff.py +++ b/sabnzbd/nzbstuff.py @@ -1259,7 +1259,7 @@ class NzbObject(TryList): self.files.remove(nzf) # If cleanup emptied the active files list, end this job if nzf_remove_list and not self.files: - sabnzbd.NzbQueue.do.end_job(self) # @UndefinedVariable + sabnzbd.NzbQueue.do.end_job(self) if not article: # No articles for this server, block for next time @@ -1343,7 +1343,7 @@ class NzbObject(TryList): fields = {} for k in rating_types: 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: pass diff --git a/sabnzbd/osxmenu.py b/sabnzbd/osxmenu.py index d8fced3..0861c42 100644 --- a/sabnzbd/osxmenu.py +++ b/sabnzbd/osxmenu.py @@ -110,7 +110,7 @@ class SABnzbdDelegate(NSObject): # Variables self.state = "Idle" try: - self.speed = sabnzbd.downloader.Downloader.do.get_limit() # @UndefinedVariable + self.speed = sabnzbd.downloader.Downloader.do.get_limit() except: self.speed = 0 self.version_notify = 1 @@ -500,7 +500,7 @@ class SABnzbdDelegate(NSObject): def iconUpdate(self): try: - if sabnzbd.downloader.Downloader.do.paused: # @UndefinedVariable + if sabnzbd.downloader.Downloader.do.paused: self.status_item.setImage_(self.icons['pause']) else: self.status_item.setImage_(self.icons['idle']) @@ -509,7 +509,7 @@ class SABnzbdDelegate(NSObject): def pauseUpdate(self): try: - if sabnzbd.downloader.Downloader.do.paused: # @UndefinedVariable + if sabnzbd.downloader.Downloader.do.paused: if self.isLeopard: self.resume_menu_item.setHidden_(NO) self.pause_menu_item.setHidden_(YES) @@ -528,7 +528,7 @@ class SABnzbdDelegate(NSObject): def speedlimitUpdate(self): try: - speed = int(sabnzbd.downloader.Downloader.do.get_limit()) # @UndefinedVariable + speed = int(sabnzbd.downloader.Downloader.do.get_limit()) if self.speed != speed: self.speed = speed speedsValues = self.menu_speed.numberOfItems() @@ -685,14 +685,14 @@ class SABnzbdDelegate(NSObject): # logging.info("[osx] speed limit to %s" % (sender.representedObject())) speed = int(sender.representedObject()) if speed != self.speed: - sabnzbd.downloader.Downloader.do.limit_speed(speed) # @UndefinedVariable + sabnzbd.downloader.Downloader.do.limit_speed(speed) self.speedlimitUpdate() def purgeAction_(self, sender): mode = sender.representedObject() # logging.info("[osx] purge %s" % (mode)) if mode == "queue": - NzbQueue.do.remove_all() # @UndefinedVariable + NzbQueue.do.remove_all() elif mode == "history": if not self.history_db: self.history_db = sabnzbd.database.get_history_handle() @@ -704,7 +704,7 @@ class SABnzbdDelegate(NSObject): if minutes: scheduler.plan_resume(minutes) else: - sabnzbd.downloader.Downloader.do.pause() # @UndefinedVariable + sabnzbd.downloader.Downloader.do.pause() def resumeAction_(self, sender): scheduler.plan_resume(0) diff --git a/sabnzbd/postproc.py b/sabnzbd/postproc.py index 9befc8d..f38b6b7 100644 --- a/sabnzbd/postproc.py +++ b/sabnzbd/postproc.py @@ -183,7 +183,7 @@ class PostProcessor(Thread): # Pause downloader, if users wants that if cfg.pause_on_post_processing(): - sabnzbd.downloader.Downloader.do.wait_for_postproc() # @UndefinedVariable + sabnzbd.downloader.Downloader.do.wait_for_postproc() self.__busy = True process_job(nzo) @@ -191,7 +191,7 @@ class PostProcessor(Thread): check_eoq = True # Allow download to proceed - sabnzbd.downloader.Downloader.do.resume_from_postproc() # @UndefinedVariable + sabnzbd.downloader.Downloader.do.resume_from_postproc() def process_job(nzo): @@ -495,13 +495,13 @@ def process_job(nzo): # Update indexer with results if cfg.rating_enable(): 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: - 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: hosts = [None] 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 if all_ok: @@ -545,7 +545,7 @@ def process_job(nzo): # Clean up the NZO try: 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: logging.error(T('Cleanup of %s failed.'), nzo.final_name) logging.info("Traceback: ", exc_info=True) @@ -616,7 +616,7 @@ def parring(nzo, workdir): if nzo.priority != TOP_PRIORITY: nzo.priority = REPAIR_PRIORITY 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) @@ -670,7 +670,7 @@ def addPrefixes(path, dirprefix): def handle_empty_queue(): """ 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() logging.info("Queue has finished, launching: %s (%s)", sabnzbd.QUEUECOMPLETEACTION, sabnzbd.QUEUECOMPLETEARG) diff --git a/sabnzbd/sabtray.py b/sabnzbd/sabtray.py index 104478c..74b9a13 100644 --- a/sabnzbd/sabtray.py +++ b/sabnzbd/sabtray.py @@ -170,7 +170,7 @@ class SABTrayThread(SysTrayIconThread): # adapted from interface.py def pause(self): scheduler.plan_resume(0) - Downloader.do.pause() # @UndefinedVariable + Downloader.do.pause() # adapted from interface.py def resume(self): diff --git a/sabnzbd/scheduler.py b/sabnzbd/scheduler.py index 2ea3db5..3ce0a11 100644 --- a/sabnzbd/scheduler.py +++ b/sabnzbd/scheduler.py @@ -94,7 +94,7 @@ def init(): action = scheduled_resume arguments = [] elif action_name == 'pause': - action = sabnzbd.downloader.Downloader.do.pause # @UndefinedVariable + action = sabnzbd.downloader.Downloader.do.pause arguments = [] elif action_name == 'pause_all': action = sabnzbd.pause_all @@ -110,7 +110,7 @@ def init(): elif action_name == 'resume_post': action = pp_resume 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 != []: action = sabnzbd.enable_server elif action_name == 'disable_server' and arguments != []: @@ -123,28 +123,28 @@ def init(): elif action_name == 'remove_failed': action = sabnzbd.api.history_remove_failed elif action_name == 'enable_quota': - action = sabnzbd.bpsmeter.BPSMeter.do.set_status # @UndefinedVariable + action = sabnzbd.bpsmeter.BPSMeter.do.set_status arguments = [True] elif action_name == 'disable_quota': - action = sabnzbd.bpsmeter.BPSMeter.do.set_status # @UndefinedVariable + action = sabnzbd.bpsmeter.BPSMeter.do.set_status arguments = [False] 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] 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] 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] 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] 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] 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] else: 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), 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: 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), @@ -212,7 +212,7 @@ def restart(force=False): SCHEDULE_GUARD_FLAG = False stop() - analyse(sabnzbd.downloader.Downloader.do.paused) # @UndefinedVariable + analyse(sabnzbd.downloader.Downloader.do.paused) init() start() @@ -364,13 +364,13 @@ def analyse(was_paused=False, priority=None): sabnzbd.pause_all() else: 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 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: try: @@ -378,7 +378,7 @@ def analyse(was_paused=False, priority=None): value = servers[serv] if bool(item.enable()) != bool(value): item.enable.set(value) - sabnzbd.downloader.Downloader.do.init_server(serv, serv) # @UndefinedVariable + sabnzbd.downloader.Downloader.do.init_server(serv, serv) except: pass config.save_config() @@ -415,7 +415,7 @@ def plan_resume(interval): __PAUSE_END = time.time() + (interval * 60) logging.debug('Schedule resume at %s', __PAUSE_END) __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: __PAUSE_END = None sabnzbd.unpause_all() diff --git a/sabnzbd/urlgrabber.py b/sabnzbd/urlgrabber.py index e476a0c..d83fc27 100644 --- a/sabnzbd/urlgrabber.py +++ b/sabnzbd/urlgrabber.py @@ -48,7 +48,7 @@ class URLGrabber(Thread): def __init__(self): Thread.__init__(self) self.queue = Queue.Queue() - for tup in NzbQueue.do.get_urls(): # @UndefinedVariable + for tup in NzbQueue.do.get_urls(): url, nzo = tup self.queue.put((url, nzo)) self.shutdown = False @@ -217,7 +217,7 @@ class URLGrabber(Thread): when = 300 elif res == -1: # 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 else: 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: 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) diff --git a/sabnzbd/zconfig.py b/sabnzbd/zconfig.py index 29f9967..22221fa 100644 --- a/sabnzbd/zconfig.py +++ b/sabnzbd/zconfig.py @@ -44,7 +44,7 @@ def hostname(): if sabnzbd.WIN32: return os.environ.get('computername', 'unknown') try: - return os.uname()[1] # @UndefinedVariable + return os.uname()[1] except: return 'unknown' @@ -97,7 +97,7 @@ def set_bonjour(host=None, port=None): port=int(port), txtRecord=pybonjour.TXTRecord({'path': '/sabnzbd/'}), callBack=_zeroconf_callback) - except sabnzbd.utils.pybonjour.BonjourError: # @UndefinedVariable + except sabnzbd.utils.pybonjour.BonjourError: _BONJOUR_OBJECT = None logging.debug('Failed to start Bonjour service') else: