From d2ef6cb2f3070ea44c837d063882a62f7f355cf5 Mon Sep 17 00:00:00 2001 From: "Dr. Frank Hoffmann" Date: Sun, 28 Apr 2019 20:08:00 +0200 Subject: [PATCH] fixed dataset printing --- conf/zms3.formulator.metaobj.xml | 8 ++++---- setup.py | 2 +- zms3/formulator/ZMSFormulator.py | 18 ++++++++---------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/conf/zms3.formulator.metaobj.xml b/conf/zms3.formulator.metaobj.xml index a834376..30f78aa 100644 --- a/conf/zms3.formulator.metaobj.xml +++ b/conf/zms3.formulator.metaobj.xml @@ -675,7 +675,7 @@ $ZMI.registerReady(function() { - + @@ -1214,7 +1214,7 @@ textarea.form-control.rawJSON { - + @@ -1246,7 +1246,7 @@ textarea.form-control.rawJSON { 0 - + @@ -1524,7 +1524,7 @@ def downloadData(self): - + diff --git a/setup.py b/setup.py index 426498d..de67900 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ else: site_packages = get_python_lib() -VERSION = '3.4.14' +VERSION = '3.4.15' zmspkg_name = 'formulator' branch_name = 'master' diff --git a/zms3/formulator/ZMSFormulator.py b/zms3/formulator/ZMSFormulator.py index d35c7ba..468eb96 100644 --- a/zms3/formulator/ZMSFormulator.py +++ b/zms3/formulator/ZMSFormulator.py @@ -373,6 +373,7 @@ def printDataRaw(self, receivedData=None, frmt='txt'): data = self.getData() header = ['TIMESTAMP'] output = [] + s = '' # text stream # Received data if isinstance(receivedData, dict): @@ -382,22 +383,21 @@ def printDataRaw(self, receivedData=None, frmt='txt'): if isinstance(data, dict): if frmt=='txt': s = '%s entries:\n\n'%len(data) - else: - s = '' - s1 = s2 = '' - for t, v in sorted(data.iteritems()): + if len(data) > 0: + header.extend( [ i[0] for i in data[data.keys()[0]] ] ) + s += '#/#'.join(header).upper() +'\n' + + for t, v in sorted(data.iteritems()): + output = [] output.append(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t))) for i in sorted(v): i1, i2 = i - header.append(i1.upper()) outstr = self.this.str_item(i2) outstr = outstr.replace('\n',', ') output.append(_globals.html_quote(outstr)) - s1 = '#/#'.join(header) - s2 += '#/#'.join(output) + '\n' + s += '#/#'.join(output) + '\n' - s += s1.upper() + '\n' + s2 # Handle SQL-Storage else: @@ -406,8 +406,6 @@ def printDataRaw(self, receivedData=None, frmt='txt'): res = con.execute(sel) if frmt=='txt': s = '%s entries:\n\n'%res.rowcount - else: - s = '' sel = select([self.sqldb.c.ZMS_FRM_KEY]).distinct().order_by(self.sqldb.c.ZMS_FRM_ORD, self.sqldb.c.ZMS_FRM_KEY) con = self.engine.connect()