From cc8e1c211ee5c7f6af3d358619b44b3a14ce4deb Mon Sep 17 00:00:00 2001 From: M Bernt Date: Thu, 1 Nov 2018 19:06:46 +0100 Subject: [PATCH 1/2] fix empty loc file bug --- lib/galaxy/tools/data/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/tools/data/__init__.py b/lib/galaxy/tools/data/__init__.py index 6c05b60ccb1..ec039d8c90a 100644 --- a/lib/galaxy/tools/data/__init__.py +++ b/lib/galaxy/tools/data/__init__.py @@ -597,6 +597,7 @@ class TabularToolDataTable(ToolDataTable, Dictifiable): fields.append(field_value) else: fields = entry + log.error("FIELDS %s"%(str(fields))) is_error = False if self.largest_index < len(fields): fields = self._replace_field_separators(fields) @@ -612,6 +613,7 @@ class TabularToolDataTable(ToolDataTable, Dictifiable): if persist and (not is_error or persist_on_error): filename = self.get_filename_for_source(entry_source) + log.error("FILENAME %s"%(str(filename))) if filename is None: # should we default to using any filename here instead? log.error("Unable to determine filename for persisting data table '%s' values: '%s'.", self.name, fields) @@ -624,13 +626,13 @@ class TabularToolDataTable(ToolDataTable, Dictifiable): except IOError as e: log.warning('Error opening data table file (%s) with r+b, assuming file does not exist and will open as wb: %s', filename, e) data_table_fh = open(filename, 'wb') - if os.stat(filename)[6] != 0: + if os.stat(filename).st_size != 0: # ensure last existing line ends with new line data_table_fh.seek(-1, 2) # last char in file last_char = data_table_fh.read(1) if last_char not in [b'\n', b'\r']: data_table_fh.write(b'\n') - fields = "%s\n" % self.separator.join(fields) + fields = "%s\n" % self.separator.join(fields) data_table_fh.write(fields.encode('utf-8')) return not is_error From 13a4238510de2330bcf460519eac2198f66e0c33 Mon Sep 17 00:00:00 2001 From: M Bernt Date: Thu, 1 Nov 2018 19:10:02 +0100 Subject: [PATCH 2/2] removed debug output --- lib/galaxy/tools/data/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/galaxy/tools/data/__init__.py b/lib/galaxy/tools/data/__init__.py index ec039d8c90a..e4a13d0e207 100644 --- a/lib/galaxy/tools/data/__init__.py +++ b/lib/galaxy/tools/data/__init__.py @@ -597,7 +597,6 @@ class TabularToolDataTable(ToolDataTable, Dictifiable): fields.append(field_value) else: fields = entry - log.error("FIELDS %s"%(str(fields))) is_error = False if self.largest_index < len(fields): fields = self._replace_field_separators(fields) @@ -613,7 +612,6 @@ class TabularToolDataTable(ToolDataTable, Dictifiable): if persist and (not is_error or persist_on_error): filename = self.get_filename_for_source(entry_source) - log.error("FILENAME %s"%(str(filename))) if filename is None: # should we default to using any filename here instead? log.error("Unable to determine filename for persisting data table '%s' values: '%s'.", self.name, fields)