Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
logging.basicConfig(style='{', format='[{levelname:<7}] {message}', level=logging.DEBUG)
# Add a custom status level for logging what tockloader is doing.
logging.addLevelName(25, 'STATUS')
logging.Logger.status = functools.partialmethod(logging.Logger.log, 25)
logging.status = functools.partial(logging.log, 25)
# Create a common parent parser for arguments shared by all subparsers. In
# practice there are very few of these since tockloader supports a range of
# operations.
parent = argparse.ArgumentParser(add_help=False)
parent.add_argument('--debug',
action='store_true',
help='Print additional debugging information')
parent.add_argument('--version',
action='version',
version=__version__,
help='Print Tockloader version and exit')
# Get the list of arguments before any command
before_command_args = parent.parse_known_args()
# The top-level parser object
parser = argparse.ArgumentParser(parents=[parent])
# Parser for all app related commands
parent_apps = argparse.ArgumentParser(add_help=False)
parent_apps.add_argument('--app-address', '-a',
help='Address where apps are located',
type=lambda x: int(x, 0))
parent_apps.add_argument('--force',
help='Allow apps on boards that are not listed as compatible',
action='store_true')
def command_info (args):
tock_loader = TockLoader(args)
tock_loader.open()
print('tockloader version: {}'.format(__version__))
logging.status('Showing all properties of the board...')
tock_loader.info()