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,7 +181,10 @@ def initialize(section=None):
except:
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.'
sys.exit(1)
if os.environ.has_key('NZBOP_SCRIPTDIR'):
sys.exit(NZBGET_POSTPROCESS_ERROR)
else:
sys.exit(1)
if not makeDir(LOG_DIR):
print("!!! No log folder, logging to screen only!")
@ -192,13 +195,19 @@ def initialize(section=None):
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
if not config.migrate():
logger.error("Unable to migrate config file %s, exiting ..." % (CONFIG_FILE))
sys.exit(-1)
if os.environ.has_key('NZBOP_SCRIPTDIR'):
sys.exit(NZBGET_POSTPROCESS_ERROR)
else:
sys.exit(-1)
# run migrate to convert NzbGet data from old cfg style to new cfg style
if os.environ.has_key('NZBOP_SCRIPTDIR'):
if not config.addnzbget():
logger.error("Unable to migrate NzbGet config file %s, exiting ..." % (CONFIG_FILE))
sys.exit(-1)
if os.environ.has_key('NZBOP_SCRIPTDIR'):
sys.exit(NZBGET_POSTPROCESS_ERROR)
else:
sys.exit(-1)
# load newly migrated config
logger.info("Loading config from [%s]" % (CONFIG_FILE))
CFG = config()

View file

@ -223,7 +223,9 @@ class NTMRotatingLogHandler(object):
def log_error_and_exit(self, error_msg):
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'))
else:
sys.exit(1)