projects
/
htsworkflow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Initial port to python3
[htsworkflow.git]
/
htsworkflow
/
util
/
api.py
diff --git
a/htsworkflow/util/api.py
b/htsworkflow/util/api.py
index 76ee84dc318005fea7281d6b838244fb869b811f..a90503e8d1e6e10d60da4b927adee95b640f0863 100644
(file)
--- a/
htsworkflow/util/api.py
+++ b/
htsworkflow/util/api.py
@@
-1,7
+1,7
@@
"""Common functions for accessing the HTS Workflow REST API
"""
import base64
"""Common functions for accessing the HTS Workflow REST API
"""
import base64
-from
ConfigP
arser import SafeConfigParser
+from
configp
arser import SafeConfigParser
import random
import logging
import random
import logging
@@
-13,9
+13,9
@@
except ImportError:
import os
from optparse import OptionGroup
import os
from optparse import OptionGroup
-import urllib
-import urllib
2
-import urlparse
+import urllib
.request, urllib.parse, urllib.error
+import urllib
.request, urllib.error, urllib.parse
+import url
lib.
parse
LOGGER = logging.getLogger(__name__)
LOGGER = logging.getLogger(__name__)
@@
-79,7
+79,7
@@
def library_url(root_url, library_id):
"""
url_fragment = '/samples/library/%s/json' % (library_id,)
"""
url_fragment = '/samples/library/%s/json' % (library_id,)
- url = urlparse.urljoin(root_url, url_fragment)
+ url = url
lib.
parse.urljoin(root_url, url_fragment)
return url
return url
@@
-99,7
+99,7
@@
def flowcell_url(root_url, flowcell_id):
http://localhost/experiments/config/1234AAXX/json
"""
url_fragment = '/experiments/config/%s/json' % (flowcell_id,)
http://localhost/experiments/config/1234AAXX/json
"""
url_fragment = '/experiments/config/%s/json' % (flowcell_id,)
- url = urlparse.urljoin(root_url, url_fragment)
+ url = url
lib.
parse.urljoin(root_url, url_fragment)
return url
return url
@@
-120,7
+120,7
@@
def lanes_for_user_url(root_url, username):
"""
url_fragment = '/lanes_for/%s/json' % (username,)
"""
url_fragment = '/lanes_for/%s/json' % (username,)
- url = urlparse.urljoin(root_url, url_fragment)
+ url = url
lib.
parse.urljoin(root_url, url_fragment)
return url
return url
@@
-129,9
+129,9
@@
def retrieve_info(url, apidata):
Return a dictionary from the HTSworkflow API
"""
try:
Return a dictionary from the HTSworkflow API
"""
try:
- apipayload = urllib.urlencode(apidata)
- web = urllib
2
.urlopen(url, apipayload)
- except urllib
2.URLError,
e:
+ apipayload = urllib.
parse.
urlencode(apidata)
+ web = urllib
.request
.urlopen(url, apipayload)
+ except urllib
.error.URLError as
e:
if hasattr(e, 'code') and e.code == 404:
LOGGER.info("%s was not found" % (url,))
return None
if hasattr(e, 'code') and e.code == 404:
LOGGER.info("%s was not found" % (url,))
return None
@@
-168,7
+168,7
@@
def make_django_secret_key(size=216):
"""return key suitable for use as secret key"""
try:
source = random.SystemRandom()
"""return key suitable for use as secret key"""
try:
source = random.SystemRandom()
- except AttributeError
,
e:
+ except AttributeError
as
e:
source = random.random()
bits = source.getrandbits(size)
chars = []
source = random.random()
bits = source.getrandbits(size)
chars = []