Skip to content

Commit

Permalink
Python 3 all the stuff.
Browse files Browse the repository at this point in the history
Fixes #62.
  • Loading branch information
jmchilton committed Apr 15, 2015
1 parent 17e374f commit d76cadc
Show file tree
Hide file tree
Showing 43 changed files with 277 additions and 172 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
- TOX_ENV=lint-docs
- TOX_ENV=py26 SETUP=true
- TOX_ENV=py27 SETUP=true
- TOX_ENV=py34 SETUP=true

install:
- pip install tox
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Before you submit a pull request, check that it meets these guidelines:
1. If the pull request adds functionality, the docs should ideally be updated.
Put your new functionality into a function with a docstring. (Until the
@jmchilton learns to do this consistently this is only a suggestion though.)
2. The pull request should work for Python 2.6 and 2.7. Check
2. The pull request should work for Python 2.6, 2.7, and 3.4. Check
https://travis-ci.org/galaxyproject/planemo/pull_requests
and make sure that the tests pass for all supported Python versions. The
tests are imperfect and Travis sometimes fails in a transient fashion so
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ History
0.4.0.dev0
------------------------

* Python 3 support.

------------------------
0.3.0 (2015-04-12)
Expand Down
8 changes: 4 additions & 4 deletions galaxy/objectstore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class DiskObjectStore(ObjectStore):
>>> import tempfile
>>> file_path=tempfile.mkdtemp()
>>> obj = Bunch(id=1)
>>> s = DiskObjectStore(Bunch(umask=077, job_working_directory=file_path, new_file_path=file_path, object_store_check_old_style=False), file_path=file_path)
>>> s = DiskObjectStore(Bunch(umask=0o077, job_working_directory=file_path, new_file_path=file_path, object_store_check_old_style=False), file_path=file_path)
>>> s.create(obj)
>>> s.exists(obj)
True
Expand Down Expand Up @@ -287,7 +287,7 @@ def create(self, obj, **kwargs):
# Create the file if it does not exist
if not dir_only:
open(path, 'w').close() # Should be rb?
umask_fix_perms(path, self.config.umask, 0666)
umask_fix_perms(path, self.config.umask, 0o666)

def empty(self, obj, **kwargs):
return os.path.getsize(self.get_filename(obj, **kwargs)) == 0
Expand All @@ -311,7 +311,7 @@ def delete(self, obj, entire_dir=False, **kwargs):
if self.exists(obj, **kwargs):
os.remove(path)
return True
except OSError, ex:
except OSError as ex:
log.critical('%s delete error %s' % (self._get_filename(obj, **kwargs), ex))
return False

Expand Down Expand Up @@ -344,7 +344,7 @@ def update_from_file(self, obj, file_name=None, create=False, **kwargs):
force_symlink( os.readlink( file_name ), self.get_filename( obj, **kwargs ) )
else:
shutil.copy( file_name, self.get_filename( obj, **kwargs ) )
except IOError, ex:
except IOError as ex:
log.critical('Error copying %s to %s: %s' % (file_name, self._get_filename(obj, **kwargs), ex))
raise ex

Expand Down
6 changes: 3 additions & 3 deletions galaxy/objectstore/rods.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def create(self, obj, **kwargs):
# that we can prevent overwriting
doi = irods.dataObjInp_t()
doi.objPath = rods_path
doi.createMode = 0640
doi.createMode = 0o640
doi.dataSize = 0 # 0 actually means "unknown", although literally 0 would be preferable
irods.addKeyVal( doi.condInput, irods.DEST_RESC_NAME_KW, self.default_resource )
status = irods.rcDataObjCreate( self.rods_conn, doi )
Expand Down Expand Up @@ -195,7 +195,7 @@ def delete( self, obj, entire_dir=False, **kwargs ):
return True
except AttributeError:
log.warning( 'delete(): operation failed: object does not exist: %s', rods_path )
except AssertionError, e:
except AssertionError as e:
# delete() does not raise on deletion failure
log.error( 'delete(): operation failed: %s', e )
finally:
Expand Down Expand Up @@ -281,7 +281,7 @@ def update_from_file(self, obj, file_name=None, create=False, **kwargs):
# put will create if necessary
doi = irods.dataObjInp_t()
doi.objPath = self.__get_rods_path( obj, **kwargs )
doi.createMode = 0640
doi.createMode = 0o640
doi.dataSize = os.stat( file_name ).st_size
doi.numThreads = 0
irods.addKeyVal( doi.condInput, irods.DEST_RESC_NAME_KW, self.default_resource )
Expand Down
6 changes: 3 additions & 3 deletions galaxy/objectstore/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ def _get_bucket(self, bucket_name):
def _fix_permissions(self, rel_path):
""" Set permissions on rel_path"""
for basedir, _, files in os.walk(rel_path):
umask_fix_perms(basedir, self.config.umask, 0777, self.config.gid)
umask_fix_perms(basedir, self.config.umask, 0o777, self.config.gid)
for filename in files:
path = os.path.join(basedir, filename)
# Ignore symlinks
if os.path.islink(path):
continue
umask_fix_perms( path, self.config.umask, 0666, self.config.gid )
umask_fix_perms( path, self.config.umask, 0o666, self.config.gid )

def _construct_path(self, obj, dir_only=None, extra_dir=None, extra_dir_at_root=False, alt_name=None, **kwargs):
rel_path = os.path.join(*directory_hash_id(obj.id))
Expand Down Expand Up @@ -439,7 +439,7 @@ def size(self, obj, **kwargs):
if self._in_cache(rel_path):
try:
return os.path.getsize(self._get_cache_path(rel_path))
except OSError, ex:
except OSError as ex:
log.info("Could not get size of file '%s' in local cache, will try S3. Error: %s", rel_path, ex)
elif self.exists(obj, **kwargs):
return self._get_size_in_s3(rel_path)
Expand Down
6 changes: 3 additions & 3 deletions galaxy/tools/deps/resolvers/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""
from os import environ, pathsep
from os.path import exists, isdir, join
from StringIO import StringIO
from six import StringIO
from subprocess import Popen, PIPE

from ..resolvers import DependencyResolver, INDETERMINATE_DEPENDENCY, Dependency
Expand Down Expand Up @@ -107,13 +107,13 @@ def has_module(self, module, version):

for module_name, module_version in module_generator:
names_match = module == module_name
module_match = names_match and (version == None or module_version == version)
module_match = names_match and (version is None or module_version == version)
if module_match:
return True
return False

def __modules(self):
raw_output = self.__module_avail_output()
raw_output = self.__module_avail_output().decode("utf-8")
for line in StringIO(raw_output):
line = line and line.strip()
if not line or line.startswith("-"):
Expand Down
9 changes: 8 additions & 1 deletion galaxy/util/odict.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
Ordered dictionary implementation.
"""

from UserDict import UserDict
try:
from galaxy import eggs
eggs.require("six")
except ImportError:
# Allow code to operate outside Galaxy.
pass

from six.moves import UserDict


class odict(UserDict):
Expand Down
Loading

0 comments on commit d76cadc

Please sign in to comment.