Safihre 4 years ago
parent
commit
86c0f7e864
  1. 2
      sabnzbd/dirscanner.py
  2. 3
      sabnzbd/downloader.py
  3. 4
      sabnzbd/interface.py
  4. 4
      sabnzbd/newsunpack.py
  5. 2
      sabnzbd/nzbparser.py
  6. 10
      sabnzbd/nzbstuff.py
  7. 2
      sabnzbd/osxmenu.py
  8. 2
      sabnzbd/postproc.py
  9. 5
      sabnzbd/rss.py
  10. 4
      sabnzbd/sorting.py

2
sabnzbd/dirscanner.py

@ -46,7 +46,7 @@ def compare_stat_tuple(tup1, tup2):
def clean_file_list(inp_list, folder, files): def clean_file_list(inp_list, folder, files):
""" Remove elements of "inp_list" not found in "files" """ """ Remove elements of "inp_list" not found in "files" """
for path in sorted(inp_list.keys()): for path in sorted(inp_list):
fld, name = os.path.split(path) fld, name = os.path.split(path)
if fld == folder: if fld == folder:
present = False present = False

3
sabnzbd/downloader.py

@ -914,7 +914,8 @@ class Downloader(Thread):
# Clean expired timers # Clean expired timers
now = time.time() now = time.time()
kicked = [] kicked = []
for server_id in self._timers.keys(): # Create a copy so we can remove during iteration
for server_id in list(self._timers):
if not [stamp for stamp in self._timers[server_id] if stamp >= now]: if not [stamp for stamp in self._timers[server_id] if stamp >= now]:
logging.debug("Forcing re-evaluation of server-id %s", server_id) logging.debug("Forcing re-evaluation of server-id %s", server_id)
del self._timers[server_id] del self._timers[server_id]

4
sabnzbd/interface.py

@ -529,7 +529,7 @@ class Wizard:
else: else:
# Sort servers to get the first enabled one # Sort servers to get the first enabled one
server_names = sorted( server_names = sorted(
servers.keys(), servers,
key=lambda svr: "%d%02d%s" key=lambda svr: "%d%02d%s"
% (int(not servers[svr].enable()), servers[svr].priority(), servers[svr].displayname().lower()), % (int(not servers[svr].enable()), servers[svr].priority(), servers[svr].displayname().lower()),
) )
@ -1580,7 +1580,7 @@ class ConfigServer:
new = [] new = []
servers = config.get_servers() servers = config.get_servers()
server_names = sorted( server_names = sorted(
list(servers.keys()), servers,
key=lambda svr: "%d%02d%s" key=lambda svr: "%d%02d%s"
% (int(not servers[svr].enable()), servers[svr].priority(), servers[svr].displayname().lower()), % (int(not servers[svr].enable()), servers[svr].priority(), servers[svr].displayname().lower()),
) )

4
sabnzbd/newsunpack.py

@ -1350,7 +1350,7 @@ def PAR_Verify(parfile, nzo, setname, joinables, single=False):
block_table[nzf.blocks] = nzf block_table[nzf.blocks] = nzf
if block_table: if block_table:
nzf = block_table[min(block_table.keys())] nzf = block_table[min(block_table)]
logging.info("Found new par2file %s", nzf.filename) logging.info("Found new par2file %s", nzf.filename)
# Move from extrapar list to files to be downloaded # Move from extrapar list to files to be downloaded
@ -1650,7 +1650,7 @@ def MultiPar_Verify(parfile, nzo, setname, joinables, single=False):
block_table[nzf.blocks] = nzf block_table[nzf.blocks] = nzf
if block_table: if block_table:
nzf = block_table[min(block_table.keys())] nzf = block_table[min(block_table)]
logging.info("Found new par2file %s", nzf.filename) logging.info("Found new par2file %s", nzf.filename)
# Move from extrapar list to files to be downloaded # Move from extrapar list to files to be downloaded

2
sabnzbd/nzbparser.py

@ -118,7 +118,7 @@ def nzbfile_parser(raw_data, nzo):
pass pass
# Sort the articles by part number, compatible with Python 3.5 # Sort the articles by part number, compatible with Python 3.5
raw_article_db_sorted = [raw_article_db[partnum] for partnum in sorted(raw_article_db.keys())] raw_article_db_sorted = [raw_article_db[partnum] for partnum in sorted(raw_article_db)]
# Create NZF # Create NZF
nzf = sabnzbd.nzbstuff.NzbFile(file_date, file_name, raw_article_db_sorted, file_bytes, nzo) nzf = sabnzbd.nzbstuff.NzbFile(file_date, file_name, raw_article_db_sorted, file_bytes, nzo)

10
sabnzbd/nzbstuff.py

