mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
Make px_mkfw.py and px_upload.py compatible with both python 2.7 and 3.3
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
# Copyright (C) 2012, 2013 PX4 Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -60,7 +60,7 @@ def mkdesc():
|
|||||||
proto['description'] = ""
|
proto['description'] = ""
|
||||||
proto['git_identity'] = ""
|
proto['git_identity'] = ""
|
||||||
proto['build_time'] = 0
|
proto['build_time'] = 0
|
||||||
proto['image'] = base64.b64encode(bytearray())
|
proto['image'] = bytes()
|
||||||
proto['image_size'] = 0
|
proto['image_size'] = 0
|
||||||
return proto
|
return proto
|
||||||
|
|
||||||
@@ -99,12 +99,12 @@ if args.description != None:
|
|||||||
if args.git_identity != None:
|
if args.git_identity != None:
|
||||||
cmd = " ".join(["git", "--git-dir", args.git_identity + "/.git", "describe", "--always", "--dirty"])
|
cmd = " ".join(["git", "--git-dir", args.git_identity + "/.git", "describe", "--always", "--dirty"])
|
||||||
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
|
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
|
||||||
desc['git_identity'] = p.read().strip()
|
desc['git_identity'] = str(p.read().strip())
|
||||||
p.close()
|
p.close()
|
||||||
if args.image != None:
|
if args.image != None:
|
||||||
f = open(args.image, "rb")
|
f = open(args.image, "rb")
|
||||||
bytes = f.read()
|
bytes = f.read()
|
||||||
desc['image_size'] = len(bytes)
|
desc['image_size'] = len(bytes)
|
||||||
desc['image'] = base64.b64encode(zlib.compress(bytes,9))
|
desc['image'] = base64.b64encode(zlib.compress(bytes,9)).decode('utf-8')
|
||||||
|
|
||||||
print(json.dumps(desc, indent=4))
|
print(json.dumps(desc, indent=4))
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
# Copyright (C) 2012, 2013 PX4 Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -102,7 +102,7 @@ class firmware(object):
|
|||||||
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
||||||
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d])
|
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d])
|
||||||
crcpad = bytearray('\xff\xff\xff\xff')
|
crcpad = bytearray(b'\xff\xff\xff\xff')
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user