python3 fixes

This commit is contained in:
Thomas Gubler 2015-10-06 21:48:13 +02:00
parent a33568cd49
commit 2bbb1ad35f
3 changed files with 5 additions and 5 deletions

View File

@ -3,8 +3,8 @@ import xml.etree.ElementTree as ET
import os
if len(os.sys.argv) != 2:
print "Error in %s" % os.sys.argv[0]
print "Usage: %s <parameters.xml>"
print("Error in %s" % os.sys.argv[0])
print("Usage: %s <parameters.xml>" % os.sys.argv[0])
raise SystemExit
fp_header = open("px4_parameters.h", "w")

View File

@ -77,7 +77,7 @@ def main():
# overwrite old scratch file
with open(file_path, "wb") as f:
f.write(pruned_content)
f.write(pruned_content.encode("ascii", errors='strict'))
if __name__ == '__main__':

View File

@ -41,7 +41,7 @@ def run_cmd(cmd, d):
#print(cmd)
proc = subprocess.Popen(cmd.split(), stdout=PIPE, stderr=PIPE)
stdout, stderr = proc.communicate()
if stderr != "":
if stderr.decode() != "":
raise RuntimeError(stderr)
return stdout
@ -57,7 +57,7 @@ run_cmd("{ld:s} -r -o {obj:s}.bin.o {obj:s}.c.o -b binary {in_bin:s}",
stdout = run_cmd("{nm:s} -p --radix=x {obj:s}.bin.o", locals())
re_string = r"^([0-9A-F-a-f]+) .*{sym:s}_size\n".format(**locals())
re_size = re.compile(re_string, re.MULTILINE)
size_match = re.search(re_size, stdout)
size_match = re.search(re_size, stdout.decode())
try:
size = size_match.group(1)
except AttributeError as e: