mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-23 06:25:22 -07:00
added debugging to resolve migration issues. helps #355
This commit is contained in:
parent
0fd1e832a1
commit
a8dbb36f6c
2 changed files with 19 additions and 20 deletions
|
@ -196,21 +196,17 @@ def initialize(section=None):
|
||||||
if not config.migrate():
|
if not config.migrate():
|
||||||
logger.error("Unable to migrate config file %s, exiting ..." % (CONFIG_FILE))
|
logger.error("Unable to migrate config file %s, exiting ..." % (CONFIG_FILE))
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
sys.exit(NZBGET_POSTPROCESS_ERROR)
|
pass # We will try and read config from Environment.
|
||||||
else:
|
else:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# run migrate to convert NzbGet data from old cfg style to new cfg style
|
# run migrate to convert NzbGet data from old cfg style to new cfg style
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
if not config.addnzbget():
|
CFG = config.addnzbget():
|
||||||
logger.error("Unable to migrate NzbGet config file %s, exiting ..." % (CONFIG_FILE))
|
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
else: # load newly migrated config
|
||||||
sys.exit(NZBGET_POSTPROCESS_ERROR)
|
logger.info("Loading config from [%s]" % (CONFIG_FILE))
|
||||||
else:
|
CFG = config()
|
||||||
sys.exit(-1)
|
|
||||||
# load newly migrated config
|
|
||||||
logger.info("Loading config from [%s]" % (CONFIG_FILE))
|
|
||||||
CFG = config()
|
|
||||||
|
|
||||||
# Enable/Disable DEBUG Logging
|
# Enable/Disable DEBUG Logging
|
||||||
LOG_DEBUG = int(CFG['General']['log_debug'])
|
LOG_DEBUG = int(CFG['General']['log_debug'])
|
||||||
|
|
|
@ -105,16 +105,16 @@ class ConfigObj(configobj.ConfigObj, Section):
|
||||||
if not os.path.isfile(nzbtomedia.CONFIG_FILE):
|
if not os.path.isfile(nzbtomedia.CONFIG_FILE):
|
||||||
shutil.copyfile(nzbtomedia.CONFIG_SPEC_FILE, nzbtomedia.CONFIG_FILE)
|
shutil.copyfile(nzbtomedia.CONFIG_SPEC_FILE, nzbtomedia.CONFIG_FILE)
|
||||||
CFG_OLD = config(nzbtomedia.CONFIG_FILE)
|
CFG_OLD = config(nzbtomedia.CONFIG_FILE)
|
||||||
except:
|
except Exception, e:
|
||||||
pass
|
logger.debug("Error %s when copying to .cfg" % (e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# check for autoProcessMedia.cfg.spec and create if it does not exist
|
# check for autoProcessMedia.cfg.spec and create if it does not exist
|
||||||
if not os.path.isfile(nzbtomedia.CONFIG_SPEC_FILE):
|
if not os.path.isfile(nzbtomedia.CONFIG_SPEC_FILE):
|
||||||
shutil.copyfile(nzbtomedia.CONFIG_FILE, nzbtomedia.CONFIG_SPEC_FILE)
|
shutil.copyfile(nzbtomedia.CONFIG_FILE, nzbtomedia.CONFIG_SPEC_FILE)
|
||||||
CFG_NEW = config(nzbtomedia.CONFIG_SPEC_FILE)
|
CFG_NEW = config(nzbtomedia.CONFIG_SPEC_FILE)
|
||||||
except:
|
except Exception, e:
|
||||||
pass
|
logger.debug("Error %s when copying to .cfg" % (e))
|
||||||
|
|
||||||
# check for autoProcessMedia.cfg and autoProcessMedia.cfg.spec and if they don't exist return and fail
|
# check for autoProcessMedia.cfg and autoProcessMedia.cfg.spec and if they don't exist return and fail
|
||||||
if CFG_NEW is None or CFG_OLD is None:
|
if CFG_NEW is None or CFG_OLD is None:
|
||||||
|
@ -358,14 +358,17 @@ class ConfigObj(configobj.ConfigObj, Section):
|
||||||
value = os.environ[key]
|
value = os.environ[key]
|
||||||
CFG_NEW[section][option] = value
|
CFG_NEW[section][option] = value
|
||||||
|
|
||||||
except:
|
except Exception, e:
|
||||||
return False
|
logger.debug("Error %s when applying NZBGet config" % (e))
|
||||||
|
|
||||||
# write our new config to autoProcessMedia.cfg
|
try:
|
||||||
CFG_NEW.filename = nzbtomedia.CONFIG_FILE
|
# write our new config to autoProcessMedia.cfg
|
||||||
CFG_NEW.write()
|
CFG_NEW.filename = nzbtomedia.CONFIG_FILE
|
||||||
|
CFG_NEW.write()
|
||||||
|
except Exception, e:
|
||||||
|
logger.debug("Error %s when writing changes to .cfg" % (e))
|
||||||
|
|
||||||
return True
|
return CFG_NEW
|
||||||
|
|
||||||
configobj.Section = Section
|
configobj.Section = Section
|
||||||
configobj.ConfigObj = ConfigObj
|
configobj.ConfigObj = ConfigObj
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue