aboutsummaryrefslogtreecommitdiff
path: root/ports/cc3200/tools/uniflash.py
diff options
context:
space:
mode:
Diffstat (limited to 'ports/cc3200/tools/uniflash.py')
-rw-r--r--ports/cc3200/tools/uniflash.py58
1 files changed, 46 insertions, 12 deletions
diff --git a/ports/cc3200/tools/uniflash.py b/ports/cc3200/tools/uniflash.py
index 21da46a56..0ce9d0703 100644
--- a/ports/cc3200/tools/uniflash.py
+++ b/ports/cc3200/tools/uniflash.py
@@ -19,7 +19,7 @@ import subprocess
def print_exception(e):
- print ('Exception: {}, on line {}'.format(e, sys.exc_info()[-1].tb_lineno))
+ print("Exception: {}, on line {}".format(e, sys.exc_info()[-1].tb_lineno))
def execute(command):
@@ -29,7 +29,7 @@ def execute(command):
# Poll process for new output until finished
while True:
nextline = process.stdout.readline()
- if nextline == '' and process.poll() != None:
+ if nextline == "" and process.poll() != None:
break
sys.stdout.write(nextline)
sys.stdout.flush()
@@ -43,25 +43,58 @@ def execute(command):
else:
raise ProcessException(command, exitCode, output)
+
def main():
- cmd_parser = argparse.ArgumentParser(description='Flash the WiPy and optionally run a small test on it.')
- cmd_parser.add_argument('-u', '--uniflash', default=None, help='the path to the uniflash cli executable')
- cmd_parser.add_argument('-c', '--config', default=None, help='the path to the uniflash config file')
- cmd_parser.add_argument('-p', '--port', default=8, help='the com serial port')
- cmd_parser.add_argument('-s', '--servicepack', default=None, help='the path to the servicepack file')
+ cmd_parser = argparse.ArgumentParser(
+ description="Flash the WiPy and optionally run a small test on it."
+ )
+ cmd_parser.add_argument(
+ "-u", "--uniflash", default=None, help="the path to the uniflash cli executable"
+ )
+ cmd_parser.add_argument(
+ "-c", "--config", default=None, help="the path to the uniflash config file"
+ )
+ cmd_parser.add_argument("-p", "--port", default=8, help="the com serial port")
+ cmd_parser.add_argument(
+ "-s", "--servicepack", default=None, help="the path to the servicepack file"
+ )
args = cmd_parser.parse_args()
output = ""
- com_port = 'com=' + str(args.port)
- servicepack_path = 'spPath=' + args.servicepack
+ com_port = "com=" + str(args.port)
+ servicepack_path = "spPath=" + args.servicepack
try:
if args.uniflash == None or args.config == None:
- raise ValueError('uniflash path and config path are mandatory')
+ raise ValueError("uniflash path and config path are mandatory")
if args.servicepack == None:
- output += execute([args.uniflash, '-config', args.config, '-setOptions', com_port, '-operations', 'format', 'program'])
+ output += execute(
+ [
+ args.uniflash,
+ "-config",
+ args.config,
+ "-setOptions",
+ com_port,
+ "-operations",
+ "format",
+ "program",
+ ]
+ )
else:
- output += execute([args.uniflash, '-config', args.config, '-setOptions', com_port, servicepack_path, '-operations', 'format', 'servicePackUpdate', 'program'])
+ output += execute(
+ [
+ args.uniflash,
+ "-config",
+ args.config,
+ "-setOptions",
+ com_port,
+ servicepack_path,
+ "-operations",
+ "format",
+ "servicePackUpdate",
+ "program",
+ ]
+ )
except Exception as e:
print_exception(e)
output = ""
@@ -77,5 +110,6 @@ def main():
print("======================================")
sys.exit(1)
+
if __name__ == "__main__":
main()