summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-05-30 18:14:46 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-01 12:46:46 +0100
commit80fecc44761fa38ccf2e4dc6897b9f1f0c9c1ed0 (patch)
treec21ed55e063e7c77be81bc2f433f3befabbfa8be /scripts
parent98a4c642444a524f547f5d978a28814d20c12354 (diff)
downloadopenembedded-core-80fecc44761fa38ccf2e4dc6897b9f1f0c9c1ed0.tar.gz
openembedded-core-80fecc44761fa38ccf2e4dc6897b9f1f0c9c1ed0.tar.bz2
openembedded-core-80fecc44761fa38ccf2e4dc6897b9f1f0c9c1ed0.zip
scripts: python3: Use print function
Used print function instead of print statement to make the code work in python 3. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cleanup-workdir16
-rwxr-xr-xscripts/combo-layer4
-rwxr-xr-xscripts/contrib/bbvars.py40
-rwxr-xr-xscripts/contrib/list-packageconfig-flags.py14
-rwxr-xr-xscripts/send-error-report6
-rwxr-xr-xscripts/test-remote-image2
-rwxr-xr-xscripts/tiny/dirsize.py6
-rwxr-xr-xscripts/tiny/ksize.py36
8 files changed, 62 insertions, 62 deletions
diff --git a/scripts/cleanup-workdir b/scripts/cleanup-workdir
index 01ebd526e3..fee464c31d 100755
--- a/scripts/cleanup-workdir
+++ b/scripts/cleanup-workdir
@@ -27,7 +27,7 @@ obsolete_dirs = []
parser = None
def err_quit(msg):
- print msg
+ print(msg)
parser.print_usage()
sys.exit(1)
@@ -43,7 +43,7 @@ def run_command(cmd):
pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
output = pipe.communicate()[0]
if pipe.returncode != 0:
- print "Execute command '%s' failed." % cmd
+ print("Execute command '%s' failed." % cmd)
sys.exit(1)
return output
@@ -84,7 +84,7 @@ will be deleted. Be CAUTIOUS.""")
if os.getcwd() != 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"
output = run_command(cmd)
@@ -129,13 +129,13 @@ will be deleted. Be CAUTIOUS.""")
# won't fail just in case
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
pattern = tmpdir + '/(.*?)/(.*?)/'
m = re.match(pattern, image_rootfs)
if not m:
- print "Can't get WORKDIR."
+ print("Can't get WORKDIR.")
return 1
workdir = os.path.join(tmpdir, m.group(1))
@@ -178,13 +178,13 @@ will be deleted. Be CAUTIOUS.""")
break
for d in obsolete_dirs:
- print "Deleting %s" % d
+ print("Deleting %s" % d)
shutil.rmtree(d, True)
if len(obsolete_dirs):
- print '\nTotal %d items.' % len(obsolete_dirs)
+ print('\nTotal %d items.' % len(obsolete_dirs))
else:
- print '\nNo obsolete directory found under %s.' % workdir
+ print('\nNo obsolete directory found under %s.' % workdir)
return 0
diff --git a/scripts/combo-layer b/scripts/combo-layer
index 1ca2ce6c02..e47059290d 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -519,7 +519,7 @@ def check_patch(patchfile):
def drop_to_shell(workdir=None):
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
shell = os.environ.get('SHELL', 'bash')
@@ -529,7 +529,7 @@ def drop_to_shell(workdir=None):
' exit 1 -- abort\n' % shell);
ret = subprocess.call([shell], cwd=workdir)
if ret != 0:
- print "Aborting"
+ print("Aborting")
return False
else:
return True
diff --git a/scripts/contrib/bbvars.py b/scripts/contrib/bbvars.py
index 0896d64445..04f5023969 100755
--- a/scripts/contrib/bbvars.py
+++ b/scripts/contrib/bbvars.py
@@ -24,12 +24,12 @@ import os.path
import re
def usage():
- 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 ' -h, --help display this help and exit'
- print ' -m METADIR meta directory to search for recipes'
- print ' -t FILENAME documentation config file (for doc tags)'
- print ' -T Only display variables with doc tags (requires -t)'
+ 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(' -h, --help display this help and exit')
+ print(' -m METADIR meta directory to search for recipes')
+ print(' -t FILENAME documentation config file (for doc tags)')
+ print(' -T Only display variables with doc tags (requires -t)')
def recipe_bbvars(recipe):
''' Return a unique set of every bbvar encountered in the recipe '''
@@ -38,8 +38,8 @@ def recipe_bbvars(recipe):
try:
r = open(recipe)
except IOError as (errno, strerror):
- print 'WARNING: Failed to open recipe ', recipe
- print strerror
+ print('WARNING: Failed to open recipe ', recipe)
+ print(strerror)
for line in r:
# Strip any comments from the line
@@ -72,8 +72,8 @@ def bbvar_is_documented(var, docfiles):
try:
f = open(doc)
except IOError as (errno, strerror):
- print 'WARNING: Failed to open doc ', doc
- print strerror
+ print('WARNING: Failed to open doc ', doc)
+ print(strerror)
for line in f:
if prog.match(line):
return True
@@ -110,7 +110,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "d:hm:t:T", ["help"])
except getopt.GetoptError, err:
- print '%s' % str(err)
+ print('%s' % str(err))
usage()
sys.exit(2)
@@ -122,13 +122,13 @@ def main():
if os.path.isfile(a):
docfiles.append(a)
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)
elif o == '-m':
if os.path.isdir(a):
metadirs.append(a)
else:
- print 'ERROR: meta directory %s is not a directory' % (a)
+ print('ERROR: meta directory %s is not a directory' % a)
sys.exit(4)
elif o == "-t":
if os.path.isfile(a):
@@ -139,17 +139,17 @@ def main():
assert False, "unhandled option"
if len(docfiles) == 0:
- print 'ERROR: no docfile specified'
+ print('ERROR: no docfile specified')
usage()
sys.exit(5)
if len(metadirs) == 0:
- print 'ERROR: no metadir specified'
+ print('ERROR: no metadir specified')
usage()
sys.exit(6)
if onlydoctags and docconf == "":
- print 'ERROR: no docconf specified'
+ print('ERROR: no docconf specified')
usage()
sys.exit(7)
@@ -172,14 +172,14 @@ def main():
varlen = varlen + 1
# 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))
- print header
- print str("").ljust(len(header), '=')
+ print(header)
+ print(str("").ljust(len(header), '='))
for v in undocumented:
doctag = bbvar_doctag(v, docconf)
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__":
diff --git a/scripts/contrib/list-packageconfig-flags.py b/scripts/contrib/list-packageconfig-flags.py
index 2f3b8b06a6..5dfe796c0a 100755
--- a/scripts/contrib/list-packageconfig-flags.py
+++ b/scripts/contrib/list-packageconfig-flags.py
@@ -104,8 +104,8 @@ def display_pkgs(pkg_dict):
pkgname_len += 1
header = '%-*s%s' % (pkgname_len, str("RECIPE NAME"), str("PACKAGECONFIG FLAGS"))
- print header
- print str("").ljust(len(header), '=')
+ print(header)
+ print(str("").ljust(len(header), '='))
for pkgname in sorted(pkg_dict):
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
header = '%-*s%s' % (flag_len, str("PACKAGECONFIG FLAG"), str("RECIPE NAMES"))
- print header
- print str("").ljust(len(header), '=')
+ print(header)
+ print(str("").ljust(len(header), '='))
for flag in sorted(flag_dict):
print('%-*s%s' % (flag_len, flag, ' '.join(sorted(flag_dict[flag]))))
def display_all(data_dict):
''' Display all pkgs and PACKAGECONFIG information '''
- print str("").ljust(50, '=')
+ print(str("").ljust(50, '='))
for fn in data_dict:
print('%s' % data_dict[fn].getVar("P", True))
- print fn
+ print(fn)
packageconfig = data_dict[fn].getVar("PACKAGECONFIG", True) or ''
if packageconfig.strip() == '':
packageconfig = 'None'
@@ -136,7 +136,7 @@ def display_all(data_dict):
if flag == "doc":
continue
print('PACKAGECONFIG[%s] %s' % (flag, flag_val))
- print ''
+ print('')
def main():
pkg_dict = {}
diff --git a/scripts/send-error-report b/scripts/send-error-report
index a29feff325..ed78bd6ebb 100755
--- a/scripts/send-error-report
+++ b/scripts/send-error-report
@@ -108,7 +108,7 @@ def prepare_data(args):
if max_log_size != 0:
for fail in jsondata['failures']:
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:]
data = json.dumps(jsondata, indent=4, sort_keys=True)
@@ -143,7 +143,7 @@ def send_data(data, args):
logging.error(e.reason)
sys.exit(1)
- print response.read()
+ print(response.read())
if __name__ == '__main__':
@@ -192,7 +192,7 @@ if __name__ == '__main__':
args = arg_parse.parse_args()
if (args.json == False):
- print "Preparing to send errors to: "+args.server
+ print("Preparing to send errors to: "+args.server)
data = prepare_data(args)
send_data(data, args)
diff --git a/scripts/test-remote-image b/scripts/test-remote-image
index 9c5b0158d5..7a00db92c0 100755
--- a/scripts/test-remote-image
+++ b/scripts/test-remote-image
@@ -289,7 +289,7 @@ class HwAuto():
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"))
log.info('Runtime tests results for %s:' % image_type)
- print testimage_results
+ print(testimage_results)
return result
# Start the procedure!
diff --git a/scripts/tiny/dirsize.py b/scripts/tiny/dirsize.py
index 40ff4ab895..5329b86f75 100755
--- a/scripts/tiny/dirsize.py
+++ b/scripts/tiny/dirsize.py
@@ -71,7 +71,7 @@ class Record:
total = 0
if self.size <= minsize:
return 0
- print "%10d %s" % (self.size, self.path)
+ print("%10d %s" % (self.size, self.path))
for r in self.records:
total += r.show(minsize)
if len(self.records) == 0:
@@ -85,8 +85,8 @@ def main():
minsize = int(sys.argv[1])
rootfs = Record.create(".")
total = rootfs.show(minsize)
- print "Displayed %d/%d bytes (%.2f%%)" % \
- (total, rootfs.size, 100 * float(total) / rootfs.size)
+ print("Displayed %d/%d bytes (%.2f%%)" % \
+ (total, rootfs.size, 100 * float(total) / rootfs.size))
if __name__ == "__main__":
diff --git a/scripts/tiny/ksize.py b/scripts/tiny/ksize.py
index 4006f2f6f1..275c983b8d 100755
--- a/scripts/tiny/ksize.py
+++ b/scripts/tiny/ksize.py
@@ -33,11 +33,11 @@ from string import join
def usage():
prog = os.path.basename(sys.argv[0])
- print 'Usage: %s [OPTION]...' % (prog)
- print ' -d, display an additional level of drivers detail'
- print ' -h, --help display this help and exit'
- print ''
- print 'Run %s from the top-level Linux kernel build directory.' % (prog)
+ print('Usage: %s [OPTION]...' % prog)
+ print(' -d, display an additional level of drivers detail')
+ print(' -h, --help display this help and exit')
+ print('')
+ print('Run %s from the top-level Linux kernel build directory.' % prog)
class Sizes:
@@ -55,8 +55,8 @@ class Sizes:
self.text = self.data = self.bss = self.total = 0
def show(self, indent=""):
- print "%-32s %10d | %10d %10d %10d" % \
- (indent+self.title, self.total, self.text, self.data, self.bss)
+ print("%-32s %10d | %10d %10d %10d" % \
+ (indent+self.title, self.total, self.text, self.data, self.bss))
class Report:
@@ -101,22 +101,22 @@ class Report:
def show(self, indent=""):
rule = str.ljust(indent, 80, '-')
- print "%-32s %10s | %10s %10s %10s" % \
- (indent+self.title, "total", "text", "data", "bss")
- print rule
+ print("%-32s %10s | %10s %10s %10s" % \
+ (indent+self.title, "total", "text", "data", "bss"))
+ print(rule)
self.sizes.show(indent)
- print rule
+ print(rule)
for p in self.parts:
if p.sizes.total > 0:
p.sizes.show(indent)
- print rule
- print "%-32s %10d | %10d %10d %10d" % \
+ print(rule)
+ print("%-32s %10d | %10d %10d %10d" % \
(indent+"sum", self.totals["total"], self.totals["text"],
- self.totals["data"], self.totals["bss"])
- print "%-32s %10d | %10d %10d %10d" % \
+ self.totals["data"], self.totals["bss"]))
+ print("%-32s %10d | %10d %10d %10d" % \
(indent+"delta", self.deltas["total"], self.deltas["text"],
- self.deltas["data"], self.deltas["bss"])
- print "\n"
+ self.deltas["data"], self.deltas["bss"]))
+ print("\n")
def __cmp__(this, that):
if that is None:
@@ -134,7 +134,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "dh", ["help"])
except getopt.GetoptError, err:
- print '%s' % str(err)
+ print('%s' % str(err))
usage()
sys.exit(2)