smem: use python 3
PATCH 1/1 smem: use python 3
There seems to be no user of python-textutils python-shell python-codecs in the script, so these rdepends are dropped.
On a i.MX6 based machine smem runs with just python3-compression and its dependencies installed.
--- .../smem/0001-smem-convert-to-python-3.patch | 161 ++++++++++++++++++ meta-oe/recipes-support/smem/smem_1.4.bb | 7 +- 2 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +161 -0
@@ -0,0 +1,161 @@ +From 5535a524f6db57c0b2e4a539db733fd9e840c97e Mon Sep 17 00:00:00 2001 +From: Max Krummenacher <[email protected]> +Date: Mon, 3 Feb 2020 21:04:42 +0000 +Subject: [PATCH] smem: convert to python 3 + +Upstream-Status: Pending + +Signed-off-by: Max Krummenacher <[email protected]> +--- + smem | 41 ++++++++++++++++++++++------------------- + 1 file changed, 22 insertions(+), 19 deletions(-) + +diff --git a/smem b/smem +index 0cbd925..577d27b 100755 +--- a/smem ++++ b/smem +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # smem - a tool for meaningful memory reporting + # +@@ -21,7 +21,10 @@ class procdata(object): + def _list(self): + return os.listdir(self.source + "/proc") + def _read(self, f): +- return file(self.source + '/proc/' + f).read() ++ afile = open(self.source + '/proc/' + f) ++ ret = afile.read() ++ afile.close() ++ return ret + def _readlines(self, f): + return self._read(f).splitlines(True) + def _stat(self, f): +@@ -209,7 +212,7 @@ def fromunits(x): + s = dict(k=2**10, K=2**10, kB=2**10, KB=2**10, + M=2**20, MB=2**20, G=2**30, GB=2**30, + T=2**40, TB=2**40) +- for k,v in s.items(): ++ for k,v in list(s.items()): + if x.endswith(k): + return int(float(x[:-len(k)])*v) + sys.stderr.write("Memory size should be written with units, for example 1024M\n") +@@ -240,7 +243,7 @@ def pidtotals(pid): + maps = pidmaps(pid) + t = dict(size=0, rss=0, pss=0, shared_clean=0, shared_dirty=0, + private_clean=0, private_dirty=0, referenced=0, swap=0) +- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -296,7 +299,7 @@ def showpids(): + ) + columns = options.columns or 'pid user command swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def maptotals(pids): + totals = {} +@@ -307,7 +310,7 @@ def maptotals(pids): + try: + maps = pidmaps(pid) + seen = {} +- for m in maps.iterkeys(): ++ for m in maps.keys(): + name = maps[m]['name'] + if name not in totals: + t = dict(size=0, rss=0, pss=0, shared_clean=0, +@@ -361,7 +364,7 @@ def showmaps(): + ) + columns = options.columns or 'map pids avgpss pss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def usertotals(pids): + totals = {} +@@ -383,7 +386,7 @@ def usertotals(pids): + else: + t = totals[user] + +- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -419,7 +422,7 @@ def showusers(): + ) + columns = options.columns or 'user count swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def showsystem(): + t = totalmem() +@@ -460,14 +463,14 @@ def showsystem(): + 'area not reclaimable')) + + columns = options.columns or 'area used cache noncache' +- showtable(range(len(l)), fields, columns.split(), options.sort or 'order') ++ showtable(list(range(len(l))), fields, columns.split(), options.sort or 'order') + + def showfields(fields, f): + if f != list: +- print "unknown field", f +- print "known fields:" ++ print("unknown field", f) ++ print("known fields:") + for l in sorted(fields.keys()): +- print "%-8s %s" % (l, fields[l][-1]) ++ print("%-8s %s" % (l, fields[l][-1])) + + def showtable(rows, fields, columns, sort): + header = "" +@@ -518,10 +521,10 @@ def showtable(rows, fields, columns, sort): + return + + if not options.no_header: +- print header ++ print(header) + + for k,r in l: +- print format % tuple([f(v) for f,v in zip(formatter, r)]) ++ print(format % tuple([f(v) for f,v in zip(formatter, r)])) + + if options.totals: + # totals +@@ -533,8 +536,8 @@ def showtable(rows, fields, columns, sort): + else: + t.append("") + +- print "-" * len(header) +- print format % tuple([f(v) for f,v in zip(formatter, t)]) ++ print("-" * len(header)) ++ print(format % tuple([f(v) for f,v in zip(formatter, t)])) + + def showpie(l, sort): + try: +@@ -605,7 +608,7 @@ def showbar(l, columns, sort): + + pl = [] + ind = numpy.arange(len(l)) +- for n in xrange(len(rc)): ++ for n in range(len(rc)): + pl.append(pylab.bar(ind + offset + width * n, + [x[1][rc[n]] for x in l], width, color=gc(n))) + +@@ -682,7 +685,7 @@ try: + showsystem() + else: + showpids() +-except IOError, e: ++except IOError as e: + if e.errno == errno.EPIPE: + pass + except KeyboardInterrupt: +-- +2.20.1 +
meta-oe/recipes-support/smem/smem_1.4.bb +5 -2
@@ -9,7 +9,10 @@ SECTION = "Applications/System" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" -SRC_URI = "http://www.selenic.com/${BPN}/download/${BP}.tar.gz" +SRC_URI = " \ + http://www.selenic.com/${BPN}/download/${BP}.tar.gz \ + file://0001-smem-convert-to-python-3.patch \ +" SRC_URI[md5sum] = "fe79435c3930389bfdb560255c802162" SRC_URI[sha256sum] = "2ea9f878f4cf3c276774c3f7e2a41977a1f2d64f98d2dcb6a15f1f3d84df61ec"
@@ -24,7 +27,7 @@ do_install() { install -m 0755 ${S}/smemcap ${D}${bindir}/ install -m 0644 ${S}/smem.8 ${D}/${mandir}/man8/ } -RDEPENDS_${PN} += "python-textutils python-compression python-shell python-codecs" +RDEPENDS_${PN} += "python3-compression" PACKAGES =+ "smemcap"
Signature · 1 line
2.20.1
Thanks for doing this.
Quoted 4 lines · Max Krummenacher
There seems to be no user of python-textutils python-shell python-codecs in the script, so these rdepends are dropped.
OK
Quoted 2 lines
On a i.MX6 based machine smem runs with just python3-compression and its dependencies installed.
ok. Perhaps, it pulls in right set of rdeps indirectly?
Quoted 7 lines
Signed-off-by Max Krummenacher <[email protected]>--- .../smem/0001-smem-convert-to-python-3.patch | 161 ++++++++++++++++++ meta-oe/recipes-support/smem/smem_1.4.bb | 7 +- 2 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch
Perhaps using 1.5 tag would be desired since that already has py3 fixes
https://selenic.com/repo/smem/archive/1.5.tar.bz2
Or maybe we can cherry pick the patches between 1.4 tag and 1.5 tag there are 6 or 7 patches in total [1]
Quoted 201 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +161
-0@@ -0,0 +1,161 @@ +From 5535a524f6db57c0b2e4a539db733fd9e840c97e Mon Sep 17 00:00:00 2001 +From: Max Krummenacher <[email protected]> +Date: Mon, 3 Feb 2020 21:04:42 +0000 +Subject: [PATCH] smem: convert to python 3 + +Upstream-Status: Pending + +Signed-off-by: Max Krummenacher <[email protected]> +--- + smem | 41 ++++++++++++++++++++++------------------- + 1 file changed, 22 insertions(+), 19 deletions(-) + +diff --git a/smem b/smem +index 0cbd925..577d27b 100755 +--- a/smem ++++ b/smem +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # smem - a tool for meaningful memory reporting + # +@@ -21,7 +21,10 @@ class procdata(object): + def _list(self): + return os.listdir(self.source + "/proc") + def _read(self, f): +- return file(self.source + '/proc/' + f).read() ++ afile = open(self.source + '/proc/' + f) ++ ret = afile.read() ++ afile.close() ++ return ret + def _readlines(self, f): + return self._read(f).splitlines(True) + def _stat(self, f): +@@ -209,7 +212,7 @@ def fromunits(x): + s = dict(k=2**10, K=2**10, kB=2**10, KB=2**10, + M=2**20, MB=2**20, G=2**30, GB=2**30, + T=2**40, TB=2**40) +- for k,v in s.items(): ++ for k,v in list(s.items()): + if x.endswith(k): + return int(float(x[:-len(k)])*v) + sys.stderr.write("Memory size should be written with units, for example 1024M\n") +@@ -240,7 +243,7 @@ def pidtotals(pid): + maps = pidmaps(pid) + t = dict(size=0, rss=0, pss=0, shared_clean=0, shared_dirty=0, + private_clean=0, private_dirty=0, referenced=0, swap=0) +- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -296,7 +299,7 @@ def showpids(): + ) + columns = options.columns or 'pid user command swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def maptotals(pids): + totals = {} +@@ -307,7 +310,7 @@ def maptotals(pids): + try: + maps = pidmaps(pid) + seen = {} +- for m in maps.iterkeys(): ++ for m in maps.keys(): + name = maps[m]['name'] + if name not in totals: + t = dict(size=0, rss=0, pss=0, shared_clean=0, +@@ -361,7 +364,7 @@ def showmaps(): + ) + columns = options.columns or 'map pids avgpss pss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def usertotals(pids): + totals = {} +@@ -383,7 +386,7 @@ def usertotals(pids): + else: + t = totals[user] + +- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -419,7 +422,7 @@ def showusers(): + ) + columns = options.columns or 'user count swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def showsystem(): + t = totalmem() +@@ -460,14 +463,14 @@ def showsystem(): + 'area not reclaimable')) + + columns = options.columns or 'area used cache noncache' +- showtable(range(len(l)), fields, columns.split(), options.sort or 'order') ++ showtable(list(range(len(l))), fields, columns.split(), options.sort or 'order') + + def showfields(fields, f): + if f != list: +- print "unknown field", f +- print "known fields:" ++ print("unknown field", f) ++ print("known fields:") + for l in sorted(fields.keys()): +- print "%-8s %s" % (l, fields[l][-1]) ++ print("%-8s %s" % (l, fields[l][-1])) + + def showtable(rows, fields, columns, sort): + header = "" +@@ -518,10 +521,10 @@ def showtable(rows, fields, columns, sort): + return + + if not options.no_header: +- print header ++ print(header) + + for k,r in l: +- print format % tuple([f(v) for f,v in zip(formatter, r)]) ++ print(format % tuple([f(v) for f,v in zip(formatter, r)])) + + if options.totals: + # totals +@@ -533,8 +536,8 @@ def showtable(rows, fields, columns, sort): + else: + t.append("") + +- print "-" * len(header) +- print format % tuple([f(v) for f,v in zip(formatter, t)]) ++ print("-" * len(header)) ++ print(format % tuple([f(v) for f,v in zip(formatter, t)])) + + def showpie(l, sort): + try: +@@ -605,7 +608,7 @@ def showbar(l, columns, sort): + + pl = [] + ind = numpy.arange(len(l)) +- for n in xrange(len(rc)): ++ for n in range(len(rc)): + pl.append(pylab.bar(ind + offset + width * n, + [x[1][rc[n]] for x in l], width, color=gc(n))) + +@@ -682,7 +685,7 @@ try: + showsystem() + else: + showpids() +-except IOError, e: ++except IOError as e: + if e.errno == errno.EPIPE: + pass + except KeyboardInterrupt: +-- +2.20.1 +meta-oe/recipes-support/smem/smem_1.4.bb +5
-3@@ -9,7 +9,10 @@ SECTION = "Applications/System" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" -SRC_URI = "http://www.selenic.com/${BPN}/download/${BP}.tar.gz" +SRC_URI = " \ + http://www.selenic.com/${BPN}/download/${BP}.tar.gz \ + file://0001-smem-convert-to-python-3.patch \ +" SRC_URI[md5sum] = "fe79435c3930389bfdb560255c802162" SRC_URI[sha256sum] = "2ea9f878f4cf3c276774c3f7e2a41977a1f2d64f98d2dcb6a15f1f3d84df61ec"@@ -24,7 +27,7 @@ do_install() { install -m 0755 ${S}/smemcap ${D}${bindir}/ install -m 0644 ${S}/smem.8 ${D}/${mandir}/man8/ } -RDEPENDS_${PN} += "python-textutils python-compression python-shell python-codecs" +RDEPENDS_${PN} += "python3-compression" PACKAGES =+ "smemcap" --2.20.1
--
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
Am Dienstag, den 04.02.2020, 18:59 -0800 schrieb Khem Raj:
Quoted 8 lines
Thanks for doing this.
Quoted 4 lines · Max Krummenacher
There seems to be no user of python-textutils python-shell python-codecs in the script, so these rdepends are dropped.
Quoted 6 lines
OK
Quoted 2 lines
On a i.MX6 based machine smem runs with just python3-compression and its dependencies installed.
ok. Perhaps, it pulls in right set of rdeps indirectly?
This is not what I meant with the sentence, runtime agrees that dropping the python modules doesn't affect the operation of smem.
On the module I get the following python packages installed:
opkg list | grep python
libpython3.8-1.0 - 3.8.1-r0
python3-compression - 3.8.1-r0
python3-core - 3.8.1-r0
On which smem directly or indirectly rdepends on:
depends-nokernel-nolibc-noupdate-nomodules.dot:
"smem" -> "python3-compression"
"python3-core" -> "libpython3.8-1.0"
"python3-compression" -> "python3-core"
So by installing smem all the installed python packages I had during my test are runtime dependencies of smem and thus available.
I guess we are fine.
Max
Quoted 219 lines
Quoted 8 lines
Signed-off-by Max Krummenacher <[email protected]>--- .../smem/0001-smem-convert-to-python-3.patch | 161 ++++++++++++++++++ meta-oe/recipes-support/smem/smem_1.4.bb | 7 +- 2 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patchPerhaps using 1.5 tag would be desired since that already has py3 fixes
https://selenic.com/repo/smem/archive/1.5.tar.bz2Or maybe we can cherry pick the patches between 1.4 tag and 1.5 tag there are 6 or 7 patches in total [1]
Quoted 202 lines
meta- renamed from meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch +0
-0
oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patchnew file mode 100644
index 000000000..85f35be44meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +161
-0@@ -0,0 +1,161 @@ +From 5535a524f6db57c0b2e4a539db733fd9e840c97e Mon Sep 17 00:00:00 2001 +From: Max Krummenacher <[email protected]> +Date: Mon, 3 Feb 2020 21:04:42 +0000 +Subject: [PATCH] smem: convert to python 3 + +Upstream-Status: Pending + +Signed-off-by: Max Krummenacher <[email protected]> +--- + smem | 41 ++++++++++++++++++++++------------------- + 1 file changed, 22 insertions(+), 19 deletions(-) + +diff --git a/smem b/smem +index 0cbd925..577d27b 100755 +--- a/smem ++++ b/smem +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # smem - a tool for meaningful memory reporting + # +@@ -21,7 +21,10 @@ class procdata(object): + def _list(self): + return os.listdir(self.source + "/proc") + def _read(self, f): +- return file(self.source + '/proc/' + f).read() ++ afile = open(self.source + '/proc/' + f) ++ ret = afile.read() ++ afile.close() ++ return ret + def _readlines(self, f): + return self._read(f).splitlines(True) + def _stat(self, f): +@@ -209,7 +212,7 @@ def fromunits(x): + s = dict(k=2**10, K=2**10, kB=2**10, KB=2**10, + M=2**20, MB=2**20, G=2**30, GB=2**30, + T=2**40, TB=2**40) +- for k,v in s.items(): ++ for k,v in list(s.items()): + if x.endswith(k): + return int(float(x[:-len(k)])*v) + sys.stderr.write("Memory size should be written with units, for example 1024M\n") +@@ -240,7 +243,7 @@ def pidtotals(pid): + maps = pidmaps(pid) + t = dict(size=0, rss=0, pss=0, shared_clean=0, shared_dirty=0, + private_clean=0, private_dirty=0, referenced=0, swap=0) +- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -296,7 +299,7 @@ def showpids(): + ) + columns = options.columns or 'pid user command swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def maptotals(pids): + totals = {} +@@ -307,7 +310,7 @@ def maptotals(pids): + try: + maps = pidmaps(pid) + seen = {} +- for m in maps.iterkeys(): ++ for m in maps.keys(): + name = maps[m]['name'] + if name not in totals: + t = dict(size=0, rss=0, pss=0, shared_clean=0, +@@ -361,7 +364,7 @@ def showmaps(): + ) + columns = options.columns or 'map pids avgpss pss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def usertotals(pids): + totals = {} +@@ -383,7 +386,7 @@ def usertotals(pids): + else: + t = totals[user] + +- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -419,7 +422,7 @@ def showusers(): + ) + columns = options.columns or 'user count swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def showsystem(): + t = totalmem() +@@ -460,14 +463,14 @@ def showsystem(): + 'area not reclaimable')) + + columns = options.columns or 'area used cache noncache' +- showtable(range(len(l)), fields, columns.split(), options.sort or 'order') ++ showtable(list(range(len(l))), fields, columns.split(), options.sort or 'order') + + def showfields(fields, f): + if f != list: +- print "unknown field", f +- print "known fields:" ++ print("unknown field", f) ++ print("known fields:") + for l in sorted(fields.keys()): +- print "%-8s %s" % (l, fields[l][-1]) ++ print("%-8s %s" % (l, fields[l][-1])) + + def showtable(rows, fields, columns, sort): + header = "" +@@ -518,10 +521,10 @@ def showtable(rows, fields, columns, sort): + return + + if not options.no_header: +- print header ++ print(header) + + for k,r in l: +- print format % tuple([f(v) for f,v in zip(formatter, r)]) ++ print(format % tuple([f(v) for f,v in zip(formatter, r)])) + + if options.totals: + # totals +@@ -533,8 +536,8 @@ def showtable(rows, fields, columns, sort): + else: + t.append("") + +- print "-" * len(header) +- print format % tuple([f(v) for f,v in zip(formatter, t)]) ++ print("-" * len(header)) ++ print(format % tuple([f(v) for f,v in zip(formatter, t)])) + + def showpie(l, sort): + try: +@@ -605,7 +608,7 @@ def showbar(l, columns, sort): + + pl = [] + ind = numpy.arange(len(l)) +- for n in xrange(len(rc)): ++ for n in range(len(rc)): + pl.append(pylab.bar(ind + offset + width * n, + [x[1][rc[n]] for x in l], width, color=gc(n))) + +@@ -682,7 +685,7 @@ try: + showsystem() + else: + showpids() +-except IOError, e: ++except IOError as e: + if e.errno == errno.EPIPE: + pass + except KeyboardInterrupt: +-- +2.20.1 +meta-oe/recipes-support/smem/smem_1.4.bb +5
-3@@ -9,7 +9,10 @@ SECTION = "Applications/System" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" -SRC_URI = "http://www.selenic.com/${BPN}/download/${BP}.tar.gz" +SRC_URI = " \ + http://www.selenic.com/${BPN}/download/${BP}.tar.gz \ + file://0001-smem-convert-to-python-3.patch \ +" SRC_URI[md5sum] = "fe79435c3930389bfdb560255c802162" SRC_URI[sha256sum] = "2ea9f878f4cf3c276774c3f7e2a41977a1f2d64f98d2dcb6a15f1f3d84df61ec"@@ -24,7 +27,7 @@ do_install() { install -m 0755 ${S}/smemcap ${D}${bindir}/ install -m 0644 ${S}/smem.8 ${D}/${mandir}/man8/ } -RDEPENDS_${PN} += "python-textutils python-compression python-shell python-codecs" +RDEPENDS_${PN} += "python3-compression" PACKAGES =+ "smemcap" --2.20.1
--
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
Hi,
Interestingly I had been looking at this today as well...
Quoted 5 lines · Max Krummenacher
There seems to be no user of python-textutils python-shell python-codecs in the script, so these rdepends are dropped.
On a i.MX6 based machine smem runs with just python3-compression and its dependencies installed.
Upstream has released v1.5 with almost complete python3 support. I'd say any patches should go on top of that.
Also, I don't think smem --source= will work with your version? Did you test that?
Quoted 193 lines
Signed-off-by Max Krummenacher <[email protected]>--- .../smem/0001-smem-convert-to-python-3.patch | 161 ++++++++++++++++++ meta-oe/recipes-support/smem/smem_1.4.bb | 7 +- 2 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patchmeta-oe/recipes- renamed from meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch +0
-0
support/smem/smem/0001-smem-convert-to-python-3.patchnew file mode 100644
index 000000000..85f35be44meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +161
-0@@ -0,0 +1,161 @@ +From 5535a524f6db57c0b2e4a539db733fd9e840c97e Mon Sep 17 00:00:00 2001 +From: Max Krummenacher <[email protected]> +Date: Mon, 3 Feb 2020 21:04:42 +0000 +Subject: [PATCH] smem: convert to python 3 + +Upstream-Status: Pending + +Signed-off-by: Max Krummenacher <[email protected]> +--- + smem | 41 ++++++++++++++++++++++------------------- + 1 file changed, 22 insertions(+), 19 deletions(-) + +diff --git a/smem b/smem +index 0cbd925..577d27b 100755 +--- a/smem ++++ b/smem +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # smem - a tool for meaningful memory reporting + # +@@ -21,7 +21,10 @@ class procdata(object): + def _list(self): + return os.listdir(self.source + "/proc") + def _read(self, f): +- return file(self.source + '/proc/' + f).read() ++ afile = open(self.source + '/proc/' + f) ++ ret = afile.read() ++ afile.close() ++ return ret + def _readlines(self, f): + return self._read(f).splitlines(True) + def _stat(self, f): +@@ -209,7 +212,7 @@ def fromunits(x): + s = dict(k=2**10, K=2**10, kB=2**10, KB=2**10, + M=2**20, MB=2**20, G=2**30, GB=2**30, + T=2**40, TB=2**40) +- for k,v in s.items(): ++ for k,v in list(s.items()): + if x.endswith(k): + return int(float(x[:-len(k)])*v) + sys.stderr.write("Memory size should be written with units, for example 1024M\n") +@@ -240,7 +243,7 @@ def pidtotals(pid): + maps = pidmaps(pid) + t = dict(size=0, rss=0, pss=0, shared_clean=0, shared_dirty=0, + private_clean=0, private_dirty=0, referenced=0, swap=0) +- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -296,7 +299,7 @@ def showpids(): + ) + columns = options.columns or 'pid user command swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def maptotals(pids): + totals = {} +@@ -307,7 +310,7 @@ def maptotals(pids): + try: + maps = pidmaps(pid) + seen = {} +- for m in maps.iterkeys(): ++ for m in maps.keys(): + name = maps[m]['name'] + if name not in totals: + t = dict(size=0, rss=0, pss=0, shared_clean=0, +@@ -361,7 +364,7 @@ def showmaps(): + ) + columns = options.columns or 'map pids avgpss pss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def usertotals(pids): + totals = {} +@@ -383,7 +386,7 @@ def usertotals(pids): + else: + t = totals[user] + +- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -419,7 +422,7 @@ def showusers(): + ) + columns = options.columns or 'user count swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or 'pss') ++ showtable(list(pt.keys()), fields, columns.split(), options.sort or 'pss') + + def showsystem(): + t = totalmem() +@@ -460,14 +463,14 @@ def showsystem(): + 'area not reclaimable')) + + columns = options.columns or 'area used cache noncache' +- showtable(range(len(l)), fields, columns.split(), options.sort or 'order') ++ showtable(list(range(len(l))), fields, columns.split(), options.sort or 'order') + + def showfields(fields, f): + if f != list: +- print "unknown field", f +- print "known fields:" ++ print("unknown field", f) ++ print("known fields:") + for l in sorted(fields.keys()): +- print "%-8s %s" % (l, fields[l][-1]) ++ print("%-8s %s" % (l, fields[l][-1])) + + def showtable(rows, fields, columns, sort): + header = "" +@@ -518,10 +521,10 @@ def showtable(rows, fields, columns, sort): + return + + if not options.no_header: +- print header ++ print(header) + + for k,r in l: +- print format % tuple([f(v) for f,v in zip(formatter, r)]) ++ print(format % tuple([f(v) for f,v in zip(formatter, r)])) + + if options.totals: + # totals +@@ -533,8 +536,8 @@ def showtable(rows, fields, columns, sort): + else: + t.append("") + +- print "-" * len(header) +- print format % tuple([f(v) for f,v in zip(formatter, t)]) ++ print("-" * len(header)) ++ print(format % tuple([f(v) for f,v in zip(formatter, t)])) + + def showpie(l, sort): + try: +@@ -605,7 +608,7 @@ def showbar(l, columns, sort): + + pl = [] + ind = numpy.arange(len(l)) +- for n in xrange(len(rc)): ++ for n in range(len(rc)): + pl.append(pylab.bar(ind + offset + width * n, + [x[1][rc[n]] for x in l], width, color=gc(n))) + +@@ -682,7 +685,7 @@ try: + showsystem() + else: + showpids() +-except IOError, e: ++except IOError as e: + if e.errno == errno.EPIPE: + pass + except KeyboardInterrupt: +-- +2.20.1 +meta-oe/recipes-support/smem/smem_1.4.bb +4
-1@@ -9,7 +9,10 @@ SECTION = "Applications/System" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" -SRC_URI = "http://www.selenic.com/${BPN}/download/${BP}.tar.gz" +SRC_URI = " \ + http://www.selenic.com/${BPN}/download/${BP}.tar.gz \ + file://0001-smem-convert-to-python-3.patch \ +" SRC_URI[md5sum] = "fe79435c3930389bfdb560255c802162" SRC_URI[sha256sum] = "2ea9f878f4cf3c276774c3f7e2a41977a1f2d64f98d2dcb6a15f1f3d84df61ec"
meta-oe/recipes-support/smem/smem_1.4.bb do_install() { · line 30
Quoted 5 lines
meta-oe/recipes-support/smem/smem_1.4.bb +1
-1@@ -24,7 +27,7 @@ do_install() { install -m 0755 ${S}/smemcap ${D}${bindir}/ install -m 0644 ${S}/smem.8 ${D}/${mandir}/man8/ } -RDEPENDS_${PN} += "python-textutils python-compression python-shell python-codecs" +RDEPENDS_${PN} += "python3-compression"
smem also imports numpy and matplotlib (for graphs etc.)
I've posted a different patch addressing all issues (I think).
Cheers,
Andre'
Quoted 6 lines
meta-oe/recipes-support/smem/smem_1.4.bb +0
-0PACKAGES =+ "smemcap"Signature · 1 line
2.20.1
Hi André
Thanks for your patch. This seems more complete and should go in in favour of this one.
No I didn't test with --source, I only tested using smem directly on the embedded target
which worked well for all but the charting options.
I'm aware that the charting option gracefully declines to work when the plugins you now
added with RRECOMMEND are missing.
Max
Am Mi., 5. Feb. 2020 um 17:39 Uhr schrieb André Draszik <[email protected]>:
Quoted 254 lines
Hi,
Interestingly I had been looking at this today as well...
Quoted 5 lines · Max Krummenacher
There seems to be no user of python-textutils python-shell python-codecs in the script, so these rdepends are dropped.
On a i.MX6 based machine smem runs with just python3-compression and its dependencies installed.
Upstream has released v1.5 with almost complete python3 support. I'd say any patches should go on top of that.
Also, I don't think smem --source= will work with your version? Did you test that?
Quoted 7 lines
Signed-off-by Max Krummenacher <[email protected]>--- .../smem/0001-smem-convert-to-python-3.patch | 161 ++++++++++++++++++ meta-oe/recipes-support/smem/smem_1.4.bb | 7 +- 2 files changed, 166 insertions(+), 2 deletions(-) create mode 100644
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patchQuoted 2 lines
diff --git
a/meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patchb/meta-oe/recipes-Quoted 5 lines
support/smem/smem/0001-smem-convert-to-python-3.patchnew file mode 100644
index 000000000..85f35be44
---/dev/null
+++
b/meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patchQuoted 34 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +33
-0@@ -0,0 +1,161 @@ +From 5535a524f6db57c0b2e4a539db733fd9e840c97e Mon Sep 17 00:00:00 2001 +From: Max Krummenacher <[email protected]> +Date: Mon, 3 Feb 2020 21:04:42 +0000 +Subject: [PATCH] smem: convert to python 3 + +Upstream-Status: Pending + +Signed-off-by: Max Krummenacher <[email protected]> +--- + smem | 41 ++++++++++++++++++++++------------------- + 1 file changed, 22 insertions(+), 19 deletions(-) + +diff --git a/smem b/smem +index 0cbd925..577d27b 100755 +--- a/smem ++++ b/smem +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + # + # smem - a tool for meaningful memory reporting + # +@@ -21,7 +21,10 @@ class procdata(object): + def _list(self): + return os.listdir(self.source + "/proc") + def _read(self, f): +- return file(self.source + '/proc/' + f).read() ++ afile = open(self.source + '/proc/' + f) ++ ret = afile.read() ++ afile.close() ++ return ret + def _readlines(self, f): + return self._read(f).splitlines(True)meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch line 43
Quoted 10 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +10
-0+ def _stat(self, f): +@@ -209,7 +212,7 @@ def fromunits(x): + s = dict(k=2**10, K=2**10, kB=2**10, KB=2**10, + M=2**20, MB=2**20, G=2**30, GB=2**30, + T=2**40, TB=2**40) +- for k,v in s.items(): ++ for k,v in list(s.items()): + if x.endswith(k): + return int(float(x[:-len(k)])*v) + sys.stderr.write("Memory size should be written with units, forexample 1024M\n")
Quoted 4 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +4
-0+@@ -240,7 +243,7 @@ def pidtotals(pid): + maps = pidmaps(pid) + t = dict(size=0, rss=0, pss=0, shared_clean=0, shared_dirty=0, + private_clean=0, private_dirty=0, referenced=0, swap=0)meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch
Quoted 10 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +10
-0+- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -296,7 +299,7 @@ def showpids(): + ) + columns = options.columns or 'pid user command swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or'pss')
Review line 58
Quoted 1 line
(quoted diff) +1
-0++ showtable(list(pt.keys()), fields, columns.split(), options.sortor 'pss')
Quoted 7 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +7
-0+ + def maptotals(pids): + totals = {} +@@ -307,7 +310,7 @@ def maptotals(pids): + try: + maps = pidmaps(pid) + seen = {}meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch
Quoted 10 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +10
-0+- for m in maps.iterkeys(): ++ for m in maps.keys(): + name = maps[m]['name'] + if name not in totals: + t = dict(size=0, rss=0, pss=0, shared_clean=0, +@@ -361,7 +364,7 @@ def showmaps(): + ) + columns = options.columns or 'map pids avgpss pss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or'pss')
Review line 76
Quoted 1 line
(quoted diff) +1
-0++ showtable(list(pt.keys()), fields, columns.split(), options.sortor 'pss')
Quoted 7 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +7
-0+ + def usertotals(pids): + totals = {} +@@ -383,7 +386,7 @@ def usertotals(pids): + else: + t = totals[user] +meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch
Quoted 10 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +10
-0+- for m in maps.iterkeys(): ++ for m in maps.keys(): + for k in t: + t[k] += maps[m].get(k, 0) + +@@ -419,7 +422,7 @@ def showusers(): + ) + columns = options.columns or 'user count swap uss pss rss' + +- showtable(pt.keys(), fields, columns.split(), options.sort or'pss')
Review line 94
Quoted 1 line
(quoted diff) +1
-0++ showtable(list(pt.keys()), fields, columns.split(), options.sortor 'pss')
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch
Quoted 8 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +8
-0+ + def showsystem(): + t = totalmem() +@@ -460,14 +463,14 @@ def showsystem(): + 'area not reclaimable')) + + columns = options.columns or 'area used cache noncache' +- showtable(range(len(l)), fields, columns.split(), options.sort or'order')
Review line 103
Quoted 1 line
(quoted diff) +1
-0++ showtable(list(range(len(l))), fields, columns.split(),options.sort or 'order')
Quoted 35 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +35
-0+ + def showfields(fields, f): + if f != list: +- print "unknown field", f +- print "known fields:" ++ print("unknown field", f) ++ print("known fields:") + for l in sorted(fields.keys()): +- print "%-8s %s" % (l, fields[l][-1]) ++ print("%-8s %s" % (l, fields[l][-1])) + + def showtable(rows, fields, columns, sort): + header = "" +@@ -518,10 +521,10 @@ def showtable(rows, fields, columns, sort): + return + + if not options.no_header: +- print header ++ print(header) + + for k,r in l: +- print format % tuple([f(v) for f,v in zip(formatter, r)]) ++ print(format % tuple([f(v) for f,v in zip(formatter, r)])) + + if options.totals: + # totals +@@ -533,8 +536,8 @@ def showtable(rows, fields, columns, sort): + else: + t.append("") + +- print "-" * len(header) +- print format % tuple([f(v) for f,v in zip(formatter, t)]) ++ print("-" * len(header)) ++ print(format % tuple([f(v) for f,v in zip(formatter, t)])) +meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch
Quoted 10 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +10
-0+ def showpie(l, sort): + try: +@@ -605,7 +608,7 @@ def showbar(l, columns, sort): + + pl = [] + ind = numpy.arange(len(l)) +- for n in xrange(len(rc)): ++ for n in range(len(rc)): + pl.append(pylab.bar(ind + offset + width * n, + [x[1][rc[n]] for x in l], width,color=gc(n)))
Review
Quoted 14 lines
meta-oe/recipes-support/smem/smem/0001-smem-convert-to-python-3.patch new file +13
-0+ +@@ -682,7 +685,7 @@ try: + showsystem() + else: + showpids() +-except IOError, e: ++except IOError as e: + if e.errno == errno.EPIPE: + pass + except KeyboardInterrupt: +-- +2.20.1 +(quoted diff) +0
-0b/meta-oe/recipes-support/smem/smem_1.4.bb
Quoted 4 lines
index
947c47b0f..4728e6b79100644meta-oe/recipes-support/smem/smem_1.4.bb SECTION = "Applications/System" · line 17
Quoted 10 lines
meta-oe/recipes-support/smem/smem_1.4.bb +4
-1@@ -9,7 +9,10 @@ SECTION = "Applications/System" LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" -SRC_URI = "http://www.selenic.com/${BPN}/download/${BP}.tar.gz" +SRC_URI = " \ + http://www.selenic.com/${BPN}/download/${BP}.tar.gz \ + file://0001-smem-convert-to-python-3.patch \ +" SRC_URI[md5sum] = "fe79435c3930389bfdb560255c802162" SRC_URI[sha256sum] ="
2ea9f878f4cf3c276774c3f7e2a41977a1f2d64f98d2dcb6a15f1f3d84df61ec"meta-oe/recipes-support/smem/smem_1.4.bb do_install() { · line 27
Quoted 6 lines
meta-oe/recipes-support/smem/smem_1.4.bb +0
-1@@ -24,7 +27,7 @@ do_install() { install -m 0755 ${S}/smemcap ${D}${bindir}/ install -m 0644 ${S}/smem.8 ${D}/${mandir}/man8/ } -RDEPENDS_${PN} += "python-textutils python-compression python-shellpython-codecs"
meta-oe/recipes-support/smem/smem_1.4.bb do_install() { · line 30
Quoted 1 line
meta-oe/recipes-support/smem/smem_1.4.bb +1
-0+RDEPENDS_${PN} += "python3-compression"smem also imports numpy and matplotlib (for graphs etc.)
I've posted a different patch addressing all issues (I think).
Cheers,
Andre'Quoted 6 lines
meta-oe/recipes-support/smem/smem_1.4.bb +0
-1PACKAGES =+ "smemcap" --2.20.1
--
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel