From ad3fb4519df0b3bf2afe403ab01ff5083a475aee Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 26 Dec 2018 12:28:18 -0500 Subject: [PATCH] Fix name shadows builtin --- core/auto_process/movies.py | 14 ++++----- core/extractor/__init__.py | 16 +++++----- core/main_db.py | 4 +-- core/scene_exceptions.py | 6 ++-- core/transcoder.py | 10 +++---- core/utils.py | 54 +++++++++++++++++----------------- libs/custom/utorrent/client.py | 44 +++++++++++++-------------- 7 files changed, 74 insertions(+), 74 deletions(-) diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 00f15e84..152353e0 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -413,8 +413,8 @@ class Movie(object): # Gather release info and return it back, no need to narrow results if release_id: try: - id = result[section]['_id'] - results[id] = result[section] + cur_id = result[section]['_id'] + results[cur_id] = result[section] return results except Exception: pass @@ -438,9 +438,9 @@ class Movie(object): if download_id.lower() != release['download_info']['id'].lower(): continue - id = release['_id'] - results[id] = release - results[id]['title'] = movie['title'] + cur_id = release['_id'] + results[cur_id] = release + results[cur_id]['title'] = movie['title'] except Exception: continue @@ -456,10 +456,10 @@ class Movie(object): # Search downloads on clients for a match to try and narrow our results down to 1 if len(results) > 1: - for id, x in results.items(): + for cur_id, x in results.items(): try: if not find_download(str(x['download_info']['downloader']).lower(), x['download_info']['id']): - results.pop(id) + results.pop(cur_id) except Exception: continue diff --git a/core/extractor/__init__.py b/core/extractor/__init__.py index 03005662..b8aceae5 100644 --- a/core/extractor/__init__.py +++ b/core/extractor/__init__.py @@ -102,11 +102,11 @@ def extract(file_path, output_destination): orig_files = [] orig_dirs = [] - for dir, subdirs, files in os.walk(output_destination): + for directory, subdirs, files in os.walk(output_destination): for subdir in subdirs: - orig_dirs.append(os.path.join(dir, subdir)) + orig_dirs.append(os.path.join(directory, subdir)) for file in files: - orig_files.append(os.path.join(dir, file)) + orig_files.append(os.path.join(directory, file)) pwd = os.getcwd() # Get our Present Working Directory os.chdir(output_destination) # Not all unpack commands accept full paths, so just extract into this directory @@ -160,17 +160,17 @@ def extract(file_path, output_destination): # sleep to let files finish writing to disk sleep(3) perms = stat.S_IMODE(os.lstat(os.path.split(file_path)[0]).st_mode) - for dir, subdirs, files in os.walk(output_destination): + for directory, subdirs, files in os.walk(output_destination): for subdir in subdirs: - if not os.path.join(dir, subdir) in orig_files: + if not os.path.join(directory, subdir) in orig_files: try: - os.chmod(os.path.join(dir, subdir), perms) + os.chmod(os.path.join(directory, subdir), perms) except Exception: pass for file in files: - if not os.path.join(dir, file) in orig_files: + if not os.path.join(directory, file) in orig_files: try: - shutil.copymode(file_path, os.path.join(dir, file)) + shutil.copymode(file_path, os.path.join(directory, file)) except Exception: pass return True diff --git a/core/main_db.py b/core/main_db.py index 74b5cdef..a39b3a82 100644 --- a/core/main_db.py +++ b/core/main_db.py @@ -274,8 +274,8 @@ class SchemaUpgrade(object): def has_column(self, table_name, column): return column in self.connection.table_info(table_name) - def add_column(self, table, column, type="NUMERIC", default=0): - self.connection.action("ALTER TABLE {0} ADD {1} {2}".format(table, column, type)) + def add_column(self, table, column, data_type="NUMERIC", default=0): + self.connection.action("ALTER TABLE {0} ADD {1} {2}".format(table, column, data_type)) self.connection.action("UPDATE {0} SET {1} = ?".format(table, column), (default,)) def check_db_version(self): diff --git a/core/scene_exceptions.py b/core/scene_exceptions.py index 3a315353..0c888953 100644 --- a/core/scene_exceptions.py +++ b/core/scene_exceptions.py @@ -121,11 +121,11 @@ def reverse_filename(filename, dirname, name): def rename_script(dirname): rename_file = "" - for dir, dirs, files in os.walk(dirname): + for directory, directories, files in os.walk(dirname): for file in files: if re.search(r'(rename\S*\.(sh|bat)$)', file, re.IGNORECASE): - rename_file = os.path.join(dir, file) - dirname = dir + rename_file = os.path.join(directory, file) + dirname = directory break if rename_file: rename_lines = [line.strip() for line in open(rename_file)] diff --git a/core/transcoder.py b/core/transcoder.py index 4314a715..08ed6077 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -124,7 +124,7 @@ def build_commands(file, new_dir, movie_name, bitbucket): if 'concat:' in file: file = file.split('|')[0].replace('concat:', '') video_details, result = get_video_details(file) - dir, name = os.path.split(file) + directory, name = os.path.split(file) name, ext = os.path.splitext(name) check = re.match("VTS_([0-9][0-9])_[0-9]+", name) if check and core.CONCAT: @@ -133,7 +133,7 @@ def build_commands(file, new_dir, movie_name, bitbucket): name = ('{0}.cd{1}'.format(movie_name, check.groups()[0])) elif core.CONCAT and re.match("(.+)[cC][dD][0-9]", name): name = re.sub('([ ._=:-]+[cC][dD][0-9])', "", name) - if ext == core.VEXTENSION and new_dir == dir: # we need to change the name to prevent overwriting itself. + if ext == core.VEXTENSION and new_dir == directory: # we need to change the name to prevent overwriting itself. core.VEXTENSION = '-transcoded{ext}'.format(ext=core.VEXTENSION) # adds '-transcoded.ext' else: img, data = next(iteritems(file)) @@ -521,10 +521,10 @@ def get_subs(file): filepaths = [] sub_ext = ['.srt', '.sub', '.idx'] name = os.path.splitext(os.path.split(file)[1])[0] - dir = os.path.split(file)[0] - for dirname, dirs, filenames in os.walk(dir): + path = os.path.split(file)[0] + for directory, directories, filenames in os.walk(path): for filename in filenames: - filepaths.extend([os.path.join(dirname, filename)]) + filepaths.extend([os.path.join(directory, filename)]) subfiles = [item for item in filepaths if os.path.splitext(item)[1] in sub_ext and name in item] return subfiles diff --git a/core/utils.py b/core/utils.py index 7277c25a..e6faf8bc 100644 --- a/core/utils.py +++ b/core/utils.py @@ -476,15 +476,15 @@ def convert_to_ascii(input_name, dir_name): encoded, input_name = char_replace(input_name) - dir, base = os.path.split(dir_name) + directory, base = os.path.split(dir_name) if not base: # ended with "/" - dir, base = os.path.split(dir) + directory, base = os.path.split(directory) encoded, base2 = char_replace(base) if encoded: - dir_name = os.path.join(dir, base2) + dir_name = os.path.join(directory, base2) logger.info("Renaming directory to: {0}.".format(base2), 'ENCODER') - os.rename(os.path.join(dir, base), dir_name) + os.rename(os.path.join(directory, base), dir_name) if 'NZBOP_SCRIPTDIR' in os.environ: print("[NZB] DIRECTORY={0}".format(dir_name)) @@ -579,32 +579,32 @@ def parse_transmission(args): def parse_vuze(args): # vuze usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D%N%L%I%K%F" try: - input = args[1].split(',') + cur_input = args[1].split(',') except Exception: - input = [] + cur_input = [] try: - input_directory = os.path.normpath(input[0]) + input_directory = os.path.normpath(cur_input[0]) except Exception: input_directory = '' try: - input_name = input[1] + input_name = cur_input[1] except Exception: input_name = '' try: - input_category = input[2] + input_category = cur_input[2] except Exception: input_category = '' try: - input_hash = input[3] + input_hash = cur_input[3] except Exception: input_hash = '' try: - input_id = input[3] + input_id = cur_input[3] except Exception: input_id = '' try: - if input[4] == 'single': - input_name = input[5] + if cur_input[4] == 'single': + input_name = cur_input[5] except Exception: pass @@ -614,27 +614,27 @@ def parse_vuze(args): def parse_qbittorrent(args): # qbittorrent usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D|%N|%L|%I" try: - input = args[1].split('|') + cur_input = args[1].split('|') except Exception: - input = [] + cur_input = [] try: - input_directory = os.path.normpath(input[0].replace('"', '')) + input_directory = os.path.normpath(cur_input[0].replace('"', '')) except Exception: input_directory = '' try: - input_name = input[1].replace('"', '') + input_name = cur_input[1].replace('"', '') except Exception: input_name = '' try: - input_category = input[2].replace('"', '') + input_category = cur_input[2].replace('"', '') except Exception: input_category = '' try: - input_hash = input[3].replace('"', '') + input_hash = cur_input[3].replace('"', '') except Exception: input_hash = '' try: - input_id = input[3].replace('"', '') + input_id = cur_input[3].replace('"', '') except Exception: input_id = '' @@ -732,12 +732,12 @@ def get_dirs(section, subsection, link='hard'): # removeEmptyFolders(path, removeRoot=False) if os.listdir(text_type(path)): - for dir in [os.path.join(path, o) for o in os.listdir(text_type(path)) if - os.path.isdir(os.path.join(path, o))]: - sync = [o for o in os.listdir(text_type(dir)) if os.path.splitext(o)[1] in ['.!sync', '.bts']] - if len(sync) > 0 or len(os.listdir(text_type(dir))) == 0: + for directory in [os.path.join(path, o) for o in os.listdir(text_type(path)) if + os.path.isdir(os.path.join(path, o))]: + sync = [o for o in os.listdir(text_type(directory)) if os.path.splitext(o)[1] in ['.!sync', '.bts']] + if len(sync) > 0 or len(os.listdir(text_type(directory))) == 0: continue - folders.extend([dir]) + folders.extend([directory]) return folders try: @@ -924,8 +924,8 @@ def find_download(client_agent, download_id): if client_agent == 'transmission': torrents = core.TORRENT_CLASS.get_torrents() for torrent in torrents: - hash = torrent.hashString - if hash == download_id: + torrent_hash = torrent.hashString + if torrent_hash == download_id: return True if client_agent == 'deluge': return False diff --git a/libs/custom/utorrent/client.py b/libs/custom/utorrent/client.py index c58023a0..a429f1ed 100644 --- a/libs/custom/utorrent/client.py +++ b/libs/custom/utorrent/client.py @@ -62,59 +62,59 @@ class UTorrentClient(object): def start(self, *hashes): params = [('action', 'start'), ] - for hash in hashes: - params.append(('hash', hash)) + for cur_hash in hashes: + params.append(('hash', cur_hash)) return self._action(params) def stop(self, *hashes): params = [('action', 'stop'), ] - for hash in hashes: - params.append(('hash', hash)) + for cur_hash in hashes: + params.append(('hash', cur_hash)) return self._action(params) def pause(self, *hashes): params = [('action', 'pause'), ] - for hash in hashes: - params.append(('hash', hash)) + for cur_hash in hashes: + params.append(('hash', cur_hash)) return self._action(params) def forcestart(self, *hashes): params = [('action', 'forcestart'), ] - for hash in hashes: - params.append(('hash', hash)) + for cur_hash in hashes: + params.append(('hash', cur_hash)) return self._action(params) - def getfiles(self, hash): - params = [('action', 'getfiles'), ('hash', hash)] + def getfiles(self, cur_hash): + params = [('action', 'getfiles'), ('hash', cur_hash)] return self._action(params) - def getprops(self, hash): - params = [('action', 'getprops'), ('hash', hash)] + def getprops(self, cur_hash): + params = [('action', 'getprops'), ('hash', cur_hash)] return self._action(params) - def setprops(self, hash, **kvpairs): - params = [('action', 'setprops'), ('hash', hash)] + def setprops(self, cur_hash, **kvpairs): + params = [('action', 'setprops'), ('hash', cur_hash)] for k, v in iteritems(kvpairs): params.append(("s", k)) params.append(("v", v)) return self._action(params) - def setprio(self, hash, priority, *files): - params = [('action', 'setprio'), ('hash', hash), ('p', str(priority))] + def setprio(self, cur_hash, priority, *files): + params = [('action', 'setprio'), ('hash', cur_hash), ('p', str(priority))] for file_index in files: params.append(('f', str(file_index))) return self._action(params) - def addfile(self, filename, filepath=None, bytes=None): + def addfile(self, filename, filepath=None, data=None): params = [('action', 'add-file')] form = MultiPartForm() if filepath is not None: file_handler = open(filepath, 'rb') else: - file_handler = StringIO(bytes) + file_handler = StringIO(data) form.add_file('torrent_file', filename.encode('utf-8'), file_handler) @@ -126,14 +126,14 @@ class UTorrentClient(object): def remove(self, *hashes): params = [('action', 'remove'), ] - for hash in hashes: - params.append(('hash', hash)) + for cur_hash in hashes: + params.append(('hash', cur_hash)) return self._action(params) def removedata(self, *hashes): params = [('action', 'removedata'), ] - for hash in hashes: - params.append(('hash', hash)) + for cur_hash in hashes: + params.append(('hash', cur_hash)) return self._action(params) def _action(self, params, body=None, content_type=None):