diff --git a/SABnzbd.py b/SABnzbd.py index 420aab1..0bd78ba 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -728,7 +728,7 @@ def evaluate_inipath(path): return path -def commandline_handler(frozen=True): +def commandline_handler(): """ Split win32-service commands are true parameters Returns: service, sab_opts, serv_opts, upload_nzbs @@ -829,7 +829,6 @@ def main(): vista_plus = False win64 = False repair = 0 - api_url = None no_login = False sabnzbd.RESTART_ARGS = [sys.argv[0]] pid_path = None @@ -1049,7 +1048,7 @@ def main(): else: # In case HTTPS == HTTP port cherryport = newport - sabnzbd.cfg.port.set(newport) + sabnzbd.cfg.cherryport.set(newport) except: # Something else wrong, probably badly specified host Bail_Out(browserhost, cherryport, '49') @@ -1180,7 +1179,7 @@ def main(): logging.info('Preferred encoding = ERROR') preferredencoding = '' - # On Linux/FreeBSD/Unix "UTF-8" is strongly, strongly adviced: + # On Linux/FreeBSD/Unix "UTF-8" is strongly, strongly advised: if not sabnzbd.WIN32 and not sabnzbd.DARWIN and not ('utf' in preferredencoding.lower() and '8' in preferredencoding.lower()): logging.warning(T("SABnzbd was started with encoding %s, this should be UTF-8. Expect problems with Unicoded file and directory names in downloads.") % preferredencoding) @@ -1237,8 +1236,6 @@ def main(): if autobrowser is not None: sabnzbd.cfg.autobrowser.set(autobrowser) - else: - autobrowser = sabnzbd.cfg.autobrowser() if not sabnzbd.WIN_SERVICE and not getattr(sys, 'frozen', None) == 'macosx_app': signal.signal(signal.SIGINT, sabnzbd.sig_handler) @@ -1601,7 +1598,7 @@ if sabnzbd.WIN32: win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) - self.overlapped = pywintypes.OVERLAPPED() # @UndefinedVariable + self.overlapped = pywintypes.OVERLAPPED() self.overlapped.hEvent = win32event.CreateEvent(None, 0, 0, None) sabnzbd.WIN_SERVICE = self diff --git a/sabnzbd/__init__.py b/sabnzbd/__init__.py index fe6cfb4..90e6d1c 100644 --- a/sabnzbd/__init__.py +++ b/sabnzbd/__init__.py @@ -661,13 +661,13 @@ def add_nzbfile(nzbfile, pp=None, script=None, cat=None, priority=NORMAL_PRIORIT try: filename = nzbfile.filename.encode('cp1252').decode('utf-8') except: - # Correct encoding afterall! + # Correct encoding after all! filename = nzbfile.filename filename = encoding.special_fixer(filename) keep = False if not sabnzbd.WIN32: - # If windows client sends file to Unix server backslashed may + # If windows client sends file to Unix server backslashes may # be included, so convert these filename = filename.replace('\\', '/') @@ -963,9 +963,9 @@ def save_admin(data, _id): try: with open(path, 'wb') as data_file: if cfg.use_pickle(): - data = pickle.dump(data, data_file) + pickle.dump(data, data_file) else: - data = cPickle.dump(data, data_file) + cPickle.dump(data, data_file) break except: if t == 2: diff --git a/sabnzbd/misc.py b/sabnzbd/misc.py index 3f434ab..bb3d7d6 100644 --- a/sabnzbd/misc.py +++ b/sabnzbd/misc.py @@ -249,11 +249,12 @@ _DEVICES = ('con', 'prn', 'aux', 'nul', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9') + def replace_win_devices(name): - ''' Remove reserved Windows device names from a name. + """ Remove reserved Windows device names from a name. aux.txt ==> _aux.txt txt.aux ==> txt.aux - ''' + """ if name: lname = name.lower() for dev in _DEVICES: @@ -261,9 +262,9 @@ def replace_win_devices(name): name = '_' + name break - # Remove special NTFS filename - if lname.startswith('$mft'): - name = name.replace('$', 'S', 1) + # Remove special NTFS filename + if lname.startswith('$mft'): + name = name.replace('$', 'S', 1) return name @@ -1082,7 +1083,7 @@ def get_filepath(path, nzo, filename): # It does no umask setting # It uses the dir_lock for the (rare) case that the # download_dir is equal to the complete_dir. - dName = nzo.work_name + dName = dirname = nzo.work_name if not nzo.created: for n in xrange(200): dName = dirname @@ -1156,11 +1157,12 @@ def renamer(old, new): @synchronized(DIR_LOCK) def remove_dir(path): """ Remove directory with retries for Win32 """ + logging.debug('[%s] Deleting dir %s', caller_name(), path) if sabnzbd.WIN32: retries = 15 while retries > 0: try: - remove_dir(path) + os.rmdir(path) return except WindowsError, err: if err[0] == 32: @@ -1171,7 +1173,7 @@ def remove_dir(path): time.sleep(3) raise WindowsError(err) else: - remove_dir(path) + os.rmdir(path) @synchronized(DIR_LOCK) @@ -1203,12 +1205,6 @@ def remove_file(path): os.remove(path) -def remove_dir(dir): - """ Wrapper function so any dir removal is logged """ - logging.debug('[%s] Deleting dir %s', caller_name(), dir) - os.rmdir(dir) - - def trim_win_path(path): """ Make sure Windows path stays below 70 by trimming last part """ if sabnzbd.WIN32 and len(path) > 69: @@ -1295,8 +1291,8 @@ def memory_usage(): except: logging.debug('Error retrieving memory usage') logging.info("Traceback: ", exc_info=True) - else: - return '' + + try: _PAGE_SIZE = os.sysconf("SC_PAGE_SIZE") except: diff --git a/sabnzbd/newsunpack.py b/sabnzbd/newsunpack.py index a43e22e..9374c8a 100644 --- a/sabnzbd/newsunpack.py +++ b/sabnzbd/newsunpack.py @@ -460,9 +460,7 @@ def rar_unpack(nzo, workdir, workdir_complete, delete, one_folder, rars): When 'delete' is set, originals will be deleted. When 'one_folder' is set, all files will be in a single folder """ - extracted_files = [] - success = False - + newfiles = extracted_files = [] rar_sets = {} for rar in rars: rar_set = os.path.splitext(os.path.basename(rar))[0]