@ -383,7 +383,7 @@ class NzbFile(TryList):
if raw_article_db: if raw_article_db:
# Convert 2.x.x jobs # Convert 2.x.x jobs
if isinstance(raw_article_db, dict): if isinstance(raw_article_db, dict):
raw_article_db = [raw_article_db[partnum] for partnum in sorted(raw_article_db.keys())] raw_article_db = [raw_article_db[partnum] for partnum in sorted(raw_article_db)]
for raw_article in raw_article_db: for raw_article in raw_article_db:
self.add_article(raw_article) self.add_article(raw_article)
@ -473,7 +473,7 @@ class NzbFile(TryList):
# Convert 2.x.x jobs # Convert 2.x.x jobs
if isinstance(self.decodetable, dict): if isinstance(self.decodetable, dict):
self.decodetable = [self.decodetable[partnum] for partnum in sorted(self.decodetable.keys())] self.decodetable = [self.decodetable[partnum] for partnum in sorted(self.decodetable)]
# Set non-transferable values # Set non-transferable values
self.md5 = None self.md5 = None
@ -1493,7 +1493,7 @@ class NzbObject(TryList):
# Sort the servers first # Sort the servers first
servers = config.get_servers() servers = config.get_servers()
server_names = sorted( server_names = sorted(
servers.keys(), servers,
key=lambda svr: "%d%02d%s" key=lambda svr: "%d%02d%s"
% (int(not servers[svr].enable()), servers[svr].priority(), servers[svr].displayname().lower()), % (int(not servers[svr].enable()), servers[svr].priority(), servers[svr].displayname().lower()),
) )
@ -1609,7 +1609,7 @@ class NzbObject(TryList):
pos_nzf_table = self.build_pos_nzf_table(nzf_ids) pos_nzf_table = self.build_pos_nzf_table(nzf_ids)
keys = list(pos_nzf_table.keys()) keys = list(pos_nzf_table)
keys.sort() keys.sort()
if target == keys: if target == keys:
@ -1626,7 +1626,7 @@ class NzbObject(TryList):
pos_nzf_table = self.build_pos_nzf_table(nzf_ids) pos_nzf_table = self.build_pos_nzf_table(nzf_ids)
keys = list(pos_nzf_table.keys()) keys = list(pos_nzf_table)
keys.sort() keys.sort()
if target == keys: if target == keys:

2
sabnzbd/osxmenu.py

@ -234,7 +234,7 @@ class SABnzbdDelegate(NSObject):
100: "100%", 100: "100%",
} }
for speed in sorted(speeds.keys()): for speed in sorted(speeds):
menu_speed_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( menu_speed_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
"%s" % (speeds[speed]), "speedlimitAction:", "" "%s" % (speeds[speed]), "speedlimitAction:", ""
) )

2
sabnzbd/postproc.py

@ -962,7 +962,7 @@ def rar_renamer(nzo, workdir):
# So, all rar files with rarvolnr 1, find the contents (files inside the rar), # So, all rar files with rarvolnr 1, find the contents (files inside the rar),
# and match with rarfiles with rarvolnr 2, and put them in the correct rarset. # and match with rarfiles with rarvolnr 2, and put them in the correct rarset.
# And so on, until the highest rarvolnr minus 1 matched against highest rarvolnr # And so on, until the highest rarvolnr minus 1 matched against highest rarvolnr
for n in range(1, len(rarvolnr.keys())): for n in range(1, len(rarvolnr)):
logging.debug("Deobfuscate: Finding matches between rar sets %s and %s" % (n, n + 1)) logging.debug("Deobfuscate: Finding matches between rar sets %s and %s" % (n, n + 1))
for base_obfuscated_filename in rarvolnr[n]: for base_obfuscated_filename in rarvolnr[n]:
matchcounter = 0 matchcounter = 0

5
sabnzbd/rss.py

@ -151,8 +151,7 @@ def remove_obsolete(jobs, new_jobs):
""" """
now = time.time() now = time.time()
limit = now - 259200 # 3days (3x24x3600) limit = now - 259200 # 3days (3x24x3600)
olds = list(jobs.keys()) for old in list(jobs):
for old in olds:
tm = jobs[old]["time"] tm = jobs[old]["time"]
if old not in new_jobs: if old not in new_jobs:
if jobs[old].get("status", " ")[0] in ("G", "B"): if jobs[old].get("status", " ")[0] in ("G", "B"):
@ -178,7 +177,7 @@ class RSSQueue:
self.jobs = sabnzbd.load_admin(RSS_FILE_NAME) self.jobs = sabnzbd.load_admin(RSS_FILE_NAME)
if self.jobs: if self.jobs:
for feed in self.jobs: for feed in self.jobs:
remove_obsolete(self.jobs[feed], list(self.jobs[feed].keys())) remove_obsolete(self.jobs[feed], list(self.jobs[feed]))
except: except:
logging.warning(T("Cannot read %s"), RSS_FILE_NAME) logging.warning(T("Cannot read %s"), RSS_FILE_NAME)
logging.info("Traceback: ", exc_info=True) logging.info("Traceback: ", exc_info=True)

4
sabnzbd/sorting.py

@ -532,7 +532,7 @@ def check_for_sequence(regex, files):
prefix = name[: match1.start()] prefix = name[: match1.start()]
# Don't do anything if only one or no files matched # Don't do anything if only one or no files matched
if len(list(matches.keys())) < 2: if len(list(matches)) < 2:
return {} return {}
key_prev = 0 key_prev = 0
@ -540,7 +540,7 @@ def check_for_sequence(regex, files):
alphabet = "abcdefghijklmnopqrstuvwxyz" alphabet = "abcdefghijklmnopqrstuvwxyz"
# Check the dictionary to see if the keys are in a numeric or alphabetic sequence # Check the dictionary to see if the keys are in a numeric or alphabetic sequence
for akey in sorted(matches.keys()): for akey in sorted(matches):
if akey.isdigit(): if akey.isdigit():
key = int(akey) key = int(akey)
elif akey in alphabet: elif akey in alphabet:

Loading…
Cancel
Save