summaryrefslogtreecommitdiffstats
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:47:10 +0100
commit2e388048b61f6029bae1913cbb546ac40b9cfe51 (patch)
tree8fa0fc951caab1430636fca971c27a7e7beb45ce /scripts
parent79be110c1fdfd0affe6a310b96e7107c4549d23c (diff)
downloadpoky-2e388048b61f6029bae1913cbb546ac40b9cfe51.tar.gz
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>
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 = []
27parser = None 27parser = None
28 28
29def err_quit(msg): 29def err_quit(msg):
30 print msg 30 print(msg)
31 parser.print_usage() 31 parser.print_usage()
32 sys.exit(1) 32 sys.exit(1)
33 33
@@ -43,7 +43,7 @@ def run_command(cmd):
43 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) 43 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
44 output = pipe.communicate()[0] 44 output = pipe.communicate()[0]
45 if pipe.returncode != 0: 45 if pipe.returncode != 0:
46 print "Execute command '%s' failed." % cmd 46 print("Execute command '%s' failed." % cmd)
47 sys.exit(1) 47 sys.exit(1)
48 return output 48 return output
49 49
@@ -84,7 +84,7 @@ will be deleted. Be CAUTIOUS.""")
84 if os.getcwd() != builddir: 84 if os.getcwd() != builddir:
85 err_quit("Please run %s under: %s\n" % (os.path.basename(args[0]), builddir)) 85 err_quit("Please run %s under: %s\n" % (os.path.basename(args[0]), builddir))
86 86
87 print 'Updating bitbake caches...' 87 print('Updating bitbake caches...')
88 cmd = "bitbake -s" 88 cmd = "bitbake -s"
89 output = run_command(cmd) 89 output = run_command(cmd)
90 90
@@ -129,13 +129,13 @@ will be deleted. Be CAUTIOUS.""")
129 129
130 # won't fail just in case 130 # won't fail just in case
131 if not tmpdir or not image_rootfs: 131 if not tmpdir or not image_rootfs:
132 print "Can't get TMPDIR or IMAGE_ROOTFS." 132 print("Can't get TMPDIR or IMAGE_ROOTFS.")
133 return 1 133 return 1
134 134
135 pattern = tmpdir + '/(.*?)/(.*?)/' 135 pattern = tmpdir + '/(.*?)/(.*?)/'
136 m = re.match(pattern, image_rootfs) 136 m = re.match(pattern, image_rootfs)
137 if not m: 137 if not m:
138 print "Can't get WORKDIR." 138 print("Can't get WORKDIR.")
139 return 1 139 return 1
140 140
141 workdir = os.path.join(tmpdir, m.group(1)) 141 workdir = os.path.join(tmpdir, m.group(1))
@@ -178,13 +178,13 @@ will be deleted. Be CAUTIOUS.""")
178 break 178 break
179 179
180 for d in obsolete_dirs: 180 for d in obsolete_dirs:
181 print "Deleting %s" % d 181 print("Deleting %s" % d)
182 shutil.rmtree(d, True) 182 shutil.rmtree(d, True)
183 183
184 if len(obsolete_dirs): 184 if len(obsolete_dirs):
185 print '\nTotal %d items.' % len(obsolete_dirs) 185 print('\nTotal %d items.' % len(obsolete_dirs))
186 else: 186 else:
187 print '\nNo obsolete directory found under %s.' % workdir 187 print('\nNo obsolete directory found under %s.' % workdir)
188 188
189 return 0 189 return 0
190 190
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):
519 519
520def drop_to_shell(workdir=None): 520def drop_to_shell(workdir=None):
521 if not sys.stdin.isatty(): 521 if not sys.stdin.isatty():
522 print "Not a TTY so can't drop to shell for resolution, exiting." 522 print("Not a TTY so can't drop to shell for resolution, exiting.")
523 return False 523 return False
524 524
525 shell = os.environ.get('SHELL', 'bash') 525 shell = os.environ.get('SHELL', 'bash')
@@ -529,7 +529,7 @@ def drop_to_shell(workdir=None):
529 ' exit 1 -- abort\n' % shell); 529 ' exit 1 -- abort\n' % shell);
530 ret = subprocess.call([shell], cwd=workdir) 530 ret = subprocess.call([shell], cwd=workdir)
531 if ret != 0: 531 if ret != 0:
532 print "Aborting" 532 print("Aborting")
533 return False 533 return False
534 else: 534 else:
535 return True 535 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
24import re 24import re
25 25
26def usage(): 26def usage():
27 print 'Usage: %s -d FILENAME [-d FILENAME]* -m METADIR [-m MATADIR]*' % os.path.basename(sys.argv[0]) 27 print('Usage: %s -d FILENAME [-d FILENAME]* -m METADIR [-m MATADIR]*' % os.path.basename(sys.argv[0]))
28 print ' -d FILENAME documentation file to search' 28 print(' -d FILENAME documentation file to search')
29 print ' -h, --help display this help and exit' 29 print(' -h, --help display this help and exit')
30 print ' -m METADIR meta directory to search for recipes' 30 print(' -m METADIR meta directory to search for recipes')
31 print ' -t FILENAME documentation config file (for doc tags)' 31 print(' -t FILENAME documentation config file (for doc tags)')
32 print ' -T Only display variables with doc tags (requires -t)' 32 print(' -T Only display variables with doc tags (requires -t)')
33 33
34def recipe_bbvars(recipe): 34def recipe_bbvars(recipe):
35 ''' Return a unique set of every bbvar encountered in the recipe ''' 35 ''' Return a unique set of every bbvar encountered in the recipe '''
@@ -38,8 +38,8 @@ def recipe_bbvars(recipe):
38 try: 38 try:
39 r = open(recipe) 39 r = open(recipe)
40 except IOError as (errno, strerror): 40 except IOError as (errno, strerror):
41 print 'WARNING: Failed to open recipe ', recipe 41 print('WARNING: Failed to open recipe ', recipe)
42 print strerror 42 print(strerror)
43 43
44 for line in r: 44 for line in r:
45 # Strip any comments from the line 45 # Strip any comments from the line
@@ -72,8 +72,8 @@ def bbvar_is_documented(var, docfiles):
72 try: 72 try:
73 f = open(doc) 73 f = open(doc)
74 except IOError as (errno, strerror): 74 except IOError as (errno, strerror):
75 print 'WARNING: Failed to open doc ', doc 75 print('WARNING: Failed to open doc ', doc)
76 print strerror 76 print(strerror)
77 for line in f: 77 for line in f:
78 if prog.match(line): 78 if prog.match(line):
79 return True 79 return True
@@ -110,7 +110,7 @@ def main():
110 try: 110 try:
111 opts, args = getopt.getopt(sys.argv[1:], "d:hm:t:T", ["help"]) 111 opts, args = getopt.getopt(sys.argv[1:], "d:hm:t:T", ["help"])
112 except getopt.GetoptError, err: 112 except getopt.GetoptError, err:
113 print '%s' % str(err) 113 print('%s' % str(err))
114 usage() 114 usage()
115 sys.exit(2) 115 sys.exit(2)
116 116
@@ -122,13 +122,13 @@ def main():
122 if os.path.isfile(a): 122 if os.path.isfile(a):
123 docfiles.append(a) 123 docfiles.append(a)
124 else: 124 else:
125 print 'ERROR: documentation file %s is not a regular file' % (a) 125 print('ERROR: documentation file %s is not a regular file' % a)
126 sys.exit(3) 126 sys.exit(3)
127 elif o == '-m': 127 elif o == '-m':
128 if os.path.isdir(a): 128 if os.path.isdir(a):
129 metadirs.append(a) 129 metadirs.append(a)
130 else: 130 else:
131 print 'ERROR: meta directory %s is not a directory' % (a) 131 print('ERROR: meta directory %s is not a directory' % a)
132 sys.exit(4) 132 sys.exit(4)
133 elif o == "-t": 133 elif o == "-t":
134 if os.path.isfile(a): 134 if os.path.isfile(a):
@@ -139,17 +139,17 @@ def main():
139 assert False, "unhandled option" 139 assert False, "unhandled option"
140 140
141 if len(docfiles) == 0: 141 if len(docfiles) == 0:
142 print 'ERROR: no docfile specified' 142 print('ERROR: no docfile specified')
143 usage() 143 usage()
144 sys.exit(5) 144 sys.exit(5)
145 145
146 if len(metadirs) == 0: 146 if len(metadirs) == 0:
147 print 'ERROR: no metadir specified' 147 print('ERROR: no metadir specified')
148 usage() 148 usage()
149 sys.exit(6) 149 sys.exit(6)
150 150
151 if onlydoctags and docconf == "": 151 if onlydoctags and docconf == "":
152 print 'ERROR: no docconf specified' 152 print('ERROR: no docconf specified')
153 usage() 153 usage()
154 sys.exit(7) 154 sys.exit(7)
155 155
@@ -172,14 +172,14 @@ def main():
172 varlen = varlen + 1 172 varlen = varlen + 1
173 173
174 # Report all undocumented variables 174 # Report all undocumented variables
175 print 'Found %d undocumented bb variables (out of %d):' % (len(undocumented), len(bbvars)) 175 print('Found %d undocumented bb variables (out of %d):' % (len(undocumented), len(bbvars)))
176 header = '%s%s%s' % (str("VARIABLE").ljust(varlen), str("COUNT").ljust(6), str("DOCTAG").ljust(7)) 176 header = '%s%s%s' % (str("VARIABLE").ljust(varlen), str("COUNT").ljust(6), str("DOCTAG").ljust(7))
177 print header 177 print(header)
178 print str("").ljust(len(header), '=') 178 print(str("").ljust(len(header), '='))
179 for v in undocumented: 179 for v in undocumented:
180 doctag = bbvar_doctag(v, docconf) 180 doctag = bbvar_doctag(v, docconf)
181 if not onlydoctags or not doctag == "": 181 if not onlydoctags or not doctag == "":
182 print '%s%s%s' % (v.ljust(varlen), str(bbvars[v]).ljust(6), doctag) 182 print('%s%s%s' % (v.ljust(varlen), str(bbvars[v]).ljust(6), doctag))
183 183
184 184
185if __name__ == "__main__": 185if __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):
104 pkgname_len += 1 104 pkgname_len += 1
105 105
106 header = '%-*s%s' % (pkgname_len, str("RECIPE NAME"), str("PACKAGECONFIG FLAGS")) 106 header = '%-*s%s' % (pkgname_len, str("RECIPE NAME"), str("PACKAGECONFIG FLAGS"))
107 print header 107 print(header)
108 print str("").ljust(len(header), '=') 108 print(str("").ljust(len(header), '='))
109 for pkgname in sorted(pkg_dict): 109 for pkgname in sorted(pkg_dict):
110 print('%-*s%s' % (pkgname_len, pkgname, ' '.join(pkg_dict[pkgname]))) 110 print('%-*s%s' % (pkgname_len, pkgname, ' '.join(pkg_dict[pkgname])))
111 111
@@ -115,18 +115,18 @@ def display_flags(flag_dict):
115 flag_len = len("PACKAGECONFIG FLAG") + 5 115 flag_len = len("PACKAGECONFIG FLAG") + 5
116 116
117 header = '%-*s%s' % (flag_len, str("PACKAGECONFIG FLAG"), str("RECIPE NAMES")) 117 header = '%-*s%s' % (flag_len, str("PACKAGECONFIG FLAG"), str("RECIPE NAMES"))
118 print header 118 print(header)
119 print str("").ljust(len(header), '=') 119 print(str("").ljust(len(header), '='))
120 120
121 for flag in sorted(flag_dict): 121 for flag in sorted(flag_dict):
122 print('%-*s%s' % (flag_len, flag, ' '.join(sorted(flag_dict[flag])))) 122 print('%-*s%s' % (flag_len, flag, ' '.join(sorted(flag_dict[flag]))))
123 123
124def display_all(data_dict): 124def display_all(data_dict):
125 ''' Display all pkgs and PACKAGECONFIG information ''' 125 ''' Display all pkgs and PACKAGECONFIG information '''
126 print str("").ljust(50, '=') 126 print(str("").ljust(50, '='))
127 for fn in data_dict: 127 for fn in data_dict:
128 print('%s' % data_dict[fn].getVar("P", True)) 128 print('%s' % data_dict[fn].getVar("P", True))
129 print fn 129 print(fn)
130 packageconfig = data_dict[fn].getVar("PACKAGECONFIG", True) or '' 130 packageconfig = data_dict[fn].getVar("PACKAGECONFIG", True) or ''
131 if packageconfig.strip() == '': 131 if packageconfig.strip() == '':
132 packageconfig = 'None' 132 packageconfig = 'None'
@@ -136,7 +136,7 @@ def display_all(data_dict):
136 if flag == "doc": 136 if flag == "doc":
137 continue 137 continue
138 print('PACKAGECONFIG[%s] %s' % (flag, flag_val)) 138 print('PACKAGECONFIG[%s] %s' % (flag, flag_val))
139 print '' 139 print('')
140 140
141def main(): 141def main():
142 pkg_dict = {} 142 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):
108 if max_log_size != 0: 108 if max_log_size != 0:
109 for fail in jsondata['failures']: 109 for fail in jsondata['failures']:
110 if len(fail['log']) > max_log_size: 110 if len(fail['log']) > max_log_size:
111 print "Truncating log to allow for upload" 111 print("Truncating log to allow for upload")
112 fail['log'] = fail['log'][-max_log_size:] 112 fail['log'] = fail['log'][-max_log_size:]
113 113
114 data = json.dumps(jsondata, indent=4, sort_keys=True) 114 data = json.dumps(jsondata, indent=4, sort_keys=True)
@@ -143,7 +143,7 @@ def send_data(data, args):
143 logging.error(e.reason) 143 logging.error(e.reason)
144 sys.exit(1) 144 sys.exit(1)
145 145
146 print response.read() 146 print(response.read())
147 147
148 148
149if __name__ == '__main__': 149if __name__ == '__main__':
@@ -192,7 +192,7 @@ if __name__ == '__main__':
192 args = arg_parse.parse_args() 192 args = arg_parse.parse_args()
193 193
194 if (args.json == False): 194 if (args.json == False):
195 print "Preparing to send errors to: "+args.server 195 print("Preparing to send errors to: "+args.server)
196 196
197 data = prepare_data(args) 197 data = prepare_data(args)
198 send_data(data, args) 198 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():
289 result = bitbake("%s -c testimage" % image_type, ignore_status=True, postconfig=postconfig) 289 result = bitbake("%s -c testimage" % image_type, ignore_status=True, postconfig=postconfig)
290 testimage_results = ftools.read_file(os.path.join(get_bb_var("T", image_type), "log.do_testimage")) 290 testimage_results = ftools.read_file(os.path.join(get_bb_var("T", image_type), "log.do_testimage"))
291 log.info('Runtime tests results for %s:' % image_type) 291 log.info('Runtime tests results for %s:' % image_type)
292 print testimage_results 292 print(testimage_results)
293 return result 293 return result
294 294
295 # Start the procedure! 295 # 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:
71 total = 0 71 total = 0
72 if self.size <= minsize: 72 if self.size <= minsize:
73 return 0 73 return 0
74 print "%10d %s" % (self.size, self.path) 74 print("%10d %s" % (self.size, self.path))
75 for r in self.records: 75 for r in self.records:
76 total += r.show(minsize) 76 total += r.show(minsize)
77 if len(self.records) == 0: 77 if len(self.records) == 0:
@@ -85,8 +85,8 @@ def main():
85 minsize = int(sys.argv[1]) 85 minsize = int(sys.argv[1])
86 rootfs = Record.create(".") 86 rootfs = Record.create(".")
87 total = rootfs.show(minsize) 87 total = rootfs.show(minsize)
88 print "Displayed %d/%d bytes (%.2f%%)" % \ 88 print("Displayed %d/%d bytes (%.2f%%)" % \
89 (total, rootfs.size, 100 * float(total) / rootfs.size) 89 (total, rootfs.size, 100 * float(total) / rootfs.size))
90 90
91 91
92if __name__ == "__main__": 92if __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
33 33
34def usage(): 34def usage():
35 prog = os.path.basename(sys.argv[0]) 35 prog = os.path.basename(sys.argv[0])
36 print 'Usage: %s [OPTION]...' % (prog) 36 print('Usage: %s [OPTION]...' % prog)
37 print ' -d, display an additional level of drivers detail' 37 print(' -d, display an additional level of drivers detail')
38 print ' -h, --help display this help and exit' 38 print(' -h, --help display this help and exit')
39 print '' 39 print('')
40 print 'Run %s from the top-level Linux kernel build directory.' % (prog) 40 print('Run %s from the top-level Linux kernel build directory.' % prog)
41 41
42 42
43class Sizes: 43class Sizes:
@@ -55,8 +55,8 @@ class Sizes:
55 self.text = self.data = self.bss = self.total = 0 55 self.text = self.data = self.bss = self.total = 0
56 56
57 def show(self, indent=""): 57 def show(self, indent=""):
58 print "%-32s %10d | %10d %10d %10d" % \ 58 print("%-32s %10d | %10d %10d %10d" % \
59 (indent+self.title, self.total, self.text, self.data, self.bss) 59 (indent+self.title, self.total, self.text, self.data, self.bss))
60 60
61 61
62class Report: 62class Report:
@@ -101,22 +101,22 @@ class Report:
101 101
102 def show(self, indent=""): 102 def show(self, indent=""):
103 rule = str.ljust(indent, 80, '-') 103 rule = str.ljust(indent, 80, '-')
104 print "%-32s %10s | %10s %10s %10s" % \ 104 print("%-32s %10s | %10s %10s %10s" % \
105 (indent+self.title, "total", "text", "data", "bss") 105 (indent+self.title, "total", "text", "data", "bss"))
106 print rule 106 print(rule)
107 self.sizes.show(indent) 107 self.sizes.show(indent)
108 print rule 108 print(rule)
109 for p in self.parts: 109 for p in self.parts:
110 if p.sizes.total > 0: 110 if p.sizes.total > 0:
111 p.sizes.show(indent) 111 p.sizes.show(indent)
112 print rule 112 print(rule)
113 print "%-32s %10d | %10d %10d %10d" % \ 113 print("%-32s %10d | %10d %10d %10d" % \
114 (indent+"sum", self.totals["total"], self.totals["text"], 114 (indent+"sum", self.totals["total"], self.totals["text"],
115 self.totals["data"], self.totals["bss"]) 115 self.totals["data"], self.totals["bss"]))
116 print "%-32s %10d | %10d %10d %10d" % \ 116 print("%-32s %10d | %10d %10d %10d" % \
117 (indent+"delta", self.deltas["total"], self.deltas["text"], 117 (indent+"delta", self.deltas["total"], self.deltas["text"],
118 self.deltas["data"], self.deltas["bss"]) 118 self.deltas["data"], self.deltas["bss"]))
119 print "\n" 119 print("\n")
120 120
121 def __cmp__(this, that): 121 def __cmp__(this, that):
122 if that is None: 122 if that is None:
@@ -134,7 +134,7 @@ def main():
134 try: 134 try:
135 opts, args = getopt.getopt(sys.argv[1:], "dh", ["help"]) 135 opts, args = getopt.getopt(sys.argv[1:], "dh", ["help"])
136 except getopt.GetoptError, err: 136 except getopt.GetoptError, err:
137 print '%s' % str(err) 137 print('%s' % str(err))
138 usage() 138 usage()
139 sys.exit(2) 139 sys.exit(2)
140 140