Skip to content

Commit

Permalink
Merge pull request #92 from justin-chandra/fix-export-options
Browse files Browse the repository at this point in the history
Fixes to export options
  • Loading branch information
guysoft authored May 17, 2023
2 parents e7e614f + ceb586e commit 8abf20a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions octoprint_printhistory/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def exportHistoryData(self, exportType):
import sys
if sys.version_info >= (3,0):
from io import StringIO
from io import BytesIO
import csv
else:
from StringIO import StringIO
Expand Down Expand Up @@ -89,6 +90,9 @@ def exportHistoryData(self, exportType):
elif exportType == 'excel':
import xlsxwriter

if sys.version_info >= (3,0):
si = BytesIO()

workbook = xlsxwriter.Workbook(si)
worksheet = workbook.add_worksheet()
for column, header in enumerate(headers):
Expand Down
6 changes: 3 additions & 3 deletions octoprint_printhistory/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def rename_duplicates(immutable, mutable, prefix):
"""
for value in mutable:
if value in immutable:
mutable[mutable.index(value)] = str(prefix) + value
value = str(prefix) + value
return mutable

def namedtuple_with_defaults(typename, field_names, default_values=()):
Expand All @@ -29,7 +29,7 @@ def namedtuple_with_defaults(typename, field_names, default_values=()):
"""
T = collections.namedtuple(typename, field_names)
T.__new__.__defaults__ = (None,) * len(T._fields)
if isinstance(default_values, collections.Mapping):
if isinstance(default_values, collections.abc.Mapping):
prototype = T(**default_values)
else:
prototype = T(*default_values)
Expand All @@ -40,6 +40,6 @@ def load_json(dictionary, key):
parameters_json = dictionary.get(key)
try:
parameters = json.loads(parameters_json)
except ValueError:
except:
parameters = {}
return parameters

0 comments on commit 8abf20a

Please sign in to comment.