Tools: build-binaries and generate-manifest py3 fixes

This commit is contained in:
Peter Barker 2020-07-20 12:54:19 +10:00 committed by Peter Barker
parent de8439dc3a
commit 1c772b94cd
2 changed files with 22 additions and 1 deletions

View File

@ -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):
# 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'''
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")

View File

@ -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():
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__":
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()