clean exit for NZBGet.

This commit is contained in:
clinton-hall 2014-04-30 13:30:46 +09:30
commit e3f896d316
2 changed files with 15 additions and 4 deletions

View file

@ -181,6 +181,9 @@ def initialize(section=None):
except: except:
print 'Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable' print 'Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable'
print 'or find another way to force Python to use ' + SYS_ENCODING + ' for string encoding.' print 'or find another way to force Python to use ' + SYS_ENCODING + ' for string encoding.'
if os.environ.has_key('NZBOP_SCRIPTDIR'):
sys.exit(NZBGET_POSTPROCESS_ERROR)
else:
sys.exit(1) sys.exit(1)
if not makeDir(LOG_DIR): if not makeDir(LOG_DIR):
@ -192,12 +195,18 @@ def initialize(section=None):
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options. # run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
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'):
sys.exit(NZBGET_POSTPROCESS_ERROR)
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(): if not config.addnzbget():
logger.error("Unable to migrate NzbGet config file %s, exiting ..." % (CONFIG_FILE)) logger.error("Unable to migrate NzbGet config file %s, exiting ..." % (CONFIG_FILE))
if os.environ.has_key('NZBOP_SCRIPTDIR'):
sys.exit(NZBGET_POSTPROCESS_ERROR)
else:
sys.exit(-1) sys.exit(-1)
# load newly migrated config # load newly migrated config
logger.info("Loading config from [%s]" % (CONFIG_FILE)) logger.info("Loading config from [%s]" % (CONFIG_FILE))

View file

@ -223,7 +223,9 @@ class NTMRotatingLogHandler(object):
def log_error_and_exit(self, error_msg): def log_error_and_exit(self, error_msg):
log(error_msg, ERROR) log(error_msg, ERROR)
if not self.console_logging: if os.environ.has_key('NZBOP_SCRIPTDIR'):
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
elif not self.console_logging:
sys.exit(error_msg.encode(nzbtomedia.SYS_ENCODING, 'xmlcharrefreplace')) sys.exit(error_msg.encode(nzbtomedia.SYS_ENCODING, 'xmlcharrefreplace'))
else: else:
sys.exit(1) sys.exit(1)