Merge branch 'syno-debug' into dev

This commit is contained in:
clinton-hall 2014-05-16 15:24:20 +09:30
commit d01b721b0f
2 changed files with 20 additions and 20 deletions

View file

@ -198,19 +198,15 @@ 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)
else:
sys.exit(-1)
# load newly migrated config
logger.info("Loading config from [%s]" % (CONFIG_FILE)) logger.info("Loading config from [%s]" % (CONFIG_FILE))
CFG = config() CFG = config()

View file

@ -3,6 +3,7 @@ import shutil
import copy import copy
import nzbtomedia import nzbtomedia
from configobj import * from configobj import *
from nzbtomedia import logger
from itertools import chain from itertools import chain
@ -105,16 +106,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 .spec" % (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 +359,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))
try:
# write our new config to autoProcessMedia.cfg # write our new config to autoProcessMedia.cfg
CFG_NEW.filename = nzbtomedia.CONFIG_FILE CFG_NEW.filename = nzbtomedia.CONFIG_FILE
CFG_NEW.write() 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