From b0cd8d128824627de05c99c3e16d8effcd6a70d5 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Mon, 20 Jul 2015 11:37:23 -0700 Subject: [PATCH] python3 byte vs str compatibility for constructing document data urls --- htsworkflow/submission/encoded.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htsworkflow/submission/encoded.py b/htsworkflow/submission/encoded.py index 97f66e9..964cdb6 100644 --- a/htsworkflow/submission/encoded.py +++ b/htsworkflow/submission/encoded.py @@ -498,7 +498,7 @@ class TypedColumnParser(object): def parse_sheet_string_type(value): """Helper function to parse :string columns in sheet (the default) """ - return unicode(value) + return str(value) def __getitem__(self, name): parser = { @@ -559,7 +559,7 @@ class Document(object): def get_document(self): if os.path.exists(self.url): - with open(self.url, 'r') as instream: + with open(self.url, 'rb') as instream: assert self.url.endswith('pdf') self.content_type = 'application/pdf' self.document = instream.read() @@ -577,7 +577,7 @@ class Document(object): 'attachment': { 'download': self.filename, 'type': self.content_type, - 'href': 'data:'+self.content_type+';base64,' + base64.b64encode(self.document), + 'href': 'data:'+self.content_type+';base64,' + base64.b64encode(self.document).decode('ascii'), 'md5sum': self.md5sum.hexdigest() }, 'document_type': self.document_type, -- 2.30.2