Browse Source

Remove redundant parentheses

pull/1182/head
Safihre 7 years ago
parent
commit
7a7ce47769
  1. 30
      SABnzbd.py
  2. 8
      sabnzbd/__init__.py
  3. 10
      sabnzbd/api.py
  4. 6
      sabnzbd/assembler.py
  5. 2
      sabnzbd/constants.py
  6. 4
      sabnzbd/database.py
  7. 2
      sabnzbd/decoder.py
  8. 8
      sabnzbd/directunpacker.py
  9. 2
      sabnzbd/interface.py
  10. 12
      sabnzbd/misc.py
  11. 4
      sabnzbd/newsunpack.py
  12. 28
      sabnzbd/newswrapper.py
  13. 2
      sabnzbd/notifier.py
  14. 8
      sabnzbd/nzbqueue.py
  15. 10
      sabnzbd/nzbstuff.py
  16. 8
      sabnzbd/osxmenu.py
  17. 2
      sabnzbd/sorting.py
  18. 3
      sabnzbd/utils/certgen.py
  19. 2
      sabnzbd/utils/checkdir.py
  20. 2
      sabnzbd/utils/getperformance.py
  21. 12
      scripts/Deobfuscate.py
  22. 2
      tools/extract_pot.py

30
SABnzbd.py

@ -659,12 +659,12 @@ def attach_server(host, port, cert=None, key=None, chain=None):
def is_sabnzbd_running(url): def is_sabnzbd_running(url):
""" Return True when there's already a SABnzbd instance running. """ """ Return True when there's already a SABnzbd instance running. """
try: try:
url = '%s&mode=version' % (url) url = '%s&mode=version' % url
# Do this without certificate verification, few installations will have that # Do this without certificate verification, few installations will have that
prev = sabnzbd.set_https_verification(False) prev = sabnzbd.set_https_verification(False)
ver = get_from_url(url) ver = get_from_url(url)
sabnzbd.set_https_verification(prev) sabnzbd.set_https_verification(prev)
return (ver and (re.search(r'\d+\.\d+\.', ver) or ver.strip() == sabnzbd.__version__)) return ver and (re.search(r'\d+\.\d+\.', ver) or ver.strip() == sabnzbd.__version__)
except: except:
return False return False
@ -864,9 +864,9 @@ def main():
elif opt in ('-b', '--browser'): elif opt in ('-b', '--browser'):
try: try:
autobrowser = bool(int(arg)) autobrowser = bool(int(arg))
except: except ValueError:
autobrowser = True autobrowser = True
elif opt in ('--autorestarted', ): elif opt == '--autorestarted':
autorestarted = True autorestarted = True
elif opt in ('-c', '--clean'): elif opt in ('-c', '--clean'):
clean_up = True clean_up = True
@ -885,36 +885,36 @@ def main():
exit_sab(0) exit_sab(0)
elif opt in ('-p', '--pause'): elif opt in ('-p', '--pause'):
pause = True pause = True
elif opt in ('--https',): elif opt == '--https':
https_port = int(arg) https_port = int(arg)
sabnzbd.RESTART_ARGS.append(opt) sabnzbd.RESTART_ARGS.append(opt)
sabnzbd.RESTART_ARGS.append(arg) sabnzbd.RESTART_ARGS.append(arg)
elif opt in ('--repair',): elif opt == '--repair':
repair = 1 repair = 1
pause = True pause = True
elif opt in ('--repair-all',): elif opt == '--repair-all':
repair = 2 repair = 2
pause = True pause = True
elif opt in ('--log-all',): elif opt == '--log-all':
sabnzbd.LOG_ALL = True sabnzbd.LOG_ALL = True
elif opt in ('--disable-file-log'): elif opt == '--disable-file-log':
no_file_log = True no_file_log = True
elif opt in ('--no-login',): elif opt == '--no-login':
no_login = True no_login = True
elif opt in ('--pid',): elif opt == '--pid':
pid_path = arg pid_path = arg
sabnzbd.RESTART_ARGS.append(opt) sabnzbd.RESTART_ARGS.append(opt)
sabnzbd.RESTART_ARGS.append(arg) sabnzbd.RESTART_ARGS.append(arg)
elif opt in ('--pidfile',): elif opt == '--pidfile':
pid_file = arg pid_file = arg
sabnzbd.RESTART_ARGS.append(opt) sabnzbd.RESTART_ARGS.append(opt)
sabnzbd.RESTART_ARGS.append(arg) sabnzbd.RESTART_ARGS.append(arg)
elif opt in ('--new',): elif opt == '--new':
new_instance = True new_instance = True
elif opt in ('--console',): elif opt == '--console':
sabnzbd.RESTART_ARGS.append(opt) sabnzbd.RESTART_ARGS.append(opt)
osx_console = True osx_console = True
elif opt in ('--ipv6_hosting',): elif opt == '--ipv6_hosting':
ipv6_hosting = arg ipv6_hosting = arg
sabnzbd.MY_FULLNAME = os.path.normpath(os.path.abspath(sabnzbd.MY_FULLNAME)) sabnzbd.MY_FULLNAME = os.path.normpath(os.path.abspath(sabnzbd.MY_FULLNAME))

