From 54d6a54367ed6a852b54a89f567d901f494e682a Mon Sep 17 00:00:00 2001 From: peterjc Date: Mon, 29 May 2017 17:40:33 +0100 Subject: [PATCH] Avoid locale specific string.letters for job_name The job_name sanitation can fail if the locale specific string.letters contains unexpected characters. e.g. Saravanaraj Ayyampalayam reported getting the following under locale en_US.iso885915 Traceback (most recent call last): File /.../galaxy-dist/lib/galaxy/jobs/runners/drmaa.py, line 397, in job_name = ''.join( x if x in ( string.letters + string.digits + '_' ) else '_' for x in job_name ) UnicodeDecodeError: 'ascii' codec can't decode byte 0xa6 in position 52: ordinal not in range(128) See http://dev.list.galaxyproject.org/Issue-with-job-name-UnicodeDecodeError-in-drmaa-td4670784.html or https://lists.galaxyproject.org/pipermail/galaxy-dev/2017-May/025687.html The downside of this proposed change would be to mask reasonable non ASCII letters from the job name on a well defined system with consistent locale settings for both Galaxy and the Cluster. But ASCII only seems safer. --- lib/galaxy/jobs/runners/__init__.py | 2 +- lib/galaxy/jobs/runners/drmaa.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/jobs/runners/__init__.py b/lib/galaxy/jobs/runners/__init__.py index ebf4859a7f60..6ee51c87608d 100644 --- a/lib/galaxy/jobs/runners/__init__.py +++ b/lib/galaxy/jobs/runners/__init__.py @@ -419,7 +419,7 @@ def set_defaults( self, files_dir ): job_name += '_%s' % self.job_wrapper.tool.old_id if self.job_wrapper.user: job_name += '_%s' % self.job_wrapper.user - self.job_name = ''.join( map( lambda x: x if x in ( string.letters + string.digits + '_' ) else '_', job_name ) ) + self.job_name = ''.join( map( lambda x: x if x in ( string.ascii_letters + string.digits + '_' ) else '_', job_name ) ) @staticmethod def default_job_file( files_dir, id_tag ): diff --git a/lib/galaxy/jobs/runners/drmaa.py b/lib/galaxy/jobs/runners/drmaa.py index 7c089847762b..5c5dc623ddcc 100644 --- a/lib/galaxy/jobs/runners/drmaa.py +++ b/lib/galaxy/jobs/runners/drmaa.py @@ -394,7 +394,7 @@ def _job_name(self, job_wrapper): job_name += '_%s' % job_wrapper.tool.old_id if external_runjob_script is None: job_name += '_%s' % job_wrapper.user - job_name = ''.join( x if x in ( string.letters + string.digits + '_' ) else '_' for x in job_name ) + job_name = ''.join( x if x in ( string.ascii_letters + string.digits + '_' ) else '_' for x in job_name ) if self.restrict_job_name_length: job_name = job_name[:self.restrict_job_name_length] return job_name