commit:     dfe7211eaba93e58b530ec6fd80f3478e4ec3653
Author:     Tomáš Mózes <hydrapolic <AT> gmail <DOT> com>
AuthorDate: Fri Jun 19 09:18:02 2020 +0000
Commit:     Joonas Niilola <juippis <AT> gentoo <DOT> org>
CommitDate: Thu Jul 16 14:38:40 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dfe7211e

sys-apps/dstat: fix csv output

Closes: https://bugs.gentoo.org/728736
Signed-off-by: Tomáš Mózes <hydrapolic <AT> gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/16322
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>

 sys-apps/dstat/dstat-0.7.4-r2.ebuild      | 56 +++++++++++++++++++++++++++++++
 sys-apps/dstat/files/fix-csv-output.patch | 21 ++++++++++++
 2 files changed, 77 insertions(+)

diff --git a/sys-apps/dstat/dstat-0.7.4-r2.ebuild 
b/sys-apps/dstat/dstat-0.7.4-r2.ebuild
new file mode 100644
index 00000000000..ef9a1a736ea
--- /dev/null
+++ b/sys-apps/dstat/dstat-0.7.4-r2.ebuild
@@ -0,0 +1,56 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6..9} )
+
+inherit python-r1
+
+DESCRIPTION="Versatile replacement for vmstat, iostat and ifstat"
+HOMEPAGE="http://dag.wieers.com/home-made/dstat/";
+SRC_URI="https://github.com/dagwieers/${PN}/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 
~x86-linux"
+IUSE="doc examples"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RDEPEND="${PYTHON_DEPS}
+       dev-python/six[${PYTHON_USEDEP}]"
+DEPEND="${RDEPEND}"
+
+PATCHES=(
+       "${FILESDIR}/dstat-${PV}-skip-non-sandbox-tests.patch"
+       "${FILESDIR}/fix-collections-deprecation-warning.patch"
+       "${FILESDIR}/fix-csv-output.patch"
+)
+
+src_prepare() {
+
+       # bug fix: allow delay to be specified
+       # backport from: https://github.com/dagwieers/dstat/pull/167/files
+       sed -i -e 's; / op\.delay; // op.delay;' "dstat" || die
+
+       default
+}
+
+src_install() {
+       python_foreach_impl python_doscript dstat
+
+       insinto /usr/share/dstat
+       newins dstat dstat.py
+       doins plugins/dstat_*.py
+
+       doman docs/dstat.1
+
+       einstalldocs
+
+       if use examples; then
+               dodoc examples/{mstat,read}.py
+       fi
+       if use doc; then
+               dodoc docs/*.html
+       fi
+}

diff --git a/sys-apps/dstat/files/fix-csv-output.patch 
b/sys-apps/dstat/files/fix-csv-output.patch
new file mode 100644
index 00000000000..e44125b0e46
--- /dev/null
+++ b/sys-apps/dstat/files/fix-csv-output.patch
@@ -0,0 +1,21 @@
+https://serverfault.com/questions/996996/dstat-fails-to-start-trying-to-load-python3s-csv
+
+diff --git a/dstat b/dstat
+index 9359965..1682fb5 100755
+--- a/dstat
++++ b/dstat
+@@ -541,12 +541,12 @@ class dstat:
+ 
+         line = ''
+         for i, name in enumerate(self.vars):
+-            if isinstance(self.val[name], types.ListType) or 
isinstance(self.val[name], types.TupleType):
++            if isinstance(self.val[name], (tuple, list)):
+                 for j, val in enumerate(self.val[name]):
+                     line = line + printcsv(val)
+                     if j + 1 != len(self.val[name]):
+                         line = line + char['sep']
+-            elif isinstance(self.val[name], types.StringType):
++            elif isinstance(self.val[name], str):
+                 line = line + self.val[name]
+             else:
+                 line = line + printcsv(self.val[name])

Reply via email to