mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 22:40:25 +00:00
[FL-1862] Scripts, ob.py: improved return of error codes #720
This commit is contained in:
parent
b3becb9d63
commit
0ff677b174
1 changed files with 16 additions and 13 deletions
|
@ -44,7 +44,13 @@ class Main:
|
|||
self.logger.addHandler(self.handler)
|
||||
# execute requested function
|
||||
self.loadOB()
|
||||
self.args.func()
|
||||
|
||||
return_code = self.args.func()
|
||||
if isinstance(return_code, int):
|
||||
return return_code
|
||||
else:
|
||||
self.logger.error(f"Forgotten return code")
|
||||
return 255
|
||||
|
||||
def loadOB(self):
|
||||
self.logger.info(f"Loading Option Bytes data")
|
||||
|
@ -70,13 +76,11 @@ class Main:
|
|||
except subprocess.CalledProcessError as e:
|
||||
self.logger.error(e.output.decode())
|
||||
self.logger.error(f"Failed to call STM32_Programmer_CLI")
|
||||
exit(127)
|
||||
return
|
||||
return 127
|
||||
except Exception as e:
|
||||
self.logger.error(f"Failed to call STM32_Programmer_CLI")
|
||||
self.logger.exception(e)
|
||||
exit(126)
|
||||
return
|
||||
return 126
|
||||
ob_correct = True
|
||||
for line in output.decode().split("\n"):
|
||||
line = line.strip()
|
||||
|
@ -100,10 +104,10 @@ class Main:
|
|||
ob_correct = False
|
||||
if ob_correct:
|
||||
self.logger.info(f"OB Check OK")
|
||||
exit(0)
|
||||
return 0
|
||||
else:
|
||||
self.logger.error(f"OB Check FAIL")
|
||||
exit(255)
|
||||
return 255
|
||||
|
||||
def set(self):
|
||||
self.logger.info(f"Setting Option Bytes")
|
||||
|
@ -127,15 +131,14 @@ class Main:
|
|||
except subprocess.CalledProcessError as e:
|
||||
self.logger.error(e.output.decode())
|
||||
self.logger.error(f"Failed to call STM32_Programmer_CLI")
|
||||
exit(125)
|
||||
return
|
||||
return 125
|
||||
except Exception as e:
|
||||
self.logger.error(f"Failed to call STM32_Programmer_CLI")
|
||||
self.logger.exception(e)
|
||||
exit(124)
|
||||
return
|
||||
return 124
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Main()()
|
||||
exit(0)
|
||||
return_code = Main()()
|
||||
exit(return_code)
|
||||
|
|
Loading…
Reference in a new issue