8
sabnzbd/__init__.py

@ -1008,12 +1008,12 @@ def pp_to_opts(pp):
# Convert the pp to an int # Convert the pp to an int
pp = sabnzbd.interface.int_conv(pp) pp = sabnzbd.interface.int_conv(pp)
if pp == 0: if pp == 0:
return (False, False, False) return False, False, False
if pp == 1: if pp == 1:
return (True, False, False) return True, False, False
if pp == 2: if pp == 2:
return (True, True, False) return True, True, False
return (True, True, True) return True, True, True
def opts_to_pp(repair, unpack, delete): def opts_to_pp(repair, unpack, delete):

10
sabnzbd/api.py

@ -1350,10 +1350,10 @@ def build_queue(start=0, limit=0, trans=False, output=None, search=None):
# Ensure compatibility of API status # Ensure compatibility of API status
if status == Status.DELETED or priority == TOP_PRIORITY: if status == Status.DELETED or priority == TOP_PRIORITY:
status = Status.DOWNLOADING status = Status.DOWNLOADING
slot['status'] = "%s" % (status) slot['status'] = "%s" % status
if (Downloader.do.paused or Downloader.do.postproc or is_propagating or \ if (Downloader.do.paused or Downloader.do.postproc or is_propagating or
status not in (Status.DOWNLOADING, Status.FETCHING, Status.QUEUED)) and priority != TOP_PRIORITY: status not in (Status.DOWNLOADING, Status.FETCHING, Status.QUEUED)) and priority != TOP_PRIORITY:
slot['timeleft'] = '0:00:00' slot['timeleft'] = '0:00:00'
slot['eta'] = 'unknown' slot['eta'] = 'unknown'
else: else:
@ -1705,7 +1705,7 @@ def build_queue_header(search=None, start=0, limit=0, output=None):
except: except:
header['eta'] = T('unknown') header['eta'] = T('unknown')
return (header, qnfo.list, bytespersec, qnfo.q_fullsize, qnfo.bytes_left_previous_page) return header, qnfo.list, bytespersec, qnfo.q_fullsize, qnfo.bytes_left_previous_page
def build_history(start=None, limit=None, verbose=False, verbose_list=None, search=None, failed_only=0, def build_history(start=None, limit=None, verbose=False, verbose_list=None, search=None, failed_only=0,
@ -1858,7 +1858,7 @@ def build_history(start=None, limit=None, verbose=False, verbose_list=None, sear
if close_db: if close_db:
history_db.close() history_db.close()
return (items, fetched_items, total_items) return items, fetched_items, total_items
def get_active_history(queue=None, items=None): def get_active_history(queue=None, items=None):

6
sabnzbd/assembler.py

@ -334,11 +334,11 @@ def nzo_filtered_by_rating(nzo):
nzo.rating_filtered = 1 nzo.rating_filtered = 1
reason = rating_filtered(rating, nzo.filename.lower(), True) reason = rating_filtered(rating, nzo.filename.lower(), True)
if reason is not None: if reason is not None:
return (2, reason) return 2, reason
reason = rating_filtered(rating, nzo.filename.lower(), False) reason = rating_filtered(rating, nzo.filename.lower(), False)
if reason is not None: if reason is not None:
return (1, reason) return 1, reason
return (0, "") return 0, ""
def rating_filtered(rating, filename, abort): def rating_filtered(rating, filename, abort):

2
sabnzbd/constants.py

@ -123,7 +123,7 @@ year_match = r'[\W]([1|2]\d{3})([^\w]|$)' # Something '(YYYY)' or '.YYYY.' or '
sample_match = r'((^|[\W_])(sample|proof))' # something-sample or something-proof sample_match = r'((^|[\W_])(sample|proof))' # something-sample or something-proof
class Status(): class Status:
COMPLETED = 'Completed' # PP: Job is finished COMPLETED = 'Completed' # PP: Job is finished
CHECKING = 'Checking' # Q: Pre-check is running CHECKING = 'Checking' # Q: Pre-check is running
DOWNLOADING = 'Downloading' # Q: Normal downloading DOWNLOADING = 'Downloading' # Q: Normal downloading

4
sabnzbd/database.py

@ -314,7 +314,7 @@ class HistoryDB(object):
# Stage Name is separated by ::: stage lines by ; and stages by \r\n # Stage Name is separated by ::: stage lines by ; and stages by \r\n
items = [unpack_history_info(item) for item in items] items = [unpack_history_info(item) for item in items]
return (items, fetched_items, total_items) return items, fetched_items, total_items
def have_episode(self, series, season, episode): def have_episode(self, series, season, episode):
""" Check whether History contains this series episode """ """ Check whether History contains this series episode """
@ -375,7 +375,7 @@ class HistoryDB(object):
except AttributeError: except AttributeError:
pass pass
return (total, month, week) return total, month, week
def get_script_log(self, nzo_id): def get_script_log(self, nzo_id):
""" Return decompressed log file """ """ Return decompressed log file """

2
sabnzbd/decoder.py

@ -378,7 +378,7 @@ def yCheck(data):
except IndexError: except IndexError:
break break
return ((ybegin, ypart, yend), data) return (ybegin, ypart, yend), data
# Example: =ybegin part=1 line=128 size=123 name=-=DUMMY=- abc.par # Example: =ybegin part=1 line=128 size=123 name=-=DUMMY=- abc.par
YSPLIT_RE = re.compile(r'([a-zA-Z0-9]+)=') YSPLIT_RE = re.compile(r'([a-zA-Z0-9]+)=')

8
sabnzbd/directunpacker.py

@ -176,10 +176,10 @@ class DirectUnpacker(threading.Thread):
break break
# Error? Let PP-handle it # Error? Let PP-handle it
if linebuf.endswith(('ERROR: ', 'Cannot create', 'in the encrypted file', 'CRC failed', \ if linebuf.endswith(('ERROR: ', 'Cannot create', 'in the encrypted file', 'CRC failed',
'checksum failed', 'You need to start extraction from a previous volume', \ 'checksum failed', 'You need to start extraction from a previous volume',
'password is incorrect', 'Write error', 'checksum error', \ 'password is incorrect', 'Write error', 'checksum error',
'start extraction from a previous volume')): 'start extraction from a previous volume')):
logging.info('Error in DirectUnpack of %s', self.cur_setname) logging.info('Error in DirectUnpack of %s', self.cur_setname)
self.abort() self.abort()

2
sabnzbd/interface.py

@ -2765,7 +2765,7 @@ def rss_history(url, limit=50, search=None):
stageLine.append("<tr><dt>Stage %s</dt>" % stage['name']) stageLine.append("<tr><dt>Stage %s</dt>" % stage['name'])
actions = [] actions = []
for action in stage['actions']: for action in stage['actions']:
actions.append("<dd>%s</dd>" % (action)) actions.append("<dd>%s</dd>" % action)
actions.sort() actions.sort()
actions.reverse() actions.reverse()
for act in actions: for act in actions:

12
sabnzbd/misc.py

@ -427,7 +427,7 @@ def is_obfuscated_filename(filename):
""" Check if this file has an extension, if not, it's """ Check if this file has an extension, if not, it's
probably obfuscated and we don't use it probably obfuscated and we don't use it
""" """
return (os.path.splitext(filename)[1] == '') return os.path.splitext(filename)[1] == ''
############################################################################## ##############################################################################
@ -519,16 +519,16 @@ def create_real_path(name, loc, path, umask=False, writable=True):
logging.info('%s directory: %s does not exist, try to create it', name, my_dir) logging.info('%s directory: %s does not exist, try to create it', name, my_dir)
if not create_all_dirs(my_dir, umask): if not create_all_dirs(my_dir, umask):
logging.error(T('Cannot create directory %s'), clip_path(my_dir)) logging.error(T('Cannot create directory %s'), clip_path(my_dir))
return (False, my_dir) return False, my_dir
checks = (os.W_OK + os.R_OK) if writable else os.R_OK checks = (os.W_OK + os.R_OK) if writable else os.R_OK
if os.access(my_dir, checks): if os.access(my_dir, checks):
return (True, my_dir) return True, my_dir
else: else:
logging.error(T('%s directory: %s error accessing'), name, clip_path(my_dir)) logging.error(T('%s directory: %s error accessing'), name, clip_path(my_dir))
return (False, my_dir) return False, my_dir
else: else:
return (False, "") return False, ""
def is_relative_path(p): def is_relative_path(p):
@ -846,7 +846,7 @@ def split_host(srv):
port = int(port) port = int(port)
except: except:
port = None port = None
return (host, port) return host, port
def get_from_url(url): def get_from_url(url):

4
sabnzbd/newsunpack.py

@ -1378,7 +1378,7 @@ def PAR_Verify(parfile, nzo, setname, joinables, single=False):
elif line.startswith('Repair is possible'): elif line.startswith('Repair is possible'):
start = time.time() start = time.time()
nzo.set_action_line(T('Repairing'), '%2d%%' % (0)) nzo.set_action_line(T('Repairing'), '%2d%%' % 0)
elif line.startswith('Repairing:'): elif line.startswith('Repairing:'):
chunks = line.split() chunks = line.split()
@ -1855,7 +1855,7 @@ def MultiPar_Verify(parfile, nzo, setname, joinables, single=False):
# Before this it will calculate matrix, here is where it starts # Before this it will calculate matrix, here is where it starts
start = time.time() start = time.time()
in_repair = True in_repair = True
nzo.set_action_line(T('Repairing'), '%2d%%' % (0)) nzo.set_action_line(T('Repairing'), '%2d%%' % 0)
elif in_repair and line.startswith('Verifying repair'): elif in_repair and line.startswith('Verifying repair'):
in_repair = False in_repair = False

28
sabnzbd/newswrapper.py

@ -175,14 +175,14 @@ class NNTP(object):
ctx = ssl.create_default_context() ctx = ssl.create_default_context()
# Only verify hostname when we're strict # Only verify hostname when we're strict
if(nw.server.ssl_verify < 2): if nw.server.ssl_verify < 2:
ctx.check_hostname = False ctx.check_hostname = False
# Certificates optional # Certificates optional
if(nw.server.ssl_verify == 0): if nw.server.ssl_verify == 0:
ctx.verify_mode = ssl.CERT_NONE ctx.verify_mode = ssl.CERT_NONE
# Did the user set a custom cipher-string? # Did the user set a custom cipher-string?
if(nw.server.ssl_ciphers): if nw.server.ssl_ciphers:
# At their own risk, socket will error out in case it was invalid # At their own risk, socket will error out in case it was invalid
ctx.set_ciphers(nw.server.ssl_ciphers) ctx.set_ciphers(nw.server.ssl_ciphers)
@ -374,19 +374,19 @@ class NewsWrapper(object):
self.timeout = time.time() + self.server.timeout self.timeout = time.time() + self.server.timeout
if precheck: if precheck:
if self.server.have_stat: if self.server.have_stat:
command = 'STAT <%s>\r\n' % (self.article.article) command = 'STAT <%s>\r\n' % self.article.article
else: else:
command = 'HEAD <%s>\r\n' % (self.article.article) command = 'HEAD <%s>\r\n' % self.article.article
elif self.server.have_body: elif self.server.have_body:
command = 'BODY <%s>\r\n' % (self.article.article) command = 'BODY <%s>\r\n' % self.article.article
else: else:
command = 'ARTICLE <%s>\r\n' % (self.article.article) command = 'ARTICLE <%s>\r\n' % self.article.article
self.nntp.sock.sendall(command) self.nntp.sock.sendall(command)
self.data = [] self.data = []
def send_group(self, group): def send_group(self, group):
self.timeout = time.time() + self.server.timeout self.timeout = time.time() + self.server.timeout
command = 'GROUP %s\r\n' % (group) command = 'GROUP %s\r\n' % group
self.nntp.sock.sendall(command) self.nntp.sock.sendall(command)
self.data = [] self.data = []
@ -414,7 +414,7 @@ class NewsWrapper(object):
# time.sleep(0.0001) # time.sleep(0.0001)
continue continue
else: else:
return (0, False, True) return 0, False, True
# Data is processed differently depending on C-yEnc version # Data is processed differently depending on C-yEnc version
if sabnzbd.decoder.SABYENC_ENABLED: if sabnzbd.decoder.SABYENC_ENABLED:
@ -424,16 +424,16 @@ class NewsWrapper(object):
# Official end-of-article is ".\r\n" but sometimes it can get lost between 2 chunks # Official end-of-article is ".\r\n" but sometimes it can get lost between 2 chunks
chunk_len = len(chunk) chunk_len = len(chunk)
if chunk[-5:] == '\r\n.\r\n': if chunk[-5:] == '\r\n.\r\n':
return (chunk_len, True, False) return chunk_len, True, False
elif chunk_len < 5 and len(self.data) > 1: elif chunk_len < 5 and len(self.data) > 1:
# We need to make sure the end is not split over 2 chunks # We need to make sure the end is not split over 2 chunks
# This is faster than join() # This is faster than join()
combine_chunk = self.data[-2][-5:] + chunk combine_chunk = self.data[-2][-5:] + chunk
if combine_chunk[-5:] == '\r\n.\r\n': if combine_chunk[-5:] == '\r\n.\r\n':
return (chunk_len, True, False) return chunk_len, True, False
# Still in middle of data, so continue! # Still in middle of data, so continue!
return (chunk_len, False, False) return chunk_len, False, False
else: else:
self.last_line += chunk self.last_line += chunk
new_lines = self.last_line.split('\r\n') new_lines = self.last_line.split('\r\n')
@ -457,9 +457,9 @@ class NewsWrapper(object):
if self.lines and self.lines[-1] == '.': if self.lines and self.lines[-1] == '.':
self.lines = self.lines[1:-1] self.lines = self.lines[1:-1]
return (len(chunk), True, False) return len(chunk), True, False
else: else:
return (len(chunk), False, False) return len(chunk), False, False
def soft_reset(self): def soft_reset(self):
self.timeout = None self.timeout = None

2
sabnzbd/notifier.py

@ -142,7 +142,7 @@ def check_cat(section, job_cat, keyword=None):
if not keyword: if not keyword:
keyword = section keyword = section
section_cats = sabnzbd.config.get_config(section, '%s_cats' % keyword)() section_cats = sabnzbd.config.get_config(section, '%s_cats' % keyword)()
return (['*'] == section_cats or job_cat in section_cats) return ['*'] == section_cats or job_cat in section_cats
except TypeError: except TypeError:
logging.debug('Incorrect Notify option %s:%s_cats', section, section) logging.debug('Incorrect Notify option %s:%s_cats', section, section)
return True return True

8
sabnzbd/nzbqueue.py

@ -540,10 +540,10 @@ class NzbQueue(object):
nzo2 = self.__nzo_table[item_id_2] nzo2 = self.__nzo_table[item_id_2]
except KeyError: except KeyError:
# One or both jobs missing # One or both jobs missing
return (-1, 0) return -1, 0
if nzo1 == nzo2: if nzo1 == nzo2:
return (-1, 0) return -1, 0
# get the priorities of the two items # get the priorities of the two items
nzo1_priority = nzo1.priority nzo1_priority = nzo1.priority
@ -572,9 +572,9 @@ class NzbQueue(object):
logging.info('Switching job [%s] %s => [%s] %s', item_id_pos1, item.final_name, item_id_pos2, self.__nzo_list[item_id_pos2].final_name) logging.info('Switching job [%s] %s => [%s] %s', item_id_pos1, item.final_name, item_id_pos2, self.__nzo_list[item_id_pos2].final_name)
del self.__nzo_list[item_id_pos1] del self.__nzo_list[item_id_pos1]
self.__nzo_list.insert(item_id_pos2, item) self.__nzo_list.insert(item_id_pos2, item)
return (item_id_pos2, nzo1.priority) return item_id_pos2, nzo1.priority
# If moving failed/no movement took place # If moving failed/no movement took place
return (-1, nzo1.priority) return -1, nzo1.priority
@NzbQueueLocker @NzbQueueLocker
def move_up_bulk(self, nzo_id, nzf_ids, size): def move_up_bulk(self, nzo_id, nzf_ids, size):

10
sabnzbd/nzbstuff.py

@ -167,7 +167,7 @@ class Article(TryList):
# if (server_check.priority() < found_priority and server_check.priority() < server.priority and not self.server_in_try_list(server_check)): # if (server_check.priority() < found_priority and server_check.priority() < server.priority and not self.server_in_try_list(server_check)):
if server_check.active and (server_check.priority < found_priority): if server_check.active and (server_check.priority < found_priority):
if server_check.priority < server.priority: if server_check.priority < server.priority:
if (not self.server_in_try_list(server_check)): if not self.server_in_try_list(server_check):
if log: if log:
logging.debug('Article %s | Server: %s | setting found priority to %s', self.article, server.host, server_check.priority) logging.debug('Article %s | Server: %s | setting found priority to %s', self.article, server.host, server_check.priority)
found_priority = server_check.priority found_priority = server_check.priority
@ -317,7 +317,7 @@ class NzbFile(TryList):
if found: if found:
self.bytes_left -= article.bytes self.bytes_left -= article.bytes
return (not self.articles) return not self.articles
def set_par2(self, setname, vol, blocks): def set_par2(self, setname, vol, blocks):
""" Designate this this file as a par2 file """ """ Designate this this file as a par2 file """
@ -1190,7 +1190,7 @@ class NzbObject(TryList):
self.status = Status.QUEUED self.status = Status.QUEUED
self.set_download_report() self.set_download_report()
return (file_done, post_done) return file_done, post_done
@synchronized(NZO_LOCK) @synchronized(NZO_LOCK)
def remove_saved_article(self, article): def remove_saved_article(self, article):
@ -1291,8 +1291,8 @@ class NzbObject(TryList):
# Convert input # Convert input
value = int_conv(value) value = int_conv(value)
if value in (REPAIR_PRIORITY, TOP_PRIORITY, HIGH_PRIORITY, NORMAL_PRIORITY, \ if value in (REPAIR_PRIORITY, TOP_PRIORITY, HIGH_PRIORITY, NORMAL_PRIORITY,
LOW_PRIORITY, DEFAULT_PRIORITY, PAUSED_PRIORITY, DUP_PRIORITY, STOP_PRIORITY): LOW_PRIORITY, DEFAULT_PRIORITY, PAUSED_PRIORITY, DUP_PRIORITY, STOP_PRIORITY):
self.priority = value self.priority = value
return return

8
sabnzbd/osxmenu.py

@ -208,7 +208,7 @@ class SABnzbdDelegate(NSObject):
for speed in sorted(speeds.keys()): for speed in sorted(speeds.keys()):
menu_speed_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('%s' % (speeds[speed]), 'speedlimitAction:', '') menu_speed_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('%s' % (speeds[speed]), 'speedlimitAction:', '')
menu_speed_item.setRepresentedObject_("%s" % (speed)) menu_speed_item.setRepresentedObject_("%s" % speed)
self.menu_speed.addItem_(menu_speed_item) self.menu_speed.addItem_(menu_speed_item)
self.speed_menu_item.setSubmenu_(self.menu_speed) self.speed_menu_item.setSubmenu_(self.menu_speed)
@ -414,7 +414,7 @@ class SABnzbdDelegate(NSObject):
if history['status'] != Status.COMPLETED: if history['status'] != Status.COMPLETED:
jobfailed = NSAttributedString.alloc().initWithString_attributes_(job, self.failedAttributes) jobfailed = NSAttributedString.alloc().initWithString_attributes_(job, self.failedAttributes)
menu_history_item.setAttributedTitle_(jobfailed) menu_history_item.setAttributedTitle_(jobfailed)
menu_history_item.setRepresentedObject_("%s" % (path)) menu_history_item.setRepresentedObject_("%s" % path)
self.menu_history.addItem_(menu_history_item) self.menu_history.addItem_(menu_history_item)
else: else:
menu_history_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(T('Empty'), '', '') menu_history_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(T('Empty'), '', '')
@ -483,9 +483,9 @@ class SABnzbdDelegate(NSObject):
if self.state != "" and self.info != "": if self.state != "" and self.info != "":
self.state_menu_item.setTitle_("%s - %s" % (self.state, self.info)) self.state_menu_item.setTitle_("%s - %s" % (self.state, self.info))
if self.info == "": if self.info == "":
self.state_menu_item.setTitle_("%s" % (self.state)) self.state_menu_item.setTitle_("%s" % self.state)
else: else:
self.state_menu_item.setTitle_("%s" % (self.info)) self.state_menu_item.setTitle_("%s" % self.info)
except: except:
logging.info("[osx] stateUpdate Exception %s" % (sys.exc_info()[0])) logging.info("[osx] stateUpdate Exception %s" % (sys.exc_info()[0]))

2
sabnzbd/sorting.py

@ -237,7 +237,7 @@ class SeriesSorter(object):
one = '-'.join(extra_list) one = '-'.join(extra_list)
two = '-'.join(extra2_list) two = '-'.join(extra2_list)
return (one, two) return one, two
def get_shownames(self): def get_shownames(self):
""" Get the show name from the match object and format it """ """ Get the show name from the match object and format it """

3
sabnzbd/utils/certgen.py

@ -64,8 +64,7 @@ def generate_local_cert(private_key, days_valid=3560, output_file='cert.cert', L
# build Subject Alternate Names (aka SAN) list # build Subject Alternate Names (aka SAN) list
# First the host names, add with x509.DNSName(): # First the host names, add with x509.DNSName():
san_list = [x509.DNSName(u"localhost")] san_list = [x509.DNSName(u"localhost"), x509.DNSName(unicode(socket.gethostname()))]
san_list.append(x509.DNSName(unicode(socket.gethostname())))
# Then the host IP addresses, add with x509.IPAddress() # Then the host IP addresses, add with x509.IPAddress()
# Inside a try-except, just to be sure # Inside a try-except, just to be sure

2
sabnzbd/utils/checkdir.py

@ -49,7 +49,7 @@ def isFAT(dir):
try: try:
result = win32api.GetVolumeInformation(os.path.splitdrive(dir)[0]) result = win32api.GetVolumeInformation(os.path.splitdrive(dir)[0])
if debug: print result if debug: print result
if(result[4].startswith("FAT")): if result[4].startswith("FAT"):
FAT = True FAT = True
except: except:
pass pass

2
sabnzbd/utils/getperformance.py

@ -20,7 +20,7 @@ def getcpu():
elif platform.system() == "Linux": elif platform.system() == "Linux":
for myline in open("/proc/cpuinfo"): for myline in open("/proc/cpuinfo"):
if myline.startswith(('model name')): if myline.startswith('model name'):
# Typical line: # Typical line:
# model name : Intel(R) Xeon(R) CPU E5335 @ 2.00GHz # model name : Intel(R) Xeon(R) CPU E5335 @ 2.00GHz
cputype = myline.split(":", 1)[1] # get everything after the first ":" cputype = myline.split(":", 1)[1] # get everything after the first ":"

12
scripts/Deobfuscate.py

@ -91,7 +91,7 @@ def decodePar(parfile):
result = False result = False
dir = os.path.dirname(parfile) dir = os.path.dirname(parfile)
with open(parfile, 'rb') as parfileToDecode: with open(parfile, 'rb') as parfileToDecode:
while (True): while True:
header = parfileToDecode.read(STRUCT_PACKET_HEADER.size) header = parfileToDecode.read(STRUCT_PACKET_HEADER.size)
if not header: break # file fully read if not header: break # file fully read
@ -99,7 +99,7 @@ def decodePar(parfile):
bodyLength = packetLength - STRUCT_PACKET_HEADER.size bodyLength = packetLength - STRUCT_PACKET_HEADER.size
# only process File Description packets # only process File Description packets
if (packetType != PACKET_TYPE_FILE_DESC): if packetType != PACKET_TYPE_FILE_DESC:
# skip this packet # skip this packet
parfileToDecode.seek(bodyLength, os.SEEK_CUR) parfileToDecode.seek(bodyLength, os.SEEK_CUR)
continue continue
@ -112,13 +112,13 @@ def decodePar(parfile):
targetPath = path.join(dir, targetName) targetPath = path.join(dir, targetName)
# file already exists, skip it # file already exists, skip it
if (path.exists(targetPath)): if path.exists(targetPath):
print "File already exists: " + targetName print "File already exists: " + targetName
continue continue
# find and rename file # find and rename file
srcPath = findFile(dir, filelength, hash16k) srcPath = findFile(dir, filelength, hash16k)
if (srcPath is not None): if srcPath is not None:
os.rename(srcPath, targetPath) os.rename(srcPath, targetPath)
print "Renamed file from " + path.basename(srcPath) + " to " + targetName print "Renamed file from " + path.basename(srcPath) + " to " + targetName
result = True result = True
@ -132,7 +132,7 @@ def findFile(dir, filelength, hash16k):
filepath = path.join(dir, filename) filepath = path.join(dir, filename)
# check if the size matches as an indication # check if the size matches as an indication
if (path.getsize(filepath) != filelength): continue if path.getsize(filepath) != filelength: continue
with open(filepath, 'rb') as fileToMatch: with open(filepath, 'rb') as fileToMatch:
data = fileToMatch.read(16 * 1024) data = fileToMatch.read(16 * 1024)
@ -140,7 +140,7 @@ def findFile(dir, filelength, hash16k):
m.update(data) m.update(data)
# compare hash to confirm the match # compare hash to confirm the match
if (m.digest() == hash16k): if m.digest() == hash16k:
return filepath return filepath
return None return None

2
tools/extract_pot.py

@ -27,7 +27,7 @@ import re
f = open('sabnzbd/version.py') f = open('sabnzbd/version.py')
code = f.read() code = f.read()
f.close() f.close()
exec(code) exec code
# Fixed information for the POT header # Fixed information for the POT header
HEADER = r'''# HEADER = r'''#

Loading…
Cancel
Save