summaryrefslogtreecommitdiffstats
path: root/import-layers/yocto-poky/scripts/tiny
diff options
context:
space:
mode:
Diffstat (limited to 'import-layers/yocto-poky/scripts/tiny')
-rwxr-xr-ximport-layers/yocto-poky/scripts/tiny/dirsize.py22
-rwxr-xr-ximport-layers/yocto-poky/scripts/tiny/ksize.py44
2 files changed, 30 insertions, 36 deletions
diff --git a/import-layers/yocto-poky/scripts/tiny/dirsize.py b/import-layers/yocto-poky/scripts/tiny/dirsize.py
index 40ff4ab89..ddccc5a8c 100755
--- a/import-layers/yocto-poky/scripts/tiny/dirsize.py
+++ b/import-layers/yocto-poky/scripts/tiny/dirsize.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (c) 2011, Intel Corporation.
# All rights reserved.
@@ -52,26 +52,22 @@ class Record:
self.size = 0
self.records = []
- def __cmp__(this, that):
+ def __lt__(this, that):
if that is None:
- return 1
+ return False
if not isinstance(that, Record):
raise TypeError
if len(this.records) > 0 and len(that.records) == 0:
- return -1
- if len(this.records) == 0 and len(that.records) > 0:
- return 1
- if this.size < that.size:
- return -1
+ return False
if this.size > that.size:
- return 1
- return 0
+ return False
+ return True
def show(self, minsize):
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 +81,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/import-layers/yocto-poky/scripts/tiny/ksize.py b/import-layers/yocto-poky/scripts/tiny/ksize.py
index 4006f2f6f..b9d2b192c 100755
--- a/import-layers/yocto-poky/scripts/tiny/ksize.py
+++ b/import-layers/yocto-poky/scripts/tiny/ksize.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (c) 2011, Intel Corporation.
# All rights reserved.
@@ -28,16 +28,14 @@ import sys
import getopt
import os
from subprocess import *
-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 +53,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:
@@ -66,7 +64,7 @@ class Report:
p = Popen("ls " + path + "/*.o | grep -v built-in.o",
shell=True, stdout=PIPE, stderr=PIPE)
- glob = join(p.communicate()[0].splitlines())
+ glob = ' '.join(p.communicate()[0].splitlines())
oreport = Report(glob, path + "/*.o")
oreport.sizes.title = path + "/*.o"
r.parts.append(oreport)
@@ -101,22 +99,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:
@@ -133,8 +131,8 @@ class Report:
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "dh", ["help"])
- except getopt.GetoptError, err:
- print '%s' % str(err)
+ except getopt.GetoptError as err:
+ print('%s' % str(err))
usage()
sys.exit(2)
OpenPOWER on IntegriCloud