mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-06 21:21:12 -07:00
Python 3: Convert except ExceptClass, Target: to except ExceptClass as Target:
This commit is contained in:
parent
5903538ae5
commit
ec71e7806d
7 changed files with 28 additions and 28 deletions
|
@ -118,7 +118,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
if not os.path.isfile(core.CONFIG_FILE):
|
||||
shutil.copyfile(core.CONFIG_SPEC_FILE, core.CONFIG_FILE)
|
||||
CFG_OLD = config(core.CONFIG_FILE)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.debug("Error %s when copying to .cfg" % (e))
|
||||
|
||||
try:
|
||||
|
@ -126,7 +126,7 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
if not os.path.isfile(core.CONFIG_SPEC_FILE):
|
||||
shutil.copyfile(core.CONFIG_FILE, core.CONFIG_SPEC_FILE)
|
||||
CFG_NEW = config(core.CONFIG_SPEC_FILE)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.debug("Error %s when copying to .spec" % (e))
|
||||
|
||||
# check for autoProcessMedia.cfg and autoProcessMedia.cfg.spec and if they don't exist return and fail
|
||||
|
@ -462,14 +462,14 @@ class ConfigObj(configobj.ConfigObj, Section):
|
|||
CFG_NEW[section][os.environ[envCatKey]][option] = value
|
||||
CFG_NEW[section][os.environ[envCatKey]]['enabled'] = 1
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.debug("Error %s when applying NZBGet config" % (e))
|
||||
|
||||
try:
|
||||
# write our new config to autoProcessMedia.cfg
|
||||
CFG_NEW.filename = core.CONFIG_FILE
|
||||
CFG_NEW.write()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.debug("Error %s when writing changes to .cfg" % (e))
|
||||
|
||||
return CFG_NEW
|
||||
|
|
|
@ -37,7 +37,7 @@ class DBConnection:
|
|||
result = None
|
||||
try:
|
||||
result = self.select("SELECT db_version FROM db_version")
|
||||
except sqlite3.OperationalError, e:
|
||||
except sqlite3.OperationalError as e:
|
||||
if "no such table: db_version" in e.args[0]:
|
||||
return 0
|
||||
|
||||
|
@ -68,7 +68,7 @@ class DBConnection:
|
|||
|
||||
# get out of the connection attempt loop since we were successful
|
||||
break
|
||||
except sqlite3.OperationalError, e:
|
||||
except sqlite3.OperationalError as e:
|
||||
if "unable to open database file" in e.args[0] or "database is locked" in e.args[0]:
|
||||
logger.log(u"DB error: " + str(e), logger.WARNING)
|
||||
attempt += 1
|
||||
|
@ -76,7 +76,7 @@ class DBConnection:
|
|||
else:
|
||||
logger.log(u"DB error: " + str(e), logger.ERROR)
|
||||
raise
|
||||
except sqlite3.DatabaseError, e:
|
||||
except sqlite3.DatabaseError as e:
|
||||
logger.log(u"Fatal error executing query: " + str(e), logger.ERROR)
|
||||
raise
|
||||
|
||||
|
@ -103,7 +103,7 @@ class DBConnection:
|
|||
self.connection.commit()
|
||||
logger.log(u"Transaction with " + str(len(querylist)) + u" query's executed", logger.DEBUG)
|
||||
return sqlResult
|
||||
except sqlite3.OperationalError, e:
|
||||
except sqlite3.OperationalError as e:
|
||||
sqlResult = []
|
||||
if self.connection:
|
||||
self.connection.rollback()
|
||||
|
@ -114,7 +114,7 @@ class DBConnection:
|
|||
else:
|
||||
logger.log(u"DB error: " + str(e), logger.ERROR)
|
||||
raise
|
||||
except sqlite3.DatabaseError, e:
|
||||
except sqlite3.DatabaseError as e:
|
||||
sqlResult = []
|
||||
if self.connection:
|
||||
self.connection.rollback()
|
||||
|
@ -141,7 +141,7 @@ class DBConnection:
|
|||
self.connection.commit()
|
||||
# get out of the connection attempt loop since we were successful
|
||||
break
|
||||
except sqlite3.OperationalError, e:
|
||||
except sqlite3.OperationalError as e:
|
||||
if "unable to open database file" in e.args[0] or "database is locked" in e.args[0]:
|
||||
logger.log(u"DB error: " + str(e), logger.WARNING)
|
||||
attempt += 1
|
||||
|
@ -149,7 +149,7 @@ class DBConnection:
|
|||
else:
|
||||
logger.log(u"DB error: " + str(e), logger.ERROR)
|
||||
raise
|
||||
except sqlite3.DatabaseError, e:
|
||||
except sqlite3.DatabaseError as e:
|
||||
logger.log(u"Fatal error executing query: " + str(e), logger.ERROR)
|
||||
raise
|
||||
|
||||
|
@ -228,7 +228,7 @@ def _processUpgrade(connection, upgradeClass):
|
|||
logger.log(u"Database upgrade required: " + prettyName(upgradeClass.__name__), logger.MESSAGE)
|
||||
try:
|
||||
instance.execute()
|
||||
except sqlite3.DatabaseError, e:
|
||||
except sqlite3.DatabaseError as e:
|
||||
print("Error in " + str(upgradeClass.__name__) + ": " + str(e))
|
||||
raise
|
||||
logger.log(upgradeClass.__name__ + " upgrade completed", logger.DEBUG)
|
||||
|
|
|
@ -64,7 +64,7 @@ def rename_file(filename, newfilePath):
|
|||
logger.debug("Replacing file name %s with download name %s" % (filename, newfilePath), "EXCEPTION")
|
||||
try:
|
||||
os.rename(filename, newfilePath)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.error("Unable to rename file due to: %s" % (str(e)), "EXCEPTION")
|
||||
|
||||
|
||||
|
@ -132,7 +132,7 @@ def rename_script(dirname):
|
|||
logger.debug("Renaming file %s to %s" % (orig, dest), "EXCEPTION")
|
||||
try:
|
||||
os.rename(orig, dest)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.error("Unable to rename file due to: %s" % (str(e)), "EXCEPTION")
|
||||
|
||||
# dict for custom groups
|
||||
|
|
|
@ -74,7 +74,7 @@ def makeDir(path):
|
|||
if not os.path.isdir(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -262,7 +262,7 @@ def copy_link(src, targetLink, useLink):
|
|||
logger.info("Moving SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
|
||||
shutil.move(src, targetLink)
|
||||
return True
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.warning("Error: %s, copying instead ... " % (e), 'COPYLINK')
|
||||
|
||||
logger.info("Copying SOURCE MEDIAFILE -> TARGET FOLDER", 'COPYLINK')
|
||||
|
@ -1104,7 +1104,7 @@ def extractFiles(src, dst=None, keep_archive=None):
|
|||
if extractor.extract(inputFile, dst or dirPath):
|
||||
extracted_folder.append(dst or dirPath)
|
||||
extracted_archive.append(archiveName)
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
logger.error("Extraction failed for: %s" % (fullFileName))
|
||||
|
||||
for folder in extracted_folder:
|
||||
|
@ -1197,7 +1197,7 @@ def backupVersionedFile(old_file, version):
|
|||
shutil.copy(old_file, new_file)
|
||||
logger.log(u"Backup done", logger.DEBUG)
|
||||
break
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.log(u"Error while trying to back up " + old_file + " to " + new_file + " : " + str(e),
|
||||
logger.WARNING)
|
||||
numTries += 1
|
||||
|
|
|
@ -40,7 +40,7 @@ class DelugeClient(object):
|
|||
from xdg.BaseDirectory import save_config_path
|
||||
try:
|
||||
auth_file = os.path.join(save_config_path("deluge"), "auth")
|
||||
except OSError, e:
|
||||
except OSError:
|
||||
return username, password
|
||||
|
||||
if os.path.exists(auth_file):
|
||||
|
@ -51,7 +51,7 @@ class DelugeClient(object):
|
|||
line = line.strip()
|
||||
try:
|
||||
lsplit = line.split(":")
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if len(lsplit) == 2:
|
||||
|
|
|
@ -763,10 +763,10 @@ def Transcode_directory(dirName):
|
|||
|
||||
try: # Try to remove the file that we're transcoding to just in case. (ffmpeg will return an error if it already exists for some reason)
|
||||
os.remove(newfilePath)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOENT: # Ignore the error if it's just telling us that the file doesn't exist
|
||||
logger.debug("Error when removing transcoding target: %s" % (e))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.debug("Error when removing transcoding target: %s" % (e))
|
||||
|
||||
logger.info("Transcoding video: %s" % (newfilePath))
|
||||
|
|
|
@ -312,7 +312,7 @@ class GitUpdateManager(UpdateManager):
|
|||
else:
|
||||
try:
|
||||
self._check_github_for_update()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.log(u"Unable to contact github, can't check for update: " + repr(e), logger.ERROR)
|
||||
return False
|
||||
|
||||
|
@ -356,7 +356,7 @@ class SourceUpdateManager(UpdateManager):
|
|||
try:
|
||||
with open(version_file, 'r') as fp:
|
||||
self._cur_commit_hash = fp.read().strip(' \n\r')
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
logger.log(u"Unable to open 'version.txt': " + str(e), logger.DEBUG)
|
||||
|
||||
if not self._cur_commit_hash:
|
||||
|
@ -370,7 +370,7 @@ class SourceUpdateManager(UpdateManager):
|
|||
|
||||
try:
|
||||
self._check_github_for_update()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.log(u"Unable to contact github, can't check for update: " + repr(e), logger.ERROR)
|
||||
return False
|
||||
|
||||
|
@ -504,7 +504,7 @@ class SourceUpdateManager(UpdateManager):
|
|||
os.chmod(new_path, stat.S_IWRITE)
|
||||
os.remove(new_path)
|
||||
os.renames(old_path, new_path)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.log(u"Unable to update " + new_path + ': ' + str(e), logger.DEBUG)
|
||||
os.remove(old_path) # Trash the updated file without moving in new path
|
||||
continue
|
||||
|
@ -517,11 +517,11 @@ class SourceUpdateManager(UpdateManager):
|
|||
try:
|
||||
with open(version_path, 'w') as ver_file:
|
||||
ver_file.write(self._newest_commit_hash)
|
||||
except EnvironmentError, e:
|
||||
except EnvironmentError as e:
|
||||
logger.log(u"Unable to write version file, update not complete: " + str(e), logger.ERROR)
|
||||
return False
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.log(u"Error while trying to update: " + str(e), logger.ERROR)
|
||||
logger.log(u"Traceback: " + traceback.format_exc(), logger.DEBUG)
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue