mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 13:53:15 -07:00
clean exit for NZBGet.
This commit is contained in:
parent
5905622145
commit
e3f896d316
2 changed files with 15 additions and 4 deletions
|
@ -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))
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue