Skip to content

Commit b286fd4

Browse files
authored
Merge pull request #64 from gijzelaerr/py3compat
fix a py3 compat issue
2 parents d5d83b5 + 5fb7b9d commit b286fd4

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
language: python
22
python:
33
- '2.7'
4+
- '3.5'
5+
- '3.6'
6+
- '3.7'
47
before_install:
58
- sudo apt-get update -qq
69
- pip install toil[all]==3.17.0

test/test_client_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def testSupportedFormatChecking(self):
6464
for file_format, location in self.local.items():
6565
if file_format != 'unsupported':
6666
# Tests the behavior after receiving supported file types with and without the 'file://' prefix
67-
self.assertEquals(wf_info(location), self.expected[file_format])
68-
self.assertEquals(wf_info(location[7:]), self.expected[file_format])
67+
self.assertEqual(wf_info(location), self.expected[file_format])
68+
self.assertEqual(wf_info(location[7:]), self.expected[file_format])
6969

7070
else:
7171
# Tests behavior after receiving a non supported file type.
@@ -91,7 +91,7 @@ def testFileLocationChecking(self):
9191
wf_info(location)
9292

9393
else:
94-
self.assertEquals(wf_info(location), self.expected[file_format])
94+
self.assertEqual(wf_info(location), self.expected[file_format])
9595
self.assertFalse(os.path.isfile(os.path.join(os.getcwd(), 'fetchedFromRemote.' + file_format)))
9696

9797

wes_client/util.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
import yaml
66
import glob
77
import requests
8-
import urllib
98
import logging
109

1110
from wes_service.util import visit
12-
from urllib import urlopen
11+
12+
from future.standard_library import hooks
13+
14+
with hooks():
15+
from urllib.request import urlopen, pathname2url
1316

1417

1518
def two_seven_compatible(filePath):
@@ -56,7 +59,7 @@ def wf_info(workflow_path):
5659
html = urlopen(workflow_path).read()
5760
local_loc = os.path.join(os.getcwd(), 'fetchedFromRemote.' + file_type)
5861
with open(local_loc, 'w') as f:
59-
f.write(html)
62+
f.write(html.decode())
6063
version = wf_info('file://' + local_loc)[0] # Don't take the file_type here, found it above.
6164
os.remove(local_loc) # TODO: Find a way to avoid recreating file before version determination.
6265
else:
@@ -86,7 +89,7 @@ def fixpaths(d):
8689
if "path" in d:
8790
if ":" not in d["path"]:
8891
local_path = os.path.normpath(os.path.join(os.getcwd(), basedir, d["path"]))
89-
d["location"] = urllib.pathname2url(local_path)
92+
d["location"] = pathname2url(local_path)
9093
else:
9194
d["location"] = d["path"]
9295
del d["path"]

wes_service/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def collect_attachments(self, run_id=None):
6767
content = v.read()
6868
body[k] = json.loads(content)
6969
else:
70-
body[k] = v.read()
70+
body[k] = v.read().decode()
7171

7272
if ":" not in body["workflow_url"]:
7373
body["workflow_url"] = "file://%s" % os.path.join(tempdir, secure_filename(body["workflow_url"]))

0 commit comments

Comments
 (0)