Browse Source

Tools: build-binaries and generate-manifest py3 fixes

zr-v5.1
Peter Barker 5 years ago committed by Peter Barker
parent
commit
1c772b94cd
  1. 10
      Tools/scripts/build_binaries.py
  2. 13
      Tools/scripts/generate_manifest.py

10
Tools/scripts/build_binaries.py

@ -22,6 +22,12 @@ import gzip @@ -22,6 +22,12 @@ import gzip
import generate_manifest, gen_stable
import build_binaries_history
if sys.version_info[0] < 3:
running_python3 = False
else:
running_python3 = True
class build_binaries(object):
def __init__(self, tags):
self.tags = tags
@ -77,6 +83,8 @@ class build_binaries(object): @@ -77,6 +83,8 @@ class build_binaries(object):
# select not available on Windows... probably...
time.sleep(0.1)
continue
if running_python3:
x = x.decode('ascii')
output += x
x = x.rstrip()
if show_output:
@ -702,6 +710,8 @@ is bob we will attempt to checkout bob-AVR''' @@ -702,6 +710,8 @@ is bob we will attempt to checkout bob-AVR'''
new_json_filepath_gz = os.path.join(self.binaries,
"manifest.json.gz.new")
with gzip.open(new_json_filepath_gz, 'wb') as gf:
if running_python3:
content = bytes(content, 'ascii')
gf.write(content)
json_filepath = os.path.join(self.binaries, "manifest.json")
json_filepath_gz = os.path.join(self.binaries, "manifest.json.gz")

13
Tools/scripts/generate_manifest.py

@ -10,6 +10,11 @@ import fnmatch @@ -10,6 +10,11 @@ import fnmatch
import gen_stable
import subprocess
if sys.version_info[0] < 3:
running_python3 = False
else:
running_python3 = True
FIRMWARE_TYPES = ["AntennaTracker", "Copter", "Plane", "Rover", "Sub", "AP_Periph"]
RELEASE_TYPES = ["beta", "latest", "stable", "stable-*", "dirty"]
@ -251,6 +256,9 @@ class ManifestGenerator(): @@ -251,6 +256,9 @@ class ManifestGenerator():
return "".join(filename.split(".")[-1:])
# no extension; ensure this is an elf:
text = subprocess.check_output(["file", "-b", filepath])
if running_python3:
text = text.decode('ascii')
if re.match("^ELF", text):
return "ELF"
print("Unknown file type (%s)" % filepath)
@ -507,5 +515,8 @@ if __name__ == "__main__": @@ -507,5 +515,8 @@ if __name__ == "__main__":
print(generator.json())
else:
f = open(args.outfile, "w")
f.write(generator.json())
content = generator.json()
if running_python3:
content = bytes(content, 'ascii')
f.write(content)
f.close()

Loading…
Cancel
Save