mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-19 17:23:25 +00:00
7ce305fca3
* C2OTA: wip * Update Cube to 1.13.3 * Fixed prio * Functional Core2 updater * Removed hardware CRC usage; code cleanup & linter fixes * Moved hardcoded stack params to copro.mk * Fixing CI bundling of core2 fw * Removed last traces of hardcoded radio stack * OB processing draft * Python scripts cleanup * Support for comments in ob data * Sacrificed SD card icon in favor of faster update. Waiting for Storage fix * Additional handling for OB mismatched values * Description for new furi_hal apis; spelling fixes * Rework of OB write, WIP * Properly restarting OB verification loop * Split update_task_workers.c * Checking OBs after enabling post-update mode * Moved OB verification before flashing * Removed ob.data for custom stacks * Fixed progress calculation for OB * Removed unnecessary OB mask cast Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
import logging
|
|
import argparse
|
|
import sys
|
|
import os
|
|
|
|
|
|
class App:
|
|
def __init__(self, no_exit=False):
|
|
# Argument Parser
|
|
self.no_exit = no_exit
|
|
self.parser = argparse.ArgumentParser()
|
|
self.parser.add_argument("-d", "--debug", action="store_true", help="Debug")
|
|
# Logging
|
|
self.logger = logging.getLogger()
|
|
# Application specific initialization
|
|
self.init()
|
|
|
|
def __call__(self, args=None):
|
|
self.args, self.other_args = self.parser.parse_known_args(args=args)
|
|
# configure log output
|
|
self.log_level = logging.DEBUG if self.args.debug else logging.INFO
|
|
self.logger.setLevel(self.log_level)
|
|
self.handler = logging.StreamHandler(sys.stdout)
|
|
self.handler.setLevel(self.log_level)
|
|
self.formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
|
|
self.handler.setFormatter(self.formatter)
|
|
self.logger.addHandler(self.handler)
|
|
|
|
# execute requested function
|
|
self.before()
|
|
return_code = self.call()
|
|
self.after()
|
|
if isinstance(return_code, int):
|
|
return self._exit(return_code)
|
|
else:
|
|
self.logger.error(f"Missing return code")
|
|
return self._exit(255)
|
|
|
|
def _exit(self, code):
|
|
if self.no_exit:
|
|
return code
|
|
exit(code)
|
|
|
|
def call(self):
|
|
if "func" not in self.args:
|
|
self.parser.error("Choose something to do")
|
|
return self.args.func()
|
|
|
|
def init(self):
|
|
raise Exception("init() is not implemented")
|
|
|
|
def before(self):
|
|
pass
|
|
|
|
def after(self):
|
|
pass
|