Adapts several py scripts to python3.
print -> print() subprocess.check_output return needs decoding from utf8 Queue -> queue
This commit is contained in:
committed by
Mario Sanchez Prada
parent
29d78118ce
commit
5300ddc222
@@ -22,7 +22,7 @@ def Main(argv):
|
||||
(options, args) = parser.parse_args(argv)
|
||||
|
||||
if len(args) > 0:
|
||||
print >> sys.stderr, parser.get_usage()
|
||||
print(parser.get_usage(), file=sys.stderr)
|
||||
return 1
|
||||
|
||||
# sign file with dsa
|
||||
|
||||
@@ -22,7 +22,7 @@ def Main(argv):
|
||||
(options, args) = parser.parse_args(argv)
|
||||
|
||||
if len(args) > 0:
|
||||
print >> sys.stderr, parser.get_usage()
|
||||
print(parser.get_usage(), file=sys.stderr)
|
||||
return 1
|
||||
|
||||
# sign file with eddsa
|
||||
|
||||
@@ -83,11 +83,11 @@ def Main(argv):
|
||||
(options, args) = parser.parse_args(argv)
|
||||
|
||||
if len(args) > 0:
|
||||
print >>sys.stderr, parser.get_usage()
|
||||
print(parser.get_usage(), file=sys.stderr)
|
||||
return 1
|
||||
|
||||
if not options.plist_path:
|
||||
print >>sys.stderr, 'No --plist specified.'
|
||||
print('No --plist specified.', file=sys.stderr)
|
||||
return 1
|
||||
|
||||
# Read the plist into its parsed format. Convert the file to 'xml1' as
|
||||
|
||||
@@ -27,7 +27,7 @@ def get_sign_cmd(file):
|
||||
def run_cmd(cmd):
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
for line in p.stdout:
|
||||
print line
|
||||
print(line)
|
||||
p.wait()
|
||||
assert p.returncode == 0, "Error signing"
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ platforms is planned.
|
||||
import errno
|
||||
import optparse
|
||||
import os
|
||||
import Queue
|
||||
import queue
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -40,7 +40,7 @@ def GetCommandOutput(command):
|
||||
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=devnull,
|
||||
bufsize=1)
|
||||
output = proc.communicate()[0]
|
||||
return output
|
||||
return output.decode('utf-8')
|
||||
|
||||
|
||||
def GetDumpSymsBinary(build_dir=None):
|
||||
@@ -48,7 +48,7 @@ def GetDumpSymsBinary(build_dir=None):
|
||||
DUMP_SYMS = 'dump_syms'
|
||||
dump_syms_bin = os.path.join(os.path.expanduser(build_dir), DUMP_SYMS)
|
||||
if not os.access(dump_syms_bin, os.X_OK):
|
||||
print 'Cannot find %s.' % DUMP_SYMS
|
||||
print("Cannot find {0}.".format(DUMP_SYMS))
|
||||
sys.exit(1)
|
||||
|
||||
return dump_syms_bin
|
||||
@@ -160,7 +160,7 @@ def GetSharedLibraryDependencies(options, binary, exe_path):
|
||||
elif sys.platform == 'darwin':
|
||||
deps = GetSharedLibraryDependenciesMac(binary, exe_path)
|
||||
else:
|
||||
print "Platform not supported."
|
||||
print("Platform not supported.")
|
||||
sys.exit(1)
|
||||
|
||||
result = []
|
||||
@@ -184,17 +184,17 @@ def mkdir_p(path):
|
||||
def GenerateSymbols(options, binaries):
|
||||
"""Dumps the symbols of binary and places them in the given directory."""
|
||||
|
||||
queue = Queue.Queue()
|
||||
q = queue.Queue()
|
||||
print_lock = threading.Lock()
|
||||
|
||||
def _Worker():
|
||||
while True:
|
||||
binary = queue.get()
|
||||
binary = q.get()
|
||||
|
||||
try:
|
||||
if options.verbose:
|
||||
with print_lock:
|
||||
print "Generating symbols for %s" % binary
|
||||
print("Generating symbols for {0}".format(binary))
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
binary = GetDSYMBundle(options, binary)
|
||||
@@ -214,20 +214,20 @@ def GenerateSymbols(options, binaries):
|
||||
except Exception as inst:
|
||||
if options.verbose:
|
||||
with print_lock:
|
||||
print type(inst)
|
||||
print inst
|
||||
print(type(inst))
|
||||
print(inst)
|
||||
finally:
|
||||
queue.task_done()
|
||||
q.task_done()
|
||||
|
||||
for binary in binaries:
|
||||
queue.put(binary)
|
||||
q.put(binary)
|
||||
|
||||
for _ in range(options.jobs):
|
||||
t = threading.Thread(target=_Worker)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
queue.join()
|
||||
q.join()
|
||||
|
||||
|
||||
def main():
|
||||
@@ -251,19 +251,19 @@ def main():
|
||||
(options, _) = parser.parse_args()
|
||||
|
||||
if not options.symbols_dir:
|
||||
print "Required option --symbols-dir missing."
|
||||
print("Required option --symbols-dir missing.")
|
||||
return 1
|
||||
|
||||
if not options.build_dir:
|
||||
print "Required option --build-dir missing."
|
||||
print("Required option --build-dir missing.")
|
||||
return 1
|
||||
|
||||
if not options.libchromiumcontent_dir:
|
||||
print "Required option --libchromiumcontent-dir missing."
|
||||
print("Required option --libchromiumcontent-dir missing.")
|
||||
return 1
|
||||
|
||||
if not options.binary:
|
||||
print "Required option --binary missing."
|
||||
print("Required option --binary missing.")
|
||||
return 1
|
||||
|
||||
if options.clear:
|
||||
|
||||
@@ -10,7 +10,7 @@ import errno
|
||||
import glob
|
||||
import optparse
|
||||
import os
|
||||
import Queue
|
||||
import queue
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -50,16 +50,16 @@ def mkdir_p(path):
|
||||
def GenerateSymbols(options, binaries):
|
||||
"""Dumps the symbols of binary and places them in the given directory."""
|
||||
|
||||
queue = Queue.Queue()
|
||||
q = queue.Queue()
|
||||
print_lock = threading.Lock()
|
||||
|
||||
def _Worker():
|
||||
while True:
|
||||
binary = queue.get()
|
||||
binary = q.get()
|
||||
|
||||
if options.verbose:
|
||||
with print_lock:
|
||||
print "Generating symbols for %s" % binary
|
||||
print("Generating symbols for {0}".format(binary))
|
||||
thread_start = datetime.utcnow()
|
||||
|
||||
dump_syms = os.path.join(options.build_dir, 'dump_syms.exe')
|
||||
@@ -67,8 +67,8 @@ def GenerateSymbols(options, binaries):
|
||||
module_line = re.match("MODULE [^ ]+ [^ ]+ ([0-9A-Fa-f]+) (.*)\r\n", syms)
|
||||
if module_line == None:
|
||||
with print_lock:
|
||||
print "Failed to get symbols for %s" % binary
|
||||
queue.task_done()
|
||||
print("Failed to get symbols for {0}".format(binary))
|
||||
q.task_done()
|
||||
continue
|
||||
|
||||
output_path = os.path.join(options.symbols_dir, module_line.group(2),
|
||||
@@ -85,17 +85,17 @@ def GenerateSymbols(options, binaries):
|
||||
elapsed = thread_end - thread_start
|
||||
print("Completed generating symbols for {}: elapsed time {} seconds".format(binary, elapsed.total_seconds()))
|
||||
|
||||
queue.task_done()
|
||||
q.task_done()
|
||||
|
||||
for binary in binaries:
|
||||
queue.put(binary)
|
||||
q.put(binary)
|
||||
|
||||
for _ in range(options.jobs):
|
||||
t = threading.Thread(target=_Worker)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
queue.join()
|
||||
q.join()
|
||||
|
||||
|
||||
def main():
|
||||
@@ -115,11 +115,11 @@ def main():
|
||||
(options, directories) = parser.parse_args()
|
||||
|
||||
if not options.build_dir:
|
||||
print "Required option --build-dir missing."
|
||||
print("Required option --build-dir missing.")
|
||||
return 1
|
||||
|
||||
if not options.symbols_dir:
|
||||
print "Required option --symbols-dir missing."
|
||||
print("Required option --symbols-dir missing.")
|
||||
return 1
|
||||
|
||||
if options.clear:
|
||||
|
||||
+2
-5
@@ -1,17 +1,14 @@
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
import sys
|
||||
import string
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
compile_model(args.model[0], args.output[0])
|
||||
|
||||
def compile_model(model, output):
|
||||
xcode = subprocess.check_output(['xcode-select', '-print-path'])
|
||||
subprocess.call(string.strip(xcode) + "/usr/bin/momc " + model + " " + output, shell=True)
|
||||
xcode = subprocess.check_output(['xcode-select', '-print-path']).decode('utf-8')
|
||||
subprocess.call(xcode.strip() + "/usr/bin/momc " + model + " " + output, shell=True)
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description='Compile a CoreData model')
|
||||
|
||||
Reference in New Issue
Block a user