From a322118877077987fc505be38f97ea69469332a5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 26 Feb 2019 11:09:23 -0500 Subject: [PATCH 1/5] Fix debian build --- confluent_server/builddeb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/confluent_server/builddeb b/confluent_server/builddeb index 40d5ac6c..21da0f26 100755 --- a/confluent_server/builddeb +++ b/confluent_server/builddeb @@ -31,6 +31,8 @@ if [ "$DPKGNAME" = "confluent-server" ]; then sed -i 's/^\(Depends:.*\)/\1, confluent-client, python-lxml, python-eficompressor, python-pycryptodome/' debian/control fi fi +head -n -1 debian/control > debian/control1 +mv debian/control1 debian/control echo 'Provides: python-'$DPKGNAME >> debian/control echo 'Conflicts: python-'$DPKGNAME >> debian/control echo 'Replaces: python-'$DPKGNAME >> debian/control From db812ac292fe609c1ed3ad5b9c186b78634ac902 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 26 Feb 2019 13:02:04 -0500 Subject: [PATCH 2/5] Specify confluent client deb name --- confluent_server/builddeb | 1 + 1 file changed, 1 insertion(+) diff --git a/confluent_server/builddeb b/confluent_server/builddeb index 21da0f26..3118bbf6 100755 --- a/confluent_server/builddeb +++ b/confluent_server/builddeb @@ -30,6 +30,7 @@ if [ "$DPKGNAME" = "confluent-server" ]; then else sed -i 's/^\(Depends:.*\)/\1, confluent-client, python-lxml, python-eficompressor, python-pycryptodome/' debian/control fi + echo 'confluent_client confluent-client' >> debian/pydist-overrides fi head -n -1 debian/control > debian/control1 mv debian/control1 debian/control From ad64cda2492dd5b9b95bf8b689bfa841bb14d310 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 26 Feb 2019 13:39:11 -0500 Subject: [PATCH 3/5] Rework transition package logic --- confluent_server/builddeb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/confluent_server/builddeb b/confluent_server/builddeb index 3118bbf6..f0f45654 100755 --- a/confluent_server/builddeb +++ b/confluent_server/builddeb @@ -35,8 +35,9 @@ fi head -n -1 debian/control > debian/control1 mv debian/control1 debian/control echo 'Provides: python-'$DPKGNAME >> debian/control -echo 'Conflicts: python-'$DPKGNAME >> debian/control +#echo 'Conflicts: python-'$DPKGNAME >> debian/control echo 'Replaces: python-'$DPKGNAME >> debian/control +echo 'Breaks: python-'$DPKGNAME >> debian/control dpkg-buildpackage -rfakeroot -uc -us -i if [ $? -ne 0 ]; then From 161cf37f463ba9bda73d058c10c4e3b477a7d6a5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 26 Feb 2019 13:57:11 -0500 Subject: [PATCH 4/5] Fix nodediscover order and csv together --- confluent_client/bin/nodediscover | 17 +++++------------ confluent_client/confluent/client.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/confluent_client/bin/nodediscover b/confluent_client/bin/nodediscover index 7331b365..2c34c697 100755 --- a/confluent_client/bin/nodediscover +++ b/confluent_client/bin/nodediscover @@ -69,10 +69,7 @@ def print_disco(options, session, currmac, outhandler, columns): record.append(','.join(rawval)) else: record.append(str(rawval)) - if options.csv: - csv.writer(sys.stdout).writerow(record) - else: - outhandler.add_row(record) + outhandler.add_row(record) def process_header(header): @@ -204,7 +201,6 @@ def import_csv(options, session): def list_discovery(options, session): - outhandler = None orderby = None if options.fields: columns = [] @@ -219,15 +215,12 @@ def list_discovery(options, session): for field in columns: if options.order.lower() == field.lower(): orderby = field - if options.csv: - if orderby: - hsht - csv.writer(sys.stdout).writerow(columns) - else: - outhandler = client.Tabulator(columns) + outhandler = client.Tabulator(columns) for mac in list_matching_macs(options, session): print_disco(options, session, mac, outhandler, columns) - if outhandler: + if options.csv: + outhandler.write_csv(sys.stdout, orderby) + else: for row in outhandler.get_table(orderby): print(row) diff --git a/confluent_client/confluent/client.py b/confluent_client/confluent/client.py index 64e9c3a9..b79d865a 100644 --- a/confluent_client/confluent/client.py +++ b/confluent_client/confluent/client.py @@ -16,6 +16,7 @@ # limitations under the License. import anydbm as dbm +import csv import errno import fnmatch import hashlib @@ -70,6 +71,23 @@ class Tabulator(object): for row in self.rows: yield fmtstr.format(*row) + def write_csv(self, output, order=None): + output = csv.writer(output) + output.writerow(self.headers) + i = 0 + for head in self.headers: + if order and order == head: + order = i + i = i + 1 + if order is not None: + for row in sorted( + self.rows, + key=lambda x: sortutil.naturalize_string(x[order])): + output.writerow(row) + else: + for row in self.rows: + output.writerow(row) + def printerror(res, node=None): exitcode = 0 From 31220292e536b1ef8d35365283f64e43cb86f156 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 26 Feb 2019 14:22:19 -0500 Subject: [PATCH 5/5] Try debian build with minimum on breaks/replaces --- confluent_server/builddeb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/confluent_server/builddeb b/confluent_server/builddeb index f0f45654..95ffe99d 100755 --- a/confluent_server/builddeb +++ b/confluent_server/builddeb @@ -36,8 +36,8 @@ head -n -1 debian/control > debian/control1 mv debian/control1 debian/control echo 'Provides: python-'$DPKGNAME >> debian/control #echo 'Conflicts: python-'$DPKGNAME >> debian/control -echo 'Replaces: python-'$DPKGNAME >> debian/control -echo 'Breaks: python-'$DPKGNAME >> debian/control +echo 'Replaces: python-'$DPKGNAME' (<<2)' >> debian/control +echo 'Breaks: python-'$DPKGNAME' (<<2)' >> debian/control dpkg-buildpackage -rfakeroot -uc -us -i if [ $? -ne 0 ]; then