Skip to content

Commit

Permalink
Merge pull request #5200 from nsoranzo/python3
Browse files Browse the repository at this point in the history
Fix Python3 compatibility for lib/galaxy/web/
  • Loading branch information
dannon committed Dec 13, 2017
2 parents c468039 + e5be2c3 commit 9adfa31
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 22 deletions.
12 changes: 1 addition & 11 deletions .ci/py3_sources.txt
Expand Up @@ -27,17 +27,7 @@ lib/galaxy/tools/
lib/galaxy/tours/
lib/galaxy/util/
lib/galaxy/visualization/
lib/galaxy/web/base/
lib/galaxy/web/buildapp.py
lib/galaxy/web/framework/base.py
lib/galaxy/web/framework/decorators.py
lib/galaxy/web/framework/helpers/grids.py
lib/galaxy/web/framework/__init__.py
lib/galaxy/web/framework/middleware/error.py
lib/galaxy/web/framework/middleware/static.py
lib/galaxy/web/framework/middleware/statsd.py
lib/galaxy/web/framework/webapp.py
lib/galaxy/web/__init__.py
lib/galaxy/web/
lib/galaxy/webapps/galaxy/api/histories.py
lib/galaxy/webapps/galaxy/api/library_datasets.py
lib/galaxy/webapps/galaxy/api/tours.py
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/web/framework/middleware/batch.py
Expand Up @@ -23,10 +23,10 @@
import json
import logging
import re
from urlparse import urlparse

import routes
from paste import httpexceptions
from six.moves.urllib.parse import urlparse

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/web/framework/middleware/profile.py
Expand Up @@ -149,7 +149,7 @@ def get_func_list(stats, sel_list):
list = stats.fcn_list[:]
order_message = "Ordered by: " + stats.sort_type
else:
list = stats.stats.keys()
list = list(stats.stats.keys())
order_message = "Random listing order was used"
# Do the selection and accumulate messages
select_message = ""
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/web/framework/middleware/remoteuser.py
Expand Up @@ -192,7 +192,7 @@ def __call__(self, environ, start_response):
return self.app(environ, start_response)
else:
log.debug("Unable to identify user. %s not found" % self.remote_user_header)
for k, v in environ.iteritems():
for k, v in environ.items():
log.debug("%s = %s", k, v)

title = "Access to Galaxy is denied"
Expand Down
6 changes: 3 additions & 3 deletions lib/galaxy/web/framework/middleware/translogger.py
Expand Up @@ -5,9 +5,9 @@
"""
import logging
import time
import urllib

from six import string_types
from six.moves.urllib.parse import quote


class TransLogger(object):
Expand Down Expand Up @@ -52,8 +52,8 @@ def __init__(self, application,

def __call__(self, environ, start_response):
start = time.localtime()
req_uri = urllib.quote(environ.get('SCRIPT_NAME', '') +
environ.get('PATH_INFO', ''))
req_uri = quote(environ.get('SCRIPT_NAME', '') +
environ.get('PATH_INFO', ''))
if environ.get('QUERY_STRING'):
req_uri += '?' + environ['QUERY_STRING']
method = environ['REQUEST_METHOD']
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/web/security/__init__.py
Expand Up @@ -98,7 +98,7 @@ def encode_all_ids(self, rval, recursive=False):
if recursive and isinstance(v, dict):
rval[k] = self.encode_all_ids(v, recursive)
elif recursive and isinstance(v, list):
rval[k] = map(lambda el: self.encode_all_ids(el, True), v)
rval[k] = [self.encode_all_ids(el, True) for el in v]
return rval

def decode_id(self, obj_id, kind=None):
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/web/stack/__init__.py
Expand Up @@ -370,8 +370,8 @@ def _do_uwsgi_postfork():


def _mule_fixup():
import urllib2
urllib2._opener = None
from six.moves.urllib.request import install_opener
install_opener(None)


if uwsgi:
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/web/stack/transport.py
Expand Up @@ -76,7 +76,7 @@ def __initialize_locks(self):
if num < need:
raise RuntimeError('Need %i uWSGI locks but only %i exist(s): Set `locks = %i` in uWSGI configuration' % (need, num, need - 1))
sys.exit(1)
self._locks.extend(map(lambda x: 'RECV_MSG_FARM_' + x, farms))
self._locks.extend(['RECV_MSG_FARM_' + x for x in farms])
# this would be nice, but in my 2.0.15 uWSGI, the uwsgi module has no set_option function, and I don't know if it'd work even if the function existed as documented
# if len(self.lock_map) > 1:
# uwsgi.set_option('locks', len(self.lock_map))
Expand Down Expand Up @@ -136,7 +136,7 @@ def start(self):
if not uwsgi.in_farm():
raise RuntimeError('Mule %s is not in a farm! Set `farm = <pool_name>:%s` in uWSGI configuration'
% (uwsgi.mule_id(),
','.join(map(str, range(1, len(filter(lambda x: x.endswith('galaxy/main.py'), self.stack._configured_mules)) + 1)))))
','.join(map(str, range(1, len([x for x in self.stack._configured_mules if x.endswith('galaxy/main.py')]) + 1)))))
elif len(self.stack._farms) > 1:
raise RuntimeError('Mule %s is in multiple farms! This configuration is not supported due to locking issues' % uwsgi.mule_id())
# only mules receive messages so don't bother starting the dispatcher if we're not a mule (although
Expand Down

0 comments on commit 9adfa31

Please sign in to comment.