Merge pull request #790 from hectorm/use-sys-exit

Use "sys.exit" instead of "exit" builtin
This commit is contained in:
Simone Margaritelli 2020-01-16 12:00:59 +01:00 committed by GitHub
commit 71de5925ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import argparse
import time import time
import yaml import yaml
import signal import signal
import sys
import pwnagotchi import pwnagotchi
import pwnagotchi.grid as grid import pwnagotchi.grid as grid
@ -19,7 +20,7 @@ from pwnagotchi import restart
def do_clear(display): def do_clear(display):
logging.info("clearing the display ...") logging.info("clearing the display ...")
display.clear() display.clear()
exit(0) sys.exit(0)
def do_manual_mode(agent): def do_manual_mode(agent):
@ -115,12 +116,12 @@ if __name__ == '__main__':
if args.version: if args.version:
print(pwnagotchi.version) print(pwnagotchi.version)
exit(0) sys.exit(0)
config = utils.load_config(args) config = utils.load_config(args)
if args.print_config: if args.print_config:
print(toml.dumps(config)) print(toml.dumps(config))
exit(0) sys.exit(0)
utils.setup_logging(args, config) utils.setup_logging(args, config)
@ -132,7 +133,7 @@ if __name__ == '__main__':
if args.do_clear: if args.do_clear:
do_clear(display) do_clear(display)
exit(0) sys.exit(0)
agent = Agent(view=display, config=config, keypair=KeyPair(view=display)) agent = Agent(view=display, config=config, keypair=KeyPair(view=display))

View File

@ -11,7 +11,7 @@ try:
from .gpio import GPIO from .gpio import GPIO
except: except:
print("unknown platform") print("unknown platform")
exit() sys.exit()
CONFIG_IL0376F = { CONFIG_IL0376F = {

View File

@ -13,6 +13,7 @@ import gzip
import contextlib import contextlib
import tempfile import tempfile
import toml import toml
import sys
import pwnagotchi import pwnagotchi
@ -92,7 +93,7 @@ def load_config(args):
config = merge_config(user_config, config) config = merge_config(user_config, config)
except Exception as ex: except Exception as ex:
logging.error("There was an error processing the configuration file:\n%s ",ex) logging.error("There was an error processing the configuration file:\n%s ",ex)
exit(1) sys.exit(1)
# the very first step is to normalize the display name so we don't need dozens of if/elif around # the very first step is to normalize the display name so we don't need dozens of if/elif around
if config['ui']['display']['type'] in ('inky', 'inkyphat'): if config['ui']['display']['type'] in ('inky', 'inkyphat'):
@ -139,7 +140,7 @@ def load_config(args):
else: else:
print("unsupported display type %s" % config['ui']['display']['type']) print("unsupported display type %s" % config['ui']['display']['type'])
exit(1) sys.exit(1)
return config return config