diff --git a/core/nzbToMediaDB.py b/core/nzbToMediaDB.py index c8a22318..4445b6e1 100644 --- a/core/nzbToMediaDB.py +++ b/core/nzbToMediaDB.py @@ -115,7 +115,6 @@ class DBConnection(object): logger.log(u"DB error: " + str(e), logger.ERROR) raise except sqlite3.DatabaseError as e: - sqlResult = [] if self.connection: self.connection.rollback() logger.log(u"Fatal error executing query: " + str(e), logger.ERROR) diff --git a/core/nzbToMediaUserScript.py b/core/nzbToMediaUserScript.py index 23c3c5de..fe6a453e 100644 --- a/core/nzbToMediaUserScript.py +++ b/core/nzbToMediaUserScript.py @@ -58,7 +58,7 @@ def external_script(outputDestination, torrentName, torrentLabel, settings): fileName, fileExtension = os.path.splitext(file) if fileExtension in core.USER_SCRIPT_MEDIAEXTENSIONS or "ALL" in core.USER_SCRIPT_MEDIAEXTENSIONS: - num_files = num_files + 1 + num_files += 1 if core.USER_SCRIPT_RUNONCE == 1 and num_files > 1: # we have already run once, so just continue to get number of files. continue command = [core.USER_SCRIPT] @@ -103,16 +103,15 @@ def external_script(outputDestination, torrentName, torrentLabel, settings): except: logger.error("UserScript %s has failed" % (command[0]), "USERSCRIPT") result = int(1) - final_result = final_result + result + final_result += result num_files_new = 0 for dirpath, dirnames, filenames in os.walk(outputDestination): for file in filenames: - filePath = core.os.path.join(dirpath, file) fileName, fileExtension = os.path.splitext(file) if fileExtension in core.USER_SCRIPT_MEDIAEXTENSIONS or core.USER_SCRIPT_MEDIAEXTENSIONS == "ALL": - num_files_new = num_files_new + 1 + num_files_new += 1 if core.USER_SCRIPT_CLEAN == int(1) and num_files_new == 0 and final_result == 0: logger.info("All files have been processed. Cleaning outputDirectory %s" % (outputDestination)) diff --git a/core/nzbToMediaUtil.py b/core/nzbToMediaUtil.py index f1098330..bbb58346 100644 --- a/core/nzbToMediaUtil.py +++ b/core/nzbToMediaUtil.py @@ -38,7 +38,7 @@ def reportNzb(failure_link, clientAgent): else: return try: - r = requests.post(failure_link, headers=headers, timeout=(30, 300)) + requests.post(failure_link, headers=headers, timeout=(30, 300)) except Exception as e: logger.error("Unable to open URL %s due to %s" % (failure_link, e)) return @@ -202,7 +202,7 @@ def is_minSize(inputName, minSize): # audio files we need to check directory size not file size inputSize = os.path.getsize(inputName) - if fileExt in (core.AUDIOCONTAINER): + if fileExt in core.AUDIOCONTAINER: try: inputSize = getDirSize(os.path.dirname(inputName)) except: @@ -339,7 +339,7 @@ def rmReadOnly(filename): if os.path.isfile(filename): # check first the read-only attribute file_attribute = os.stat(filename)[0] - if (not file_attribute & stat.S_IWRITE): + if not file_attribute & stat.S_IWRITE: # File is read-only, so make it writeable logger.debug('Read only mode on file ' + filename + ' Will try to make it writeable') try: @@ -631,11 +631,7 @@ def getDirs(section, subsection, link='hard'): f = guessit.guess_video_info(mediafile) # get title - title = None - try: - title = f['series'] - except: - title = f['title'] + title = f.get('series') or f.get('title') if not title: title = os.path.splitext(os.path.basename(mediafile))[0] @@ -1262,7 +1258,7 @@ class WindowsProcess(object): def alreadyrunning(self): self.mutex = self.CreateMutex(None, 0, self.mutexname) self.lasterror = self.GetLastError() - if (self.lasterror == self.ERROR_ALREADY_EXISTS): + if self.lasterror == self.ERROR_ALREADY_EXISTS: self.CloseHandle(self.mutex) return True else: diff --git a/core/synchronousdeluge/client.py b/core/synchronousdeluge/client.py index 050d414e..cecb2a88 100644 --- a/core/synchronousdeluge/client.py +++ b/core/synchronousdeluge/client.py @@ -23,7 +23,6 @@ class DelugeClient(object): self._request_counter = 0 def _get_local_auth(self): - auth_file = "" username = password = "" if platform.system() in ('Windows', 'Microsoft'): appDataPath = os.environ.get("APPDATA") @@ -62,9 +61,9 @@ class DelugeClient(object): continue if username == "localclient": - return (username, password) + return username, password - return ("", "") + return "", "" def _create_module_method(self, module, method): fullname = "{0}.{1}".format(module, method) diff --git a/core/synchronousdeluge/protocol.py b/core/synchronousdeluge/protocol.py index 2cb1a73e..98084d4f 100644 --- a/core/synchronousdeluge/protocol.py +++ b/core/synchronousdeluge/protocol.py @@ -10,7 +10,7 @@ class DelugeRPCRequest(object): self.kwargs = kwargs def format(self): - return (self.request_id, self.method, self.args, self.kwargs) + return self.request_id, self.method, self.args, self.kwargs class DelugeRPCResponse(object): diff --git a/core/synchronousdeluge/rencode.py b/core/synchronousdeluge/rencode.py index f0fcc69e..f27c3304 100644 --- a/core/synchronousdeluge/rencode.py +++ b/core/synchronousdeluge/rencode.py @@ -126,39 +126,39 @@ def decode_int(x, f): raise ValueError elif x[f] == '0' and newf != f + 1: raise ValueError - return (n, newf + 1) + return n, newf + 1 def decode_intb(x, f): f += 1 - return (struct.unpack('!b', x[f:f + 1])[0], f + 1) + return struct.unpack('!b', x[f:f + 1])[0], f + 1 def decode_inth(x, f): f += 1 - return (struct.unpack('!h', x[f:f + 2])[0], f + 2) + return struct.unpack('!h', x[f:f + 2])[0], f + 2 def decode_intl(x, f): f += 1 - return (struct.unpack('!l', x[f:f + 4])[0], f + 4) + return struct.unpack('!l', x[f:f + 4])[0], f + 4 def decode_intq(x, f): f += 1 - return (struct.unpack('!q', x[f:f + 8])[0], f + 8) + return struct.unpack('!q', x[f:f + 8])[0], f + 8 def decode_float32(x, f): f += 1 n = struct.unpack('!f', x[f:f + 4])[0] - return (n, f + 4) + return n, f + 4 def decode_float64(x, f): f += 1 n = struct.unpack('!d', x[f:f + 8])[0] - return (n, f + 8) + return n, f + 8 def decode_string(x, f): @@ -177,7 +177,7 @@ def decode_string(x, f): s = t except UnicodeDecodeError: pass - return (s, colon + n) + return s, colon + n def decode_list(x, f): @@ -185,7 +185,7 @@ def decode_list(x, f): while x[f] != CHR_TERM: v, f = decode_func[x[f]](x, f) r.append(v) - return (tuple(r), f + 1) + return tuple(r), f + 1 def decode_dict(x, f): @@ -193,19 +193,19 @@ def decode_dict(x, f): while x[f] != CHR_TERM: k, f = decode_func[x[f]](x, f) r[k], f = decode_func[x[f]](x, f) - return (r, f + 1) + return r, f + 1 def decode_true(x, f): - return (True, f + 1) + return True, f + 1 def decode_false(x, f): - return (False, f + 1) + return False, f + 1 def decode_none(x, f): - return (None, f + 1) + return None, f + 1 decode_func = { @@ -244,7 +244,7 @@ def make_fixed_length_string_decoders(): s = t except UnicodeDecodeError: pass - return (s, f + 1 + slen) + return s, f + 1 + slen return f @@ -262,7 +262,7 @@ def make_fixed_length_list_decoders(): for i in range(slen): v, f = decode_func[x[f]](x, f) r.append(v) - return (tuple(r), f) + return tuple(r), f return f @@ -276,7 +276,7 @@ make_fixed_length_list_decoders() def make_fixed_length_int_decoders(): def make_decoder(j): def f(x, f): - return (j, f + 1) + return j, f + 1 return f @@ -296,7 +296,7 @@ def make_fixed_length_dict_decoders(): for j in range(slen): k, f = decode_func[x[f]](x, f) r[k], f = decode_func[x[f]](x, f) - return (r, f) + return r, f return f diff --git a/core/transcoder/transcoder.py b/core/transcoder/transcoder.py index 46e95896..9731f689 100644 --- a/core/transcoder/transcoder.py +++ b/core/transcoder/transcoder.py @@ -142,7 +142,6 @@ def buildCommands(file, newDir, movieName, bitbucket): video_cmd = [] audio_cmd = [] audio_cmd2 = [] - audio_cmd3 = [] sub_cmd = [] meta_cmd = [] other_cmd = [] @@ -221,10 +220,6 @@ def buildCommands(file, newDir, movieName, bitbucket): except: height = 0 scale = core.VRESOLUTION - try: - framerate = float(fr.split('/')[0]) / float(fr.split('/')[1]) - except: - framerate = 0 if codec in core.VCODEC_ALLOW or not core.VCODEC: video_cmd.extend(['-c:v', 'copy']) else: @@ -431,7 +426,6 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd.extend(audio_cmd3) s_mapped = [] - subs1 = [] burnt = 0 n = 0 for lan in core.SLANGUAGES: @@ -587,12 +581,10 @@ def extract_subs(file, newfilePath, bitbucket): def processList(List, newDir, bitbucket): remList = [] newList = [] - delList = [] combine = [] vtsPath = None success = True for item in List: - newfile = None ext = os.path.splitext(item)[1].lower() if ext in ['.iso', '.bin', '.img'] and ext not in core.IGNOREEXTENSIONS: logger.debug("Attempting to rip disk image: %s" % (item), "TRANSCODER") @@ -647,7 +639,6 @@ def ripISO(item, newDir, bitbucket): print_cmd(cmd) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket) out, err = proc.communicate() - result = proc.returncode fileList = [re.match(".+(VIDEO_TS[\\\/]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb])", line).groups()[0] for line in out.splitlines() if re.match(".+VIDEO_TS[\\\/]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]", line)] combined = [] diff --git a/core/transmissionrpc/client.py b/core/transmissionrpc/client.py index b64b709d..6379e595 100644 --- a/core/transmissionrpc/client.py +++ b/core/transmissionrpc/client.py @@ -409,11 +409,8 @@ class Client(object): pass if might_be_base64: torrent_data = torrent - args = {} - if torrent_data: - args = {'metainfo': torrent_data} - else: - args = {'filename': torrent} + + args = {'metainfo': torrent_data} if torrent_data else {'filename': torrent} for key, value in iteritems(kwargs): argument = make_rpc_name(key) (arg, val) = argument_value_convert('torrent-add', argument, value, self.rpc_version) @@ -804,7 +801,7 @@ class Client(object): raise ValueError("Target name cannot contain a path delimiter") args = {'path': location, 'name': name} result = self._request('torrent-rename-path', args, torrent_id, True, timeout=timeout) - return (result['path'], result['name']) + return result['path'], result['name'] def queue_top(self, ids, timeout=None): """Move transfer to the top of the queue.""" diff --git a/core/transmissionrpc/torrent.py b/core/transmissionrpc/torrent.py index 5fd033db..54ee2a2d 100644 --- a/core/transmissionrpc/torrent.py +++ b/core/transmissionrpc/torrent.py @@ -124,7 +124,6 @@ class Torrent(object): """ Update the torrent data from a Transmission JSON-RPC arguments dictionary """ - fields = None if isinstance(other, dict): for key, value in iteritems(other): self._fields[key.replace('-', '_')] = Field(value, False) diff --git a/core/transmissionrpc/utils.py b/core/transmissionrpc/utils.py index c2bca855..0ac2a32a 100644 --- a/core/transmissionrpc/utils.py +++ b/core/transmissionrpc/utils.py @@ -23,7 +23,7 @@ def format_size(size): while size >= 1024.0 and i < len(UNITS): i += 1 size /= 1024.0 - return (size, UNITS[i]) + return size, UNITS[i] def format_speed(size): @@ -31,7 +31,7 @@ def format_speed(size): Format bytes per second speed into IEC prefixes, B/s, KiB/s, MiB/s ... """ (size, unit) = format_size(size) - return (size, unit + '/s') + return size, unit + '/s' def format_timedelta(delta): @@ -91,7 +91,7 @@ def inet_address(address, default_port, default_address='localhost'): socket.getaddrinfo(addr, port, socket.AF_INET, socket.SOCK_STREAM) except socket.gaierror: raise INetAddressError('Cannot look up address "%s".' % address) - return (addr, port) + return addr, port def rpc_bool(arg): @@ -163,7 +163,7 @@ def argument_value_convert(method, argument, value, rpc_version): raise ValueError( 'Method "%s" Argument "%s" does not exist in version %d.' % (method, argument, rpc_version)) - return (argument, TR_TYPE_MAP[info[0]](value)) + return argument, TR_TYPE_MAP[info[0]](value) else: raise ValueError('Argument "%s" does not exists for method "%s".', (argument, method)) diff --git a/core/versionCheck.py b/core/versionCheck.py index fd58af45..84e14947 100644 --- a/core/versionCheck.py +++ b/core/versionCheck.py @@ -159,12 +159,13 @@ class GitUpdateManager(UpdateManager): def _run_git(self, git_path, args): - output = err = exit_status = None + output = None + err = None if not git_path: logger.log(u"No git specified, can't use git commands", logger.DEBUG) exit_status = 1 - return (output, err, exit_status) + return output, err, exit_status cmd = git_path + ' ' + args @@ -203,7 +204,7 @@ class GitUpdateManager(UpdateManager): logger.log(cmd + u" returned : " + output + u", treat as error for now", logger.DEBUG) exit_status = 1 - return (output, err, exit_status) + return output, err, exit_status def _find_installed_version(self): """