scripts: python3: Use print function
Used print function instead of print statement to make the code work in python 3. (From OE-Core rev: 80fecc44761fa38ccf2e4dc6897b9f1f0c9c1ed0) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
79be110c1f
commit
2e388048b6
|
@ -27,7 +27,7 @@ obsolete_dirs = []
|
||||||
parser = None
|
parser = None
|
||||||
|
|
||||||
def err_quit(msg):
|
def err_quit(msg):
|
||||||
print msg
|
print(msg)
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ def run_command(cmd):
|
||||||
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
|
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
|
||||||
output = pipe.communicate()[0]
|
output = pipe.communicate()[0]
|
||||||
if pipe.returncode != 0:
|
if pipe.returncode != 0:
|
||||||
print "Execute command '%s' failed." % cmd
|
print("Execute command '%s' failed." % cmd)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ will be deleted. Be CAUTIOUS.""")
|
||||||
if os.getcwd() != builddir:
|
if os.getcwd() != builddir:
|
||||||
err_quit("Please run %s under: %s\n" % (os.path.basename(args[0]), builddir))
|
err_quit("Please run %s under: %s\n" % (os.path.basename(args[0]), builddir))
|
||||||
|
|
||||||
print 'Updating bitbake caches...'
|
print('Updating bitbake caches...')
|
||||||
cmd = "bitbake -s"
|
cmd = "bitbake -s"
|
||||||
output = run_command(cmd)
|
output = run_command(cmd)
|
||||||
|
|
||||||
|
@ -129,13 +129,13 @@ will be deleted. Be CAUTIOUS.""")
|
||||||
|
|
||||||
# won't fail just in case
|
# won't fail just in case
|
||||||
if not tmpdir or not image_rootfs:
|
if not tmpdir or not image_rootfs:
|
||||||
print "Can't get TMPDIR or IMAGE_ROOTFS."
|
print("Can't get TMPDIR or IMAGE_ROOTFS.")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
pattern = tmpdir + '/(.*?)/(.*?)/'
|
pattern = tmpdir + '/(.*?)/(.*?)/'
|
||||||
m = re.match(pattern, image_rootfs)
|
m = re.match(pattern, image_rootfs)
|
||||||
if not m:
|
if not m:
|
||||||
print "Can't get WORKDIR."
|
print("Can't get WORKDIR.")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
workdir = os.path.join(tmpdir, m.group(1))
|
workdir = os.path.join(tmpdir, m.group(1))
|
||||||
|
@ -178,13 +178,13 @@ will be deleted. Be CAUTIOUS.""")
|
||||||
break
|
break
|
||||||
|
|
||||||
for d in obsolete_dirs:
|
for d in obsolete_dirs:
|
||||||
print "Deleting %s" % d
|
print("Deleting %s" % d)
|
||||||
shutil.rmtree(d, True)
|
shutil.rmtree(d, True)
|
||||||
|
|
||||||
if len(obsolete_dirs):
|
if len(obsolete_dirs):
|
||||||
print '\nTotal %d items.' % len(obsolete_dirs)
|
print('\nTotal %d items.' % len(obsolete_dirs))
|
||||||
else:
|
else:
|
||||||
print '\nNo obsolete directory found under %s.' % workdir
|
print('\nNo obsolete directory found under %s.' % workdir)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
@ -519,7 +519,7 @@ def check_patch(patchfile):
|
||||||
|
|
||||||
def drop_to_shell(workdir=None):
|
def drop_to_shell(workdir=None):
|
||||||
if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
print "Not a TTY so can't drop to shell for resolution, exiting."
|
print("Not a TTY so can't drop to shell for resolution, exiting.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
shell = os.environ.get('SHELL', 'bash')
|
shell = os.environ.get('SHELL', 'bash')
|
||||||
|
@ -529,7 +529,7 @@ def drop_to_shell(workdir=None):
|
||||||
' exit 1 -- abort\n' % shell);
|
' exit 1 -- abort\n' % shell);
|
||||||
ret = subprocess.call([shell], cwd=workdir)
|
ret = subprocess.call([shell], cwd=workdir)
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
print "Aborting"
|
print("Aborting")
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -24,12 +24,12 @@ import os.path
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print 'Usage: %s -d FILENAME [-d FILENAME]* -m METADIR [-m MATADIR]*' % os.path.basename(sys.argv[0])
|
print('Usage: %s -d FILENAME [-d FILENAME]* -m METADIR [-m MATADIR]*' % os.path.basename(sys.argv[0]))
|
||||||
print ' -d FILENAME documentation file to search'
|
print(' -d FILENAME documentation file to search')
|
||||||
print ' -h, --help display this help and exit'
|
print(' -h, --help display this help and exit')
|
||||||
print ' -m METADIR meta directory to search for recipes'
|
print(' -m METADIR meta directory to search for recipes')
|
||||||
print ' -t FILENAME documentation config file (for doc tags)'
|
print(' -t FILENAME documentation config file (for doc tags)')
|
||||||
print ' -T Only display variables with doc tags (requires -t)'
|
print(' -T Only display variables with doc tags (requires -t)')
|
||||||
|
|
||||||
def recipe_bbvars(recipe):
|
def recipe_bbvars(recipe):
|
||||||
''' Return a unique set of every bbvar encountered in the recipe '''
|
''' Return a unique set of every bbvar encountered in the recipe '''
|
||||||
|
@ -38,8 +38,8 @@ def recipe_bbvars(recipe):
|
||||||
try:
|
try:
|
||||||
r = open(recipe)
|
r = open(recipe)
|
||||||
except IOError as (errno, strerror):
|
except IOError as (errno, strerror):
|
||||||
print 'WARNING: Failed to open recipe ', recipe
|
print('WARNING: Failed to open recipe ', recipe)
|
||||||
print strerror
|
print(strerror)
|
||||||
|
|
||||||
for line in r:
|
for line in r:
|
||||||
# Strip any comments from the line
|
# Strip any comments from the line
|
||||||
|
@ -72,8 +72,8 @@ def bbvar_is_documented(var, docfiles):
|
||||||
try:
|
try:
|
||||||
f = open(doc)
|
f = open(doc)
|
||||||
except IOError as (errno, strerror):
|
except IOError as (errno, strerror):
|
||||||
print 'WARNING: Failed to open doc ', doc
|
print('WARNING: Failed to open doc ', doc)
|
||||||
print strerror
|
print(strerror)
|
||||||
for line in f:
|
for line in f:
|
||||||
if prog.match(line):
|
if prog.match(line):
|
||||||
return True
|
return True
|
||||||
|
@ -110,7 +110,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "d:hm:t:T", ["help"])
|
opts, args = getopt.getopt(sys.argv[1:], "d:hm:t:T", ["help"])
|
||||||
except getopt.GetoptError, err:
|
except getopt.GetoptError, err:
|
||||||
print '%s' % str(err)
|
print('%s' % str(err))
|
||||||
usage()
|
usage()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
@ -122,13 +122,13 @@ def main():
|
||||||
if os.path.isfile(a):
|
if os.path.isfile(a):
|
||||||
docfiles.append(a)
|
docfiles.append(a)
|
||||||
else:
|
else:
|
||||||
print 'ERROR: documentation file %s is not a regular file' % (a)
|
print('ERROR: documentation file %s is not a regular file' % a)
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
elif o == '-m':
|
elif o == '-m':
|
||||||
if os.path.isdir(a):
|
if os.path.isdir(a):
|
||||||
metadirs.append(a)
|
metadirs.append(a)
|
||||||
else:
|
else:
|
||||||
print 'ERROR: meta directory %s is not a directory' % (a)
|
print('ERROR: meta directory %s is not a directory' % a)
|
||||||
sys.exit(4)
|
sys.exit(4)
|
||||||
elif o == "-t":
|
elif o == "-t":
|
||||||
if os.path.isfile(a):
|
if os.path.isfile(a):
|
||||||
|
@ -139,17 +139,17 @@ def main():
|
||||||
assert False, "unhandled option"
|
assert False, "unhandled option"
|
||||||
|
|
||||||
if len(docfiles) == 0:
|
if len(docfiles) == 0:
|
||||||
print 'ERROR: no docfile specified'
|
print('ERROR: no docfile specified')
|
||||||
usage()
|
usage()
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
if len(metadirs) == 0:
|
if len(metadirs) == 0:
|
||||||
print 'ERROR: no metadir specified'
|
print('ERROR: no metadir specified')
|
||||||
usage()
|
usage()
|
||||||
sys.exit(6)
|
sys.exit(6)
|
||||||
|
|
||||||
if onlydoctags and docconf == "":
|
if onlydoctags and docconf == "":
|
||||||
print 'ERROR: no docconf specified'
|
print('ERROR: no docconf specified')
|
||||||
usage()
|
usage()
|
||||||
sys.exit(7)
|
sys.exit(7)
|
||||||
|
|
||||||
|
@ -172,14 +172,14 @@ def main():
|
||||||
varlen = varlen + 1
|
varlen = varlen + 1
|
||||||
|
|
||||||
# Report all undocumented variables
|
# Report all undocumented variables
|
||||||
print 'Found %d undocumented bb variables (out of %d):' % (len(undocumented), len(bbvars))
|
print('Found %d undocumented bb variables (out of %d):' % (len(undocumented), len(bbvars)))
|
||||||
header = '%s%s%s' % (str("VARIABLE").ljust(varlen), str("COUNT").ljust(6), str("DOCTAG").ljust(7))
|
header = '%s%s%s' % (str("VARIABLE").ljust(varlen), str("COUNT").ljust(6), str("DOCTAG").ljust(7))
|
||||||
print header
|
print(header)
|
||||||
print str("").ljust(len(header), '=')
|
print(str("").ljust(len(header), '='))
|
||||||
for v in undocumented:
|
for v in undocumented:
|
||||||
doctag = bbvar_doctag(v, docconf)
|
doctag = bbvar_doctag(v, docconf)
|
||||||
if not onlydoctags or not doctag == "":
|
if not onlydoctags or not doctag == "":
|
||||||
print '%s%s%s' % (v.ljust(varlen), str(bbvars[v]).ljust(6), doctag)
|
print('%s%s%s' % (v.ljust(varlen), str(bbvars[v]).ljust(6), doctag))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -104,8 +104,8 @@ def display_pkgs(pkg_dict):
|
||||||
pkgname_len += 1
|
pkgname_len += 1
|
||||||
|
|
||||||
header = '%-*s%s' % (pkgname_len, str("RECIPE NAME"), str("PACKAGECONFIG FLAGS"))
|
header = '%-*s%s' % (pkgname_len, str("RECIPE NAME"), str("PACKAGECONFIG FLAGS"))
|
||||||
print header
|
print(header)
|
||||||
print str("").ljust(len(header), '=')
|
print(str("").ljust(len(header), '='))
|
||||||
for pkgname in sorted(pkg_dict):
|
for pkgname in sorted(pkg_dict):
|
||||||
print('%-*s%s' % (pkgname_len, pkgname, ' '.join(pkg_dict[pkgname])))
|
print('%-*s%s' % (pkgname_len, pkgname, ' '.join(pkg_dict[pkgname])))
|
||||||
|
|
||||||
|
@ -115,18 +115,18 @@ def display_flags(flag_dict):
|
||||||
flag_len = len("PACKAGECONFIG FLAG") + 5
|
flag_len = len("PACKAGECONFIG FLAG") + 5
|
||||||
|
|
||||||
header = '%-*s%s' % (flag_len, str("PACKAGECONFIG FLAG"), str("RECIPE NAMES"))
|
header = '%-*s%s' % (flag_len, str("PACKAGECONFIG FLAG"), str("RECIPE NAMES"))
|
||||||
print header
|
print(header)
|
||||||
print str("").ljust(len(header), '=')
|
print(str("").ljust(len(header), '='))
|
||||||
|
|
||||||
for flag in sorted(flag_dict):
|
for flag in sorted(flag_dict):
|
||||||
print('%-*s%s' % (flag_len, flag, ' '.join(sorted(flag_dict[flag]))))
|
print('%-*s%s' % (flag_len, flag, ' '.join(sorted(flag_dict[flag]))))
|
||||||
|
|
||||||
def display_all(data_dict):
|
def display_all(data_dict):
|
||||||
''' Display all pkgs and PACKAGECONFIG information '''
|
''' Display all pkgs and PACKAGECONFIG information '''
|
||||||
print str("").ljust(50, '=')
|
print(str("").ljust(50, '='))
|
||||||
for fn in data_dict:
|
for fn in data_dict:
|
||||||
print('%s' % data_dict[fn].getVar("P", True))
|
print('%s' % data_dict[fn].getVar("P", True))
|
||||||
print fn
|
print(fn)
|
||||||
packageconfig = data_dict[fn].getVar("PACKAGECONFIG", True) or ''
|
packageconfig = data_dict[fn].getVar("PACKAGECONFIG", True) or ''
|
||||||
if packageconfig.strip() == '':
|
if packageconfig.strip() == '':
|
||||||
packageconfig = 'None'
|
packageconfig = 'None'
|
||||||
|
@ -136,7 +136,7 @@ def display_all(data_dict):
|
||||||
if flag == "doc":
|
if flag == "doc":
|
||||||
continue
|
continue
|
||||||
print('PACKAGECONFIG[%s] %s' % (flag, flag_val))
|
print('PACKAGECONFIG[%s] %s' % (flag, flag_val))
|
||||||
print ''
|
print('')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
pkg_dict = {}
|
pkg_dict = {}
|
||||||
|
|
|
@ -108,7 +108,7 @@ def prepare_data(args):
|
||||||
if max_log_size != 0:
|
if max_log_size != 0:
|
||||||
for fail in jsondata['failures']:
|
for fail in jsondata['failures']:
|
||||||
if len(fail['log']) > max_log_size:
|
if len(fail['log']) > max_log_size:
|
||||||
print "Truncating log to allow for upload"
|
print("Truncating log to allow for upload")
|
||||||
fail['log'] = fail['log'][-max_log_size:]
|
fail['log'] = fail['log'][-max_log_size:]
|
||||||
|
|
||||||
data = json.dumps(jsondata, indent=4, sort_keys=True)
|
data = json.dumps(jsondata, indent=4, sort_keys=True)
|
||||||
|
@ -143,7 +143,7 @@ def send_data(data, args):
|
||||||
logging.error(e.reason)
|
logging.error(e.reason)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print response.read()
|
print(response.read())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -192,7 +192,7 @@ if __name__ == '__main__':
|
||||||
args = arg_parse.parse_args()
|
args = arg_parse.parse_args()
|
||||||
|
|
||||||
if (args.json == False):
|
if (args.json == False):
|
||||||
print "Preparing to send errors to: "+args.server
|
print("Preparing to send errors to: "+args.server)
|
||||||
|
|
||||||
data = prepare_data(args)
|
data = prepare_data(args)
|
||||||
send_data(data, args)
|
send_data(data, args)
|
||||||
|
|
|
@ -289,7 +289,7 @@ class HwAuto():
|
||||||
result = bitbake("%s -c testimage" % image_type, ignore_status=True, postconfig=postconfig)
|
result = bitbake("%s -c testimage" % image_type, ignore_status=True, postconfig=postconfig)
|
||||||
testimage_results = ftools.read_file(os.path.join(get_bb_var("T", image_type), "log.do_testimage"))
|
testimage_results = ftools.read_file(os.path.join(get_bb_var("T", image_type), "log.do_testimage"))
|
||||||
log.info('Runtime tests results for %s:' % image_type)
|
log.info('Runtime tests results for %s:' % image_type)
|
||||||
print testimage_results
|
print(testimage_results)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Start the procedure!
|
# Start the procedure!
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Record:
|
||||||
total = 0
|
total = 0
|
||||||
if self.size <= minsize:
|
if self.size <= minsize:
|
||||||
return 0
|
return 0
|
||||||
print "%10d %s" % (self.size, self.path)
|
print("%10d %s" % (self.size, self.path))
|
||||||
for r in self.records:
|
for r in self.records:
|
||||||
total += r.show(minsize)
|
total += r.show(minsize)
|
||||||
if len(self.records) == 0:
|
if len(self.records) == 0:
|
||||||
|
@ -85,8 +85,8 @@ def main():
|
||||||
minsize = int(sys.argv[1])
|
minsize = int(sys.argv[1])
|
||||||
rootfs = Record.create(".")
|
rootfs = Record.create(".")
|
||||||
total = rootfs.show(minsize)
|
total = rootfs.show(minsize)
|
||||||
print "Displayed %d/%d bytes (%.2f%%)" % \
|
print("Displayed %d/%d bytes (%.2f%%)" % \
|
||||||
(total, rootfs.size, 100 * float(total) / rootfs.size)
|
(total, rootfs.size, 100 * float(total) / rootfs.size))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -33,11 +33,11 @@ from string import join
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
prog = os.path.basename(sys.argv[0])
|
prog = os.path.basename(sys.argv[0])
|
||||||
print 'Usage: %s [OPTION]...' % (prog)
|
print('Usage: %s [OPTION]...' % prog)
|
||||||
print ' -d, display an additional level of drivers detail'
|
print(' -d, display an additional level of drivers detail')
|
||||||
print ' -h, --help display this help and exit'
|
print(' -h, --help display this help and exit')
|
||||||
print ''
|
print('')
|
||||||
print 'Run %s from the top-level Linux kernel build directory.' % (prog)
|
print('Run %s from the top-level Linux kernel build directory.' % prog)
|
||||||
|
|
||||||
|
|
||||||
class Sizes:
|
class Sizes:
|
||||||
|
@ -55,8 +55,8 @@ class Sizes:
|
||||||
self.text = self.data = self.bss = self.total = 0
|
self.text = self.data = self.bss = self.total = 0
|
||||||
|
|
||||||
def show(self, indent=""):
|
def show(self, indent=""):
|
||||||
print "%-32s %10d | %10d %10d %10d" % \
|
print("%-32s %10d | %10d %10d %10d" % \
|
||||||
(indent+self.title, self.total, self.text, self.data, self.bss)
|
(indent+self.title, self.total, self.text, self.data, self.bss))
|
||||||
|
|
||||||
|
|
||||||
class Report:
|
class Report:
|
||||||
|
@ -101,22 +101,22 @@ class Report:
|
||||||
|
|
||||||
def show(self, indent=""):
|
def show(self, indent=""):
|
||||||
rule = str.ljust(indent, 80, '-')
|
rule = str.ljust(indent, 80, '-')
|
||||||
print "%-32s %10s | %10s %10s %10s" % \
|
print("%-32s %10s | %10s %10s %10s" % \
|
||||||
(indent+self.title, "total", "text", "data", "bss")
|
(indent+self.title, "total", "text", "data", "bss"))
|
||||||
print rule
|
print(rule)
|
||||||
self.sizes.show(indent)
|
self.sizes.show(indent)
|
||||||
print rule
|
print(rule)
|
||||||
for p in self.parts:
|
for p in self.parts:
|
||||||
if p.sizes.total > 0:
|
if p.sizes.total > 0:
|
||||||
p.sizes.show(indent)
|
p.sizes.show(indent)
|
||||||
print rule
|
print(rule)
|
||||||
print "%-32s %10d | %10d %10d %10d" % \
|
print("%-32s %10d | %10d %10d %10d" % \
|
||||||
(indent+"sum", self.totals["total"], self.totals["text"],
|
(indent+"sum", self.totals["total"], self.totals["text"],
|
||||||
self.totals["data"], self.totals["bss"])
|
self.totals["data"], self.totals["bss"]))
|
||||||
print "%-32s %10d | %10d %10d %10d" % \
|
print("%-32s %10d | %10d %10d %10d" % \
|
||||||
(indent+"delta", self.deltas["total"], self.deltas["text"],
|
(indent+"delta", self.deltas["total"], self.deltas["text"],
|
||||||
self.deltas["data"], self.deltas["bss"])
|
self.deltas["data"], self.deltas["bss"]))
|
||||||
print "\n"
|
print("\n")
|
||||||
|
|
||||||
def __cmp__(this, that):
|
def __cmp__(this, that):
|
||||||
if that is None:
|
if that is None:
|
||||||
|
@ -134,7 +134,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "dh", ["help"])
|
opts, args = getopt.getopt(sys.argv[1:], "dh", ["help"])
|
||||||
except getopt.GetoptError, err:
|
except getopt.GetoptError, err:
|
||||||
print '%s' % str(err)
|
print('%s' % str(err))
|
||||||
usage()
|
usage()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue