Fix exit codes.
This commit is contained in:
parent
5e0ff701da
commit
04a1e36a00
1 changed files with 8 additions and 9 deletions
17
main.py
17
main.py
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import functools
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
@ -121,7 +120,7 @@ def main(config, dryrun, level, range):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
logger.error('couldn\'t find valid adapter for source configuration %s', source)
|
logger.error('couldn\'t find valid adapter for source configuration %s', source)
|
||||||
return 1
|
sys.exit(1)
|
||||||
for sink in config['sinks']:
|
for sink in config['sinks']:
|
||||||
assert len(sink.keys()) == 1
|
assert len(sink.keys()) == 1
|
||||||
for aname, a in adapters.ADAPTERS.items():
|
for aname, a in adapters.ADAPTERS.items():
|
||||||
|
@ -130,19 +129,19 @@ def main(config, dryrun, level, range):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
logger.error('couldn\'t find valid adapter for sink configuration %s', sink)
|
logger.error('couldn\'t find valid adapter for sink configuration %s', sink)
|
||||||
return 1
|
sys.exit(1)
|
||||||
|
|
||||||
if not all([isinstance(x, adapters.Source) for x in sources]):
|
if not all([isinstance(x, adapters.Source) for x in sources]):
|
||||||
logger.error('one or more source configurations do not implement being a source')
|
logger.error('one or more source configurations do not implement being a source')
|
||||||
return 1
|
sys.exit(1)
|
||||||
if not all([isinstance(x, adapters.Sink) for x in sinks]):
|
if not all([isinstance(x, adapters.Sink) for x in sinks]):
|
||||||
logger.error('one or more sink configurations do not implement being a sink')
|
logger.error('one or more sink configurations do not implement being a sink')
|
||||||
return 1
|
sys.exit(1)
|
||||||
|
|
||||||
# log in
|
# log in
|
||||||
if not all([x.login() for x in sources | sinks]):
|
if not all([x.login() for x in sources | sinks]):
|
||||||
logger.error('failed to log into one or more sinks or sources')
|
logger.error('failed to log into one or more sinks or sources')
|
||||||
return 1
|
sys.exit(1)
|
||||||
|
|
||||||
# gather events
|
# gather events
|
||||||
events = []
|
events = []
|
||||||
|
@ -156,7 +155,7 @@ def main(config, dryrun, level, range):
|
||||||
source_results += [False]
|
source_results += [False]
|
||||||
if not any(source_results):
|
if not any(source_results):
|
||||||
logger.error('event get failed for all sources')
|
logger.error('event get failed for all sources')
|
||||||
return 1
|
sys.exit(1)
|
||||||
# filter cancelled events
|
# filter cancelled events
|
||||||
logger.info('found %d events', len(events))
|
logger.info('found %d events', len(events))
|
||||||
logger.info('not syncing cancelled events')
|
logger.info('not syncing cancelled events')
|
||||||
|
@ -177,10 +176,10 @@ def main(config, dryrun, level, range):
|
||||||
sink_results += [False]
|
sink_results += [False]
|
||||||
if not any(sink_results):
|
if not any(sink_results):
|
||||||
logger.error('event post failed for all sinks')
|
logger.error('event post failed for all sinks')
|
||||||
return 1
|
sys.exit(1)
|
||||||
|
|
||||||
logger.info("done")
|
logger.info("done")
|
||||||
return 0
|
sys.exit(0)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue