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 diff --git a/confluent_server/builddeb b/confluent_server/builddeb index 40d5ac6c..95ffe99d 100755 --- a/confluent_server/builddeb +++ b/confluent_server/builddeb @@ -30,10 +30,14 @@ 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 echo 'Provides: python-'$DPKGNAME >> debian/control -echo 'Conflicts: python-'$DPKGNAME >> debian/control -echo 'Replaces: python-'$DPKGNAME >> debian/control +#echo 'Conflicts: 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