diff --git a/contrib/nagios/check_galaxy.py b/contrib/nagios/check_galaxy.py
index 36b021f1466..7588d24cbdd 100755
--- a/contrib/nagios/check_galaxy.py
+++ b/contrib/nagios/check_galaxy.py
@@ -62,7 +62,7 @@ def usage():
try:
opts, args = getopt.getopt( sys.argv[1:], 'n' )
-except getopt.GetoptError, e:
+except getopt.GetoptError as e:
print str(e)
usage()
if len( args ) < 1:
@@ -133,7 +133,7 @@ class Browser:
tc.get_browser()._browser.set_handle_redirect(True)
dprint( "%s is returning redirect (302)" % url )
return(True)
- except twill.errors.TwillAssertionError, e:
+ except twill.errors.TwillAssertionError as e:
tc.get_browser()._browser.set_handle_redirect(True)
dprint( "%s is not returning redirect (302): %s" % (url, e) )
code = tc.browser.get_code()
diff --git a/lib/galaxy/model/migrate/versions/0018_ordered_tags_and_page_tags.py b/lib/galaxy/model/migrate/versions/0018_ordered_tags_and_page_tags.py
index dc232ae37d5..bf2c144f22e 100644
--- a/lib/galaxy/model/migrate/versions/0018_ordered_tags_and_page_tags.py
+++ b/lib/galaxy/model/migrate/versions/0018_ordered_tags_and_page_tags.py
@@ -79,7 +79,7 @@ def upgrade(migrate_engine):
try:
HistoryDatasetAssociationTagAssociation_table.drop()
HistoryDatasetAssociationTagAssociation_table.create()
- except OperationalError, e:
+ except OperationalError as e:
# Handle error that results from and index name that is too long; this occurs
# in MySQL.
if str(e).find("CREATE INDEX") != -1:
diff --git a/lib/galaxy/model/migrate/versions/0057_request_notify.py b/lib/galaxy/model/migrate/versions/0057_request_notify.py
index 827d176eb3c..711a352fff8 100644
--- a/lib/galaxy/model/migrate/versions/0057_request_notify.py
+++ b/lib/galaxy/model/migrate/versions/0057_request_notify.py
@@ -22,7 +22,7 @@ def upgrade(migrate_engine):
metadata.reflect()
try:
Request_table = Table( "request", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
Request_table = None
log.debug( "Failed loading table 'request'" )
diff --git a/lib/galaxy/model/migrate/versions/0059_sample_dataset_file_path.py b/lib/galaxy/model/migrate/versions/0059_sample_dataset_file_path.py
index 16df1aa883b..c03d59129f6 100644
--- a/lib/galaxy/model/migrate/versions/0059_sample_dataset_file_path.py
+++ b/lib/galaxy/model/migrate/versions/0059_sample_dataset_file_path.py
@@ -19,7 +19,7 @@ def upgrade(migrate_engine):
metadata.reflect()
try:
SampleDataset_table = Table( "sample_dataset", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
SampleDataset_table = None
log.debug( "Failed loading table 'sample_dataset'" )
diff --git a/lib/galaxy/model/migrate/versions/0067_populate_sequencer_table.py b/lib/galaxy/model/migrate/versions/0067_populate_sequencer_table.py
index 71dc1884207..88622f60262 100644
--- a/lib/galaxy/model/migrate/versions/0067_populate_sequencer_table.py
+++ b/lib/galaxy/model/migrate/versions/0067_populate_sequencer_table.py
@@ -193,7 +193,7 @@ def upgrade(migrate_engine):
metadata.reflect()
try:
RequestType_table = Table( "request_type", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
RequestType_table = None
log.debug( "Failed loading table 'request_type'" )
if RequestType_table is None:
@@ -201,7 +201,7 @@ def upgrade(migrate_engine):
# load the sequencer table
try:
Sequencer_table = Table( "sequencer", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
Sequencer_table = None
log.debug( "Failed loading table 'sequencer'" )
if Sequencer_table is None:
@@ -258,7 +258,7 @@ def downgrade(migrate_engine):
metadata.reflect()
try:
RequestType_table = Table( "request_type", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
RequestType_table = None
log.debug( "Failed loading table 'request_type'" )
if RequestType_table is not None:
diff --git a/lib/galaxy/model/migrate/versions/0068_rename_sequencer_to_external_services.py b/lib/galaxy/model/migrate/versions/0068_rename_sequencer_to_external_services.py
index 7199dceb803..6514438dd6f 100644
--- a/lib/galaxy/model/migrate/versions/0068_rename_sequencer_to_external_services.py
+++ b/lib/galaxy/model/migrate/versions/0068_rename_sequencer_to_external_services.py
@@ -38,14 +38,14 @@ def upgrade(migrate_engine):
# add a foreign key to the external_service table in the sample_dataset table
try:
SampleDataset_table = Table( "sample_dataset", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
SampleDataset_table = None
log.debug( "Failed loading table 'sample_dataset'" )
if SampleDataset_table is None:
return
try:
Sequencer_table = Table( "sequencer", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
Sequencer_table = None
log.debug( "Failed loading table 'sequencer'" )
if Sequencer_table is None:
@@ -92,7 +92,7 @@ def upgrade(migrate_engine):
migrate_engine.execute( cmd )
try:
ExternalServices_table = Table( "external_service", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
ExternalServices_table = None
log.debug( "Failed loading table 'external_service'" )
if ExternalServices_table is None:
@@ -201,7 +201,7 @@ def downgrade(migrate_engine):
return
try:
ExternalServices_table = Table( "external_service", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
ExternalServices_table = None
log.debug( "Failed loading table 'external_service'" )
if ExternalServices_table is None:
@@ -262,7 +262,7 @@ def downgrade(migrate_engine):
# drop the 'external_service_id' column in the 'sample_dataset' table
try:
SampleDataset_table = Table( "sample_dataset", metadata, autoload=True )
- except NoSuchTableError, e:
+ except NoSuchTableError:
SampleDataset_table = None
log.debug( "Failed loading table 'sample_dataset'" )
if SampleDataset_table is None:
diff --git a/scripts/api/upload_to_history.py b/scripts/api/upload_to_history.py
index 212456d0fba..7b538822e29 100755
--- a/scripts/api/upload_to_history.py
+++ b/scripts/api/upload_to_history.py
@@ -8,7 +8,7 @@ import sys
try:
import requests
-except ImportError, imp_err:
+except ImportError:
print "Could not import the requests module. See http://docs.python-requests.org/en/latest/" + \
" or install with 'pip install requests'"
raise
diff --git a/scripts/check_galaxy.py b/scripts/check_galaxy.py
index 5d140dbb89b..65d52ffc8d5 100755
--- a/scripts/check_galaxy.py
+++ b/scripts/check_galaxy.py
@@ -54,7 +54,7 @@ def usage():
try:
opts, args = getopt.getopt( sys.argv[1:], 'n' )
-except getopt.GetoptError, e:
+except getopt.GetoptError as e:
print str(e)
usage()
if len( args ) < 1:
@@ -151,7 +151,7 @@ class Browser:
tc.get_browser()._browser.set_handle_redirect(True)
dprint( "%s is returning redirect (302)" % url )
return(True)
- except twill.errors.TwillAssertionError, e:
+ except twill.errors.TwillAssertionError as e:
tc.get_browser()._browser.set_handle_redirect(True)
dprint( "%s is not returning redirect (302): %s" % (url, e) )
code = tc.browser.get_code()
diff --git a/scripts/cleanup_datasets/cleanup_datasets.py b/scripts/cleanup_datasets/cleanup_datasets.py
index 29161541b62..36d8b5a151f 100755
--- a/scripts/cleanup_datasets/cleanup_datasets.py
+++ b/scripts/cleanup_datasets/cleanup_datasets.py
@@ -440,7 +440,7 @@ def _delete_dataset( dataset, app, remove_from_disk, info_only=False, is_deletab
try:
print "Removing disk file ", metadata_file.file_name
os.unlink( metadata_file.file_name )
- except Exception, e:
+ except Exception as e:
print "Error, exception: %s caught attempting to purge metadata file %s\n" % ( str( e ), metadata_file.file_name )
metadata_file.purged = True
app.sa_session.add( metadata_file )
@@ -488,7 +488,7 @@ def _purge_dataset( app, dataset, remove_from_disk, info_only=False ):
print "Dataset %i will be purged (without 'info_only' mode)" % (dataset.id)
else:
print "This dataset (%i) is not purgable, the file (%s) will not be removed.\n" % ( dataset.id, dataset.file_name )
- except OSError, exc:
+ except OSError as exc:
print "Error, dataset file has already been removed: %s" % str( exc )
print "Purging dataset id", dataset.id
dataset.purged = True
@@ -496,7 +496,7 @@ def _purge_dataset( app, dataset, remove_from_disk, info_only=False ):
app.sa_session.flush()
except ObjectNotFound:
print "Dataset %i cannot be found in the object store" % dataset.id
- except Exception, exc:
+ except Exception as exc:
print "Error attempting to purge data file: ", dataset.file_name, " error: ", str( exc )
else:
print "Error: '%s' has not previously been deleted, so it cannot be purged\n" % dataset.file_name
diff --git a/scripts/cleanup_datasets/pgcleanup.py b/scripts/cleanup_datasets/pgcleanup.py
index ade7d6229b8..ab8ca7c3250 100755
--- a/scripts/cleanup_datasets/pgcleanup.py
+++ b/scripts/cleanup_datasets/pgcleanup.py
@@ -239,14 +239,14 @@ class Cleanup(object):
try:
filename = self.object_store.get_filename(metadata_file, extra_dir='_metadata_files', extra_dir_at_root=True, alt_name="metadata_%d.dat" % id)
self._log('Removing from disk: %s' % filename, action_name)
- except (ObjectNotFound, AttributeError), e:
+ except (ObjectNotFound, AttributeError) as e:
log.error('Unable to get MetadataFile %s filename: %s' % (id, e))
return
if not self.options.dry_run:
try:
os.unlink(filename)
- except Exception, e:
+ except Exception as e:
self._log('Removal of %s failed with error: %s' % (filename, e), action_name)
def _update_user_disk_usage(self):
@@ -739,7 +739,7 @@ class Cleanup(object):
dataset = Dataset(id=tup[0], object_store_id=tup[1])
try:
filename = self.object_store.get_filename(dataset)
- except (ObjectNotFound, AttributeError), e:
+ except (ObjectNotFound, AttributeError) as e:
log.error('Unable to get Dataset %s filename: %s' % (tup[0], e))
continue
@@ -753,7 +753,7 @@ class Cleanup(object):
if not self.options.dry_run:
try:
os.unlink(filename)
- except Exception, e:
+ except Exception as e:
self._log('Removal of %s failed with error: %s' % (filename, e))
# extra_files_dir is optional so it's checked first
@@ -762,7 +762,7 @@ class Cleanup(object):
if not self.options.dry_run:
try:
shutil.rmtree(extra_files_dir)
- except Exception, e:
+ except Exception as e:
self._log('Removal of %s failed with error: %s' % (extra_files_dir, e))
self._close_logfile()
diff --git a/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py b/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py
index 4a1026a3dcc..21372cbd5a9 100755
--- a/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py
+++ b/scripts/cleanup_datasets/remove_renamed_datasets_from_disk.py
@@ -40,7 +40,7 @@ def main():
os.unlink( line )
print >> out, line
removed_files += 1
- except Exception, exc:
+ except Exception as exc:
print >> out, "# Error, exception " + str( exc ) + " caught attempting to remove " + line
print >> out, "# Removed " + str( removed_files ) + " files"
diff --git a/scripts/cleanup_datasets/rename_purged_datasets.py b/scripts/cleanup_datasets/rename_purged_datasets.py
index 6189b7fdf11..eae995bd680 100755
--- a/scripts/cleanup_datasets/rename_purged_datasets.py
+++ b/scripts/cleanup_datasets/rename_purged_datasets.py
@@ -42,7 +42,7 @@ def main():
os.rename( line, purged_filename )
print >> out, purged_filename
renamed_files += 1
- except Exception, exc:
+ except Exception as exc:
print >> out, "# Error, exception " + str( exc ) + " caught attempting to rename " + purged_filename
print >> out, "# Renamed " + str( renamed_files ) + " files"
diff --git a/scripts/data_libraries/build_whoosh_index.py b/scripts/data_libraries/build_whoosh_index.py
index 8ba2cca6be0..ba80fdee813 100644
--- a/scripts/data_libraries/build_whoosh_index.py
+++ b/scripts/data_libraries/build_whoosh_index.py
@@ -22,7 +22,7 @@ try:
schema = Schema( id=STORED, name=TEXT, info=TEXT, dbkey=TEXT, message=TEXT )
import galaxy.model.mapping
from galaxy import config, model
-except ImportError, e:
+except ImportError:
whoosh_search_enabled = False
schema = None
diff --git a/scripts/drmaa_external_killer.py b/scripts/drmaa_external_killer.py
index 6c74a0cfaab..9aff1d60d70 100755
--- a/scripts/drmaa_external_killer.py
+++ b/scripts/drmaa_external_killer.py
@@ -27,7 +27,7 @@ def set_user(uid):
gid = pwd.getpwuid(uid).pw_gid
os.setgid(gid)
os.setuid(uid)
- except OSError, e:
+ except OSError as e:
if e.errno == errno.EPERM:
sys.stderr.write("error: setuid(%d) failed: permission denied. Did you setup 'sudo' correctly for this script?\n" % uid )
exit(1)
diff --git a/scripts/drmaa_external_runner.py b/scripts/drmaa_external_runner.py
index a1474feb418..1311348fbad 100755
--- a/scripts/drmaa_external_runner.py
+++ b/scripts/drmaa_external_runner.py
@@ -96,7 +96,7 @@ def set_user(uid, assign_all_groups):
os.setgroups(groups)
os.setuid(uid)
- except OSError, e:
+ except OSError as e:
if e.errno == errno.EPERM:
sys.stderr.write( "error: setuid(%d) failed: permission denied. Did you setup 'sudo' correctly for this script?\n" % uid )
exit(1)
diff --git a/scripts/extract_dataset_part.py b/scripts/extract_dataset_part.py
index 6cf43a33999..470205b60aa 100644
--- a/scripts/extract_dataset_part.py
+++ b/scripts/extract_dataset_part.py
@@ -40,7 +40,7 @@ def __main__():
if not cls.process_split_file(data):
sys.stderr.write('Writing split file failed\n')
sys.exit(1)
- except Exception, e:
+ except Exception as e:
sys.stderr.write(str(e))
sys.exit(1)
diff --git a/scripts/microbes/harvest_bacteria.py b/scripts/microbes/harvest_bacteria.py
index 09fd6f6a17c..5566f25c160 100644
--- a/scripts/microbes/harvest_bacteria.py
+++ b/scripts/microbes/harvest_bacteria.py
@@ -170,7 +170,7 @@ def process_Genbank( filename, org_num, refseq ):
def process_Glimmer3( filename, org_num, refseq ):
try:
glimmer3_bed = get_bed_from_glimmer3( filename, refseq )
- except Exception, e:
+ except Exception as e:
print "Converting Glimmer3 to bed FAILED! For chrom:", refseq, "file:", filename, e
glimmer3_bed = []
glimmer3_bed_file = open( os.path.join( os.path.split( filename )[0], "%s.Glimmer3.bed" % refseq ), 'wb+' )
@@ -181,7 +181,7 @@ def process_Glimmer3( filename, org_num, refseq ):
def process_GeneMarkHMM( filename, org_num, refseq ):
try:
geneMarkHMM_bed = get_bed_from_GeneMarkHMM( filename, refseq )
- except Exception, e:
+ except Exception as e:
print "Converting GeneMarkHMM to bed FAILED! For chrom:", refseq, "file:", filename, e
geneMarkHMM_bed = []
geneMarkHMM_bed_bed_file = open( os.path.join( os.path.split( filename )[0], "%s.GeneMarkHMM.bed" % refseq ), 'wb+' )
@@ -192,7 +192,7 @@ def process_GeneMarkHMM( filename, org_num, refseq ):
def process_GeneMark( filename, org_num, refseq ):
try:
geneMark_bed = get_bed_from_GeneMark( filename, refseq )
- except Exception, e:
+ except Exception as e:
print "Converting GeneMark to bed FAILED! For chrom:", refseq, "file:", filename, e
geneMark_bed = []
geneMark_bed_bed_file = open( os.path.join( os.path.split( filename )[0], "%s.GeneMark.bed" % refseq ), 'wb+' )
diff --git a/scripts/others/incorrect_gops_jobs.py b/scripts/others/incorrect_gops_jobs.py
index a96d136ec28..fc22ac5e71a 100755
--- a/scripts/others/incorrect_gops_jobs.py
+++ b/scripts/others/incorrect_gops_jobs.py
@@ -87,7 +87,7 @@ def main():
jobs[ job.id ][ 'history_name' ] = history.name
jobs[ job.id ][ 'history_update_time' ] = history.update_time
jobs[ job.id ][ 'user_email' ] = user.email
- except Exception, e:
+ except Exception as e:
print "# caught exception: %s" % str( e )
print "\n\n# Number of incorrect Jobs: %d\n\n" % ( len( jobs ) )
diff --git a/scripts/others/incorrect_gops_join_jobs.py b/scripts/others/incorrect_gops_join_jobs.py
index bcefdb6f4c7..e8de640614d 100644
--- a/scripts/others/incorrect_gops_join_jobs.py
+++ b/scripts/others/incorrect_gops_join_jobs.py
@@ -77,7 +77,7 @@ def main():
jobs[ job.id ][ 'history_name' ] = history.name
jobs[ job.id ][ 'history_update_time' ] = history.update_time
jobs[ job.id ][ 'user_email' ] = user.email
- except Exception, e:
+ except Exception as e:
print "# caught exception: %s" % str( e )
print "\n\n# Number of incorrect Jobs: %d\n\n" % ( len( jobs ) )
diff --git a/scripts/tool_shed/api/common.py b/scripts/tool_shed/api/common.py
index 1b249149eff..21d73f81cbd 100644
--- a/scripts/tool_shed/api/common.py
+++ b/scripts/tool_shed/api/common.py
@@ -60,7 +60,7 @@ def delete( api_key, url, data, return_formatted=True ):
opener, request = build_request_with_data( url, data, api_key, 'DELETE' )
delete_request = opener.open( request )
response = json.loads( delete_request.read() )
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
if return_formatted:
print e
print e.read( 1024 )
@@ -79,7 +79,7 @@ def display( url, api_key=None, return_formatted=True ):
"""Sends an API GET request and acts as a generic formatter for the JSON response."""
try:
r = get( url, api_key=api_key )
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
print e
# Only return the first 1K of errors.
print e.read( 1024 )
@@ -193,7 +193,7 @@ def json_from_url( url ):
url_contents = url_handle.read()
try:
parsed_json = json.loads( url_contents )
- except Exception, e:
+ except Exception as e:
error_message = str( url_contents )
print 'Error parsing JSON data in json_from_url(): ', str( e )
return None, error_message
@@ -219,7 +219,7 @@ def post( url, data, api_key=None ):
opener, request = build_request_with_data( url, data, api_key, 'POST' )
post_request = opener.open( request )
return json.loads( post_request.read() )
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
return dict( status='error', message=str( e.read( 1024 ) ) )
@@ -229,7 +229,7 @@ def put( url, data, api_key=None ):
opener, request = build_request_with_data( url, data, api_key, 'PUT' )
put_request = opener.open( request )
return json.loads( put_request.read() )
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
return dict( status='error', message=str( e.read( 1024 ) ) )
@@ -240,7 +240,7 @@ def submit( url, data, api_key=None, return_formatted=True ):
"""
try:
response = post( url, data, api_key=api_key )
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
if return_formatted:
print e
print e.read( 1024 )
@@ -277,7 +277,7 @@ def update( api_key, url, data, return_formatted=True ):
"""
try:
response = put( url, data, api_key=api_key )
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
if return_formatted:
print e
print e.read( 1024 )
diff --git a/scripts/tool_shed/api/create_categories.py b/scripts/tool_shed/api/create_categories.py
index 871cb69e3a8..f2cf778b8b5 100644
--- a/scripts/tool_shed/api/create_categories.py
+++ b/scripts/tool_shed/api/create_categories.py
@@ -40,7 +40,7 @@ def main( options ):
url = '%s/api/categories' % to_tool_shed
try:
response = submit( url, data, api_key )
- except Exception, e:
+ except Exception as e:
response = str( e )
print "Error attempting to create category using URL: ", url, " exception: ", str( e )
create_response_dict = dict( response=response )
diff --git a/scripts/tool_shed/api/create_users.py b/scripts/tool_shed/api/create_users.py
index 6bb8b206a34..f2d45317751 100644
--- a/scripts/tool_shed/api/create_users.py
+++ b/scripts/tool_shed/api/create_users.py
@@ -43,7 +43,7 @@ def main( options ):
url = '%s/api/users' % to_tool_shed
try:
response = submit( url, data, api_key )
- except Exception, e:
+ except Exception as e:
response = str( e )
print "Error attempting to create user using URL: ", url, " exception: ", str( e )
create_response_dict = dict( response=response )
diff --git a/scripts/tool_shed/api/import_capsule.py b/scripts/tool_shed/api/import_capsule.py
index 5c41a336fab..97fef3fa617 100644
--- a/scripts/tool_shed/api/import_capsule.py
+++ b/scripts/tool_shed/api/import_capsule.py
@@ -32,7 +32,7 @@ def main( options ):
url = '%s/api/repositories/new/import_capsule' % base_tool_shed_url
try:
submit( url, data, api_key )
- except Exception, e:
+ except Exception as e:
log.exception( str( e ) )
sys.exit( 1 )
diff --git a/scripts/tool_shed/api/reset_metadata_on_repositories.py b/scripts/tool_shed/api/reset_metadata_on_repositories.py
index 824d3d67d97..2098977ed3d 100644
--- a/scripts/tool_shed/api/reset_metadata_on_repositories.py
+++ b/scripts/tool_shed/api/reset_metadata_on_repositories.py
@@ -64,7 +64,7 @@ def main( options ):
url = '%s/api/repositories/reset_metadata_on_repository' % base_tool_shed_url
try:
submit( url, data, options.api )
- except Exception, e:
+ except Exception as e:
log.exception( ">>>>>>>>>>>>>>>Blew up on data: %s, exception: %s" % ( str( data ), str( e ) ) )
# An nginx timeout undoubtedly occurred.
sys.exit( 1 )
@@ -74,7 +74,7 @@ def main( options ):
url = '%s/api/repositories/reset_metadata_on_repositories' % base_tool_shed_url
try:
submit( url, data, options.api )
- except Exception, e:
+ except Exception as e:
log.exception( str( e ) )
# An nginx timeout undoubtedly occurred.
sys.exit( 1 )
diff --git a/scripts/tool_shed/check_download_urls.py b/scripts/tool_shed/check_download_urls.py
index 4698eb404c3..de8409aeee5 100644
--- a/scripts/tool_shed/check_download_urls.py
+++ b/scripts/tool_shed/check_download_urls.py
@@ -29,9 +29,9 @@ def main():
url = element.text.strip()
try:
urllib2.urlopen( urllib2.Request( url ) )
- except Exception, e:
+ except Exception as e:
print "Bad URL '%s' in file '%s': %s" % ( url, path, e )
- except Exception, e:
+ except Exception as e:
print "Unable to check XML file '%s': %s" % ( path, e )
if __name__ == "__main__":
diff --git a/scripts/tool_shed/deprecate_repositories_without_metadata.py b/scripts/tool_shed/deprecate_repositories_without_metadata.py
index 164db8f197c..e0caea75238 100644
--- a/scripts/tool_shed/deprecate_repositories_without_metadata.py
+++ b/scripts/tool_shed/deprecate_repositories_without_metadata.py
@@ -91,7 +91,7 @@ def send_mail_to_owner( app, name, owner, email, repositories_deprecated, days=1
galaxy_send_mail( from_address, repository.user.email, subject, body, app.config )
print "# An email has been sent to %s, the owner of %s." % ( repository.user.username, ', '.join( [ repository.name for repository in repositories_deprecated ] ) )
return True
- except Exception, e:
+ except Exception as e:
print "# An error occurred attempting to send email: %s" % str( e )
return False
diff --git a/scripts/tools/maf/check_loc_file.py b/scripts/tools/maf/check_loc_file.py
index efd95320ce6..3e61dc713e9 100644
--- a/scripts/tools/maf/check_loc_file.py
+++ b/scripts/tools/maf/check_loc_file.py
@@ -48,7 +48,7 @@ def __main__():
for spec in species_found_in_maf:
if spec not in species_exist:
print "Line %i, %s contains %s, but is not listed in loc file." % ( i, uid, spec )
- except Exception, e:
+ except Exception as e:
print "Line %i is invalid: %s" % ( i, e )
if __name__ == "__main__":
diff --git a/scripts/transfer.py b/scripts/transfer.py
index 38215edb363..84f0c446fed 100644
--- a/scripts/transfer.py
+++ b/scripts/transfer.py
@@ -121,7 +121,7 @@ class ListenerServer( SocketServer.ThreadingTCPServer ):
SocketServer.ThreadingTCPServer.__init__( self, ( 'localhost', random_port ), RequestHandlerClass )
log.info( 'Listening on port %s' % random_port )
break
- except Exception, e:
+ except Exception as e:
log.warning( 'Tried binding port %s: %s' % ( random_port, str( e ) ) )
transfer_job.socket = random_port
app.sa_session.add( transfer_job )
@@ -162,7 +162,7 @@ def transfer( app, transfer_job_id ):
port_range = app.config.get( 'app:main', 'transfer_worker_port_range' )
try:
port_range = [ int( p ) for p in port_range.split( '-' ) ]
- except Exception, e:
+ except Exception as e:
log.error( 'Invalid port range set in transfer_worker_port_range: %s: %s' % ( port_range, str( e ) ) )
return False
protocol = transfer_job.params[ 'protocol' ]
@@ -217,7 +217,7 @@ def http_transfer( transfer_job ):
url = transfer_job.params['url']
try:
f = urllib2.urlopen( url )
- except urllib2.URLError, e:
+ except urllib2.URLError as e:
yield dict( state=transfer_job.states.ERROR, info='Unable to open URL: %s' % str( e ) )
return
size = f.info().getheader( 'Content-Length' )
@@ -230,7 +230,7 @@ def http_transfer( transfer_job ):
last = 0
try:
fh, fn = tempfile.mkstemp()
- except Exception, e:
+ except Exception as e:
yield dict( state=transfer_job.states.ERROR, info='Unable to create temporary file for transfer: %s' % str( e ) )
return
log.debug( 'Writing %s to %s, size is %s' % ( url, fn, size or 'unknown' ) )
@@ -252,7 +252,7 @@ def http_transfer( transfer_job ):
time.sleep( 1 )
os.close( fh )
yield dict( state=transfer_job.states.DONE, path=fn )
- except Exception, e:
+ except Exception as e:
yield dict( state=transfer_job.states.ERROR, info='Error during file transfer: %s' % str( e ) )
return
return
@@ -270,7 +270,7 @@ def scp_transfer( transfer_job ):
return dict( state=transfer_job.states.ERROR, info=PEXPECT_IMPORT_MESSAGE )
try:
fh, fn = tempfile.mkstemp()
- except Exception, e:
+ except Exception as e:
return dict( state=transfer_job.states.ERROR, info='Unable to create temporary file for transfer: %s' % str( e ) )
try:
# TODO: add the ability to determine progress of the copy here like we do in the http_transfer above.
@@ -282,7 +282,7 @@ def scp_transfer( transfer_job ):
pexpect.TIMEOUT: print_ticks },
timeout=10 )
return dict( state=transfer_job.states.DONE, path=fn )
- except Exception, e:
+ except Exception as e:
return dict( state=transfer_job.states.ERROR, info='Error during file transfer: %s' % str( e ) )
if __name__ == '__main__':
diff --git a/test/base/asserts/__init__.py b/test/base/asserts/__init__.py
index 04a18e08733..da33da35eeb 100644
--- a/test/base/asserts/__init__.py
+++ b/test/base/asserts/__init__.py
@@ -19,7 +19,7 @@ for assertion_module_name in assertion_module_names:
__import__(full_assertion_module_name)
assertion_module = sys.modules[full_assertion_module_name]
assertion_modules.append(assertion_module)
- except Exception, e:
+ except Exception as e:
log.exception('Failed to load assertion module: %s %s' % (assertion_module_name, str(e)))
diff --git a/test/base/asserts/xml.py b/test/base/asserts/xml.py
index a141333e0ef..d9af28512b1 100644
--- a/test/base/asserts/xml.py
+++ b/test/base/asserts/xml.py
@@ -24,7 +24,7 @@ def assert_is_valid_xml(output):
is valid XML."""
try:
to_xml(output)
- except Exception, e:
+ except Exception as e:
# TODO: Narrow caught exception to just parsing failure
raise AssertionError("Expected valid XML, but could not parse output. %s" % str(e))
diff --git a/test/base/driver_util.py b/test/base/driver_util.py
index aafd9d289df..231a7201efa 100644
--- a/test/base/driver_util.py
+++ b/test/base/driver_util.py
@@ -384,7 +384,7 @@ def serve_webapp(webapp, port=None, host=None):
port = str( random.randint( 8000, 10000 ) )
server = httpserver.serve( webapp, host=host, port=port, start_loop=False )
break
- except socket.error, e:
+ except socket.error as e:
if e[0] == 98:
continue
raise
diff --git a/test/base/twilltestcase.py b/test/base/twilltestcase.py
index b39ea5472bb..df34d958336 100644
--- a/test/base/twilltestcase.py
+++ b/test/base/twilltestcase.py
@@ -334,7 +334,7 @@ class TwillTestCase( unittest.TestCase ):
assert os.path.exists( downloaded_file )
try:
self.files_diff( orig_file, downloaded_file )
- except AssertionError, err:
+ except AssertionError as err:
errmsg = 'Library item %s different than expected, difference:\n' % ldda.name
errmsg += str( err )
errmsg += 'Unpacked archive remains in: %s\n' % tmpd
@@ -421,7 +421,7 @@ class TwillTestCase( unittest.TestCase ):
json_data = self.get_history_from_api( show_deleted=show_deleted, show_details=True )
check_result = check_fn( json_data )
assert check_result, 'failed check_fn: %s (got %s)' % ( check_fn.func_name, str( check_result ) )
- except Exception, e:
+ except Exception as e:
log.exception( e )
log.debug( 'json_data: %s', ( '\n' + pprint.pformat( json_data ) if json_data else '(no match)' ) )
fname = self.write_temp_file( tc.browser.get_html() )
@@ -1935,7 +1935,7 @@ class TwillTestCase( unittest.TestCase ):
try:
checkbox = control.get()
checkbox.selected = is_checked( control_value )
- except Exception, e1:
+ except Exception as e1:
print "Attempting to set checkbox selected value threw exception: ", e1
# if there's more than one checkbox, probably should use the behaviour for
# ClientForm.ListControl ( see twill code ), but this works for now...
@@ -1972,7 +1972,7 @@ class TwillTestCase( unittest.TestCase ):
log.debug( formcontrol )
log.exception( "Attempting to set control '%s' to value '%s' (also tried '%s') threw exception.", control.name, elem, elem_name )
pass
- except Exception, exc:
+ except Exception as exc:
for formcontrol in formcontrols:
log.debug( formcontrol )
errmsg = "Attempting to set field '%s' to value '%s' in form '%s' threw exception: %s\n" % ( control_name, str( control_value ), f.name, str( exc ) )
@@ -2131,7 +2131,7 @@ class TwillTestCase( unittest.TestCase ):
tc.config("readonly_controls_writeable", 1)
tc.fv( "tool_form", "NAME", name )
tc.submit( "runtool_btn" )
- except AssertionError, err:
+ except AssertionError as err:
errmsg = "Uploading file resulted in the following exception. Make sure the file (%s) exists. " % filename
errmsg += str( err )
raise AssertionError( errmsg )
@@ -2155,7 +2155,7 @@ class TwillTestCase( unittest.TestCase ):
tc.fv( "tool_form", "dbkey", dbkey )
tc.fv( "tool_form", "url_paste", url_paste )
tc.submit( "runtool_btn" )
- except Exception, e:
+ except Exception as e:
errmsg = "Problem executing upload utility using url_paste: %s" % str( e )
raise AssertionError( errmsg )
# Make sure every history item has a valid hid
@@ -2214,7 +2214,7 @@ class TwillTestCase( unittest.TestCase ):
raise Exception( 'Files %s=%db but %s=%db - compare (delta=%s) failed' % (temp_name, s1, local_name, s2, delta) )
else:
raise Exception( 'Unimplemented Compare type: %s' % compare )
- except AssertionError, err:
+ except AssertionError as err:
errmsg = 'Composite file (%s) of History item %s different than expected, difference (using %s):\n' % ( base_name, hda_id, compare )
errmsg += str( err )
raise AssertionError( errmsg )
@@ -2273,7 +2273,7 @@ class TwillTestCase( unittest.TestCase ):
if attributes is not None and attributes.get( "assert_list", None ) is not None:
try:
verify_assertions(data, attributes["assert_list"])
- except AssertionError, err:
+ except AssertionError as err:
errmsg = 'History item %s different than expected\n' % (hid)
errmsg += str( err )
raise AssertionError( errmsg )
@@ -2281,7 +2281,7 @@ class TwillTestCase( unittest.TestCase ):
md5 = attributes.get("md5")
try:
self._verify_md5(data, md5)
- except AssertionError, err:
+ except AssertionError as err:
errmsg = 'History item %s different than expected\n' % (hid)
errmsg += str( err )
raise AssertionError( errmsg )
@@ -2296,7 +2296,7 @@ class TwillTestCase( unittest.TestCase ):
log.debug( 'keepoutdir: %s, ofn: %s', self.keepOutdir, ofn )
try:
shutil.copy( temp_name, ofn )
- except Exception, exc:
+ except Exception as exc:
error_log_msg = ( 'TwillTestCase could not save output file %s to %s: ' % ( temp_name, ofn ) )
error_log_msg += str( exc )
log.error( error_log_msg, exc_info=True )
@@ -2328,7 +2328,7 @@ class TwillTestCase( unittest.TestCase ):
raise Exception( 'Unimplemented Compare type: %s' % compare )
if extra_files:
self.verify_extra_files_content( extra_files, hda_id, shed_tool_id=shed_tool_id, dataset_fetcher=dataset_fetcher )
- except AssertionError, err:
+ except AssertionError as err:
errmsg = 'History item %s different than expected, difference (using %s):\n' % ( hid, compare )
errmsg += "( %s v. %s )\n" % ( local_name, temp_name )
errmsg += str( err )
diff --git a/test/casperjs/casperjs_runner.py b/test/casperjs/casperjs_runner.py
index 82db1838aa7..1b643cd6f73 100644
--- a/test/casperjs/casperjs_runner.py
+++ b/test/casperjs/casperjs_runner.py
@@ -54,7 +54,7 @@ if minor < 6:
# if nose is installed do a skip test
from nose.plugins.skip import SkipTest
raise SkipTest( msg )
- except ImportError, i_err:
+ except ImportError as i_err:
raise AssertionError( msg )
# --------------------------------------------------------------------
@@ -145,7 +145,7 @@ class CasperJSTestCase( unittest.TestCase ):
# couldn't find the headless browser,
# provide information (as it won't be included by default with galaxy)
- except OSError, os_err:
+ except OSError as os_err:
if os_err.errno == errno.ENOENT:
log.error( 'No path to headless browser executable: %s\n' +
'These tests were designed to use the following headless browser:\n%s',
@@ -208,7 +208,7 @@ class CasperJSTestCase( unittest.TestCase ):
self.browser_backtrace_to_string( last_error['backtrace'] ) ) )
# if we couldn't parse json from what's returned on the error, dump stdout
- except ValueError, val_err:
+ except ValueError as val_err:
if str( val_err ) == 'No JSON object could be decoded':
log.debug( '(error parsing returned JSON from casperjs, dumping stdout...)\n:%s', stdout_output )
return HeadlessJSJavascriptError( 'see log for details' )
@@ -216,7 +216,7 @@ class CasperJSTestCase( unittest.TestCase ):
raise
# otherwise, raise a vanilla exc
- except Exception, exc:
+ except Exception as exc:
log.debug( '(failed to parse error returned from %s: %s)', _PATH_TO_HEADLESS, str( exc ) )
return HeadlessJSJavascriptError(
"ERROR in headless browser script %s" % ( script_path ) )
diff --git a/test/casperjs/server_env.py b/test/casperjs/server_env.py
index 5b779cc9675..739b89f9f17 100644
--- a/test/casperjs/server_env.py
+++ b/test/casperjs/server_env.py
@@ -104,7 +104,7 @@ class TestEnvironment( object ):
text = f.read()
f.close()
shed_tools_dict = loads( text )
- except Exception, exc:
+ except Exception as exc:
log.error( 'Error reading tool shed test file "%s": %s', self.tool_shed_test_file, exc, exc_info=True )
return shed_tools_dict
@@ -116,7 +116,7 @@ class TestEnvironment( object ):
try:
if not os.path.exists( self.saved_output_dir ):
os.makedirs( self.saved_output_dir )
- except Exception, exc:
+ except Exception as exc:
log.error( 'unable to create saved files directory "%s": %s',
self.saved_output_dir, exc, exc_info=True )
self.saved_output_dir = None
@@ -128,7 +128,7 @@ class TestEnvironment( object ):
if self.debug_these_tests:
try:
debug_list = self.debug_these_tests.split( delim )
- except Exception, exc:
+ except Exception as exc:
log.error( 'unable to parse debug_these_tests "%s": %s',
self.debug_these_tests, exc, exc_info=True )
self.debug_these_tests = debug_list
diff --git a/test/functional/test_data_managers.py b/test/functional/test_data_managers.py
index 332fd7feae0..2843ad070c3 100644
--- a/test/functional/test_data_managers.py
+++ b/test/functional/test_data_managers.py
@@ -73,7 +73,7 @@ def build_tests( tmp_dir=None, testing_shed_tools=False, master_api_key=None, us
new_filename = tempfile.NamedTemporaryFile( prefix=os.path.basename( filename ), dir=tmp_dir ).name
try:
shutil.copy( filename, new_filename )
- except IOError, e:
+ except IOError as e:
log.warning( "Failed to copy '%s' to '%s', will create empty file at '%s': %s", filename, new_filename, new_filename, e )
open( new_filename, 'wb' ).close()
if 'filename' in value:
diff --git a/test/functional/test_toolbox.py b/test/functional/test_toolbox.py
index 4b50e2f0300..18c3bf578a4 100644
--- a/test/functional/test_toolbox.py
+++ b/test/functional/test_toolbox.py
@@ -180,7 +180,7 @@ class ToolTestCase( TwillTestCase ):
try:
data = job_stdio[what]
verify_assertions( data, getattr( testdef, what ) )
- except AssertionError, err:
+ except AssertionError as err:
errmsg = '%s different than expected\n' % description
errmsg += str( err )
register_exception( AssertionError( errmsg ) )
diff --git a/test/shed_functional/base/twilltestcase.py b/test/shed_functional/base/twilltestcase.py
index b4a5cc9e114..e03e252a958 100644
--- a/test/shed_functional/base/twilltestcase.py
+++ b/test/shed_functional/base/twilltestcase.py
@@ -1320,7 +1320,7 @@ class ShedTwillTestCase( TwillTestCase ):
# try:
# self.check_for_strings( strings_displayed, strings_not_displayed )
# break
- # except Exception, e:
+ # except Exception as e:
# if i == 4:
# raise e
# else:
diff --git a/test/unit/tools/test_execution.py b/test/unit/tools/test_execution.py
index dea955f6a3c..de066083cf9 100644
--- a/test/unit/tools/test_execution.py
+++ b/test/unit/tools/test_execution.py
@@ -60,7 +60,7 @@ class ToolExecutionTestCase( TestCase, tools_support.UsesApp, tools_support.Uses
self.tool_action.raise_exception( )
try:
self.__handle_with_incoming( param1="moo" )
- except Exception, e:
+ except Exception as e:
assert 'Error executing tool' in str( e )
def test_execute_errors( self ):
@@ -68,7 +68,7 @@ class ToolExecutionTestCase( TestCase, tools_support.UsesApp, tools_support.Uses
self.tool_action.return_error( )
try:
self.__handle_with_incoming( param1="moo" )
- except Exception, e:
+ except Exception as e:
assert 'Test Error Message' in str( e )
def test_redirect( self ):
@@ -91,7 +91,7 @@ class ToolExecutionTestCase( TestCase, tools_support.UsesApp, tools_support.Uses
self._init_tool( tools_support.SIMPLE_TOOL_CONTENTS )
try:
self.__handle_with_incoming( param1="moo", rerun_remap_job_id='123' )
- except Exception, e:
+ except Exception as e:
assert 'invalid job' in str( e )
def test_data_param_execute( self ):
diff --git a/test/unit/tools/test_select_parameters.py b/test/unit/tools/test_select_parameters.py
index 226cd088a63..7eca591a0fa 100644
--- a/test/unit/tools/test_select_parameters.py
+++ b/test/unit/tools/test_select_parameters.py
@@ -11,7 +11,7 @@ class SelectToolParameterTestCase( BaseParameterTestCase ):
self.options_xml = ''''''
try:
self.param.from_json("42", self.trans, { "input_bam": model.HistoryDatasetAssociation() })
- except ValueError, err:
+ except ValueError as err:
assert str(err) == "An invalid option was selected for my_name, '42', please verify."
return
assert False
@@ -20,7 +20,7 @@ class SelectToolParameterTestCase( BaseParameterTestCase ):
self.options_xml = ''''''
try:
self.param.from_json("42", self.trans)
- except AssertionError, err:
+ except AssertionError as err:
assert str(err) == "Required dependency 'input_bam' not found in incoming values"
return
assert False
@@ -34,7 +34,7 @@ class SelectToolParameterTestCase( BaseParameterTestCase ):
self.options_xml = ''''''
try:
self.param.from_json( model.HistoryDatasetAssociation(), self.trans, { "input_bam": basic.RuntimeValue() } )
- except ValueError, err:
+ except ValueError as err:
assert str(err) == "Parameter my_name requires a value, but has no legal values defined."
return
assert False
diff --git a/test/unit/visualizations/plugins/test_VisualizationPlugin.py b/test/unit/visualizations/plugins/test_VisualizationPlugin.py
index c696f15ec6e..5cf2facce1e 100644
--- a/test/unit/visualizations/plugins/test_VisualizationPlugin.py
+++ b/test/unit/visualizations/plugins/test_VisualizationPlugin.py
@@ -165,7 +165,7 @@ class VisualizationsPlugin_TestCase( test_utils.unittest.TestCase ):
for var in should_have:
try:
var = str( var )
- except NameError, name_err:
+ except NameError as name_err:
found_all = False
break
%>
diff --git a/tools/data_source/data_source.py b/tools/data_source/data_source.py
index 2d3dbcb9e5c..319c6bf11c2 100644
--- a/tools/data_source/data_source.py
+++ b/tools/data_source/data_source.py
@@ -88,7 +88,7 @@ def __main__():
page = urllib.urlopen( cur_URL )
elif URL_method == 'post':
page = urllib.urlopen( cur_URL, urllib.urlencode( params ) )
- except Exception, e:
+ except Exception as e:
stop_err( 'The remote data source application may be off line, please try again later. Error: %s' % str( e ) )
if max_file_size:
file_size = int( page.info().get( 'Content-Length', 0 ) )
@@ -97,14 +97,14 @@ def __main__():
# do sniff stream for multi_byte
try:
cur_filename, is_multi_byte = sniff.stream_to_open_named_file( page, os.open( cur_filename, os.O_WRONLY | os.O_CREAT ), cur_filename, source_encoding=get_charset_from_http_headers( page.headers ) )
- except Exception, e:
+ except Exception as e:
stop_err( 'Unable to fetch %s:\n%s' % ( cur_URL, e ) )
# here import checks that upload tool performs
if enhanced_handling:
try:
ext = sniff.handle_uploaded_dataset_file( filename, datatypes_registry, ext=data_dict[ 'ext' ], is_multi_byte=is_multi_byte )
- except Exception, e:
+ except Exception as e:
stop_err( str( e ) )
info = dict( type='dataset',
dataset_id=data_dict[ 'dataset_id' ],
diff --git a/tools/data_source/fetch.py b/tools/data_source/fetch.py
index 12f7140a665..2b8de91e268 100644
--- a/tools/data_source/fetch.py
+++ b/tools/data_source/fetch.py
@@ -20,6 +20,6 @@ try:
if not data:
break
out.write(data)
-except Exception, e:
+except Exception as e:
print 'Error getting the data -> %s' % e
out.close()
diff --git a/tools/data_source/hbvar_filter.py b/tools/data_source/hbvar_filter.py
index c7a6ac0c2d9..688c69f59c0 100644
--- a/tools/data_source/hbvar_filter.py
+++ b/tools/data_source/hbvar_filter.py
@@ -31,7 +31,7 @@ def exec_after_process(app, inp_data, out_data, param_dict, tool=None, stdout=No
try:
page = urllib.urlopen(URL)
- except Exception, exc:
+ except Exception as exc:
raise Exception('Problems connecting to %s (%s)' % (URL, exc) )
name, data = out_data.items()[0]
diff --git a/tools/data_source/upload.py b/tools/data_source/upload.py
index 008b2da0ee2..0450538f9fc 100644
--- a/tools/data_source/upload.py
+++ b/tools/data_source/upload.py
@@ -96,7 +96,7 @@ def add_file( dataset, registry, json_file, output_path ):
try:
page = urllib.urlopen( dataset.path ) # page will be .close()ed by sniff methods
temp_name, dataset.is_multi_byte = sniff.stream_to_file( page, prefix='url_paste', source_encoding=util.get_charset_from_http_headers( page.headers ) )
- except Exception, e:
+ except Exception as e:
file_err( 'Unable to fetch %s\n%s' % ( dataset.path, str( e ) ), dataset, json_file )
return
dataset.path = temp_name
@@ -111,7 +111,7 @@ def add_file( dataset, registry, json_file, output_path ):
# Already set is_multi_byte above if type == 'url'
try:
dataset.is_multi_byte = multi_byte.is_multi_byte( codecs.open( dataset.path, 'r', 'utf-8' ).read( 100 ) )
- except UnicodeDecodeError, e:
+ except UnicodeDecodeError as e:
dataset.is_multi_byte = False
# Is dataset an image?
image = check_image( dataset.path )
@@ -364,7 +364,7 @@ def add_composite_file( dataset, json_file, output_path, files_path ):
if isurl:
try:
temp_name, dataset.is_multi_byte = sniff.stream_to_file( urllib.urlopen( dp ), prefix='url_paste' )
- except Exception, e:
+ except Exception as e:
file_err( 'Unable to fetch %s\n%s' % ( dp, str( e ) ), dataset, json_file )
return
dataset.path = temp_name
diff --git a/tools/evolution/add_scores.py b/tools/evolution/add_scores.py
index 212d5fcb7d3..0763648e000 100755
--- a/tools/evolution/add_scores.py
+++ b/tools/evolution/add_scores.py
@@ -16,7 +16,7 @@ def open_or_die( filename, mode='r', message=None ):
message = 'Error opening %s' % filename
try:
fh = open( filename, mode )
- except IOError, err:
+ except IOError as err:
die( '%s: %s' % ( message, err.strerror ) )
return fh
@@ -51,7 +51,7 @@ class LocationFile( object ):
die( 'Location file %s line %d: duplicate key "%s"' % ( self.filename, line_number, key ) )
else:
self._map[key] = elems
- except IOError, err:
+ except IOError as err:
die( 'Error opening location file %s: %s' % ( self.filename, err.strerror ) )
def get_values( self, key ):
diff --git a/tools/extract/extract_genomic_dna.py b/tools/extract/extract_genomic_dna.py
index dcd49af5df0..359d530209d 100755
--- a/tools/extract/extract_genomic_dna.py
+++ b/tools/extract/extract_genomic_dna.py
@@ -119,7 +119,7 @@ def __main__():
# Error checking.
if returncode != 0:
raise Exception(stderr)
- except Exception, e:
+ except Exception as e:
stop_err( 'Error running faToTwoBit. ' + str( e ) )
else:
seq_path = check_seq_file( dbkey, GALAXY_DATA_INDEX_DIR )
@@ -210,7 +210,7 @@ def __main__():
nibs[chrom] = nib = bx.seq.nib.NibFile( open( "%s/%s.nib" % ( seq_path, chrom ) ) )
try:
sequence = nib.get( start, end - start )
- except Exception, e:
+ except Exception as e:
warning = "Unable to fetch the sequence from '%d' to '%d' for build '%s'. " % ( start, end - start, dbkey )
warnings.append( warning )
if not invalid_lines:
diff --git a/tools/extract/liftOver_wrapper.py b/tools/extract/liftOver_wrapper.py
index f321dd5a0e0..83fe6ea9110 100644
--- a/tools/extract/liftOver_wrapper.py
+++ b/tools/extract/liftOver_wrapper.py
@@ -79,7 +79,7 @@ try:
stderr = proc.stderr.read()
if returncode != 0:
raise Exception(stderr)
- except Exception, e:
+ except Exception as e:
raise Exception('Exception caught attempting conversion: ' + str( e ))
finally:
os.remove(safe_infile)
diff --git a/tools/filters/gff/gff_filter_by_attribute.py b/tools/filters/gff/gff_filter_by_attribute.py
index e8975206764..6125df5381b 100644
--- a/tools/filters/gff/gff_filter_by_attribute.py
+++ b/tools/filters/gff/gff_filter_by_attribute.py
@@ -126,7 +126,7 @@ for i, line in enumerate( open( in_fname ) ):
if %s:
lines_kept += 1
print >> out, line
- except Exception, e:
+ except Exception as e:
print e
skipped_lines += 1
if not invalid_line:
@@ -137,7 +137,7 @@ for i, line in enumerate( open( in_fname ) ):
valid_filter = True
try:
exec code
-except Exception, e:
+except Exception as e:
out.close()
if str( e ).startswith( 'invalid syntax' ):
valid_filter = False
diff --git a/tools/filters/gtf_to_bedgraph_converter.py b/tools/filters/gtf_to_bedgraph_converter.py
index abfcd1a3e03..df2dd056b19 100644
--- a/tools/filters/gtf_to_bedgraph_converter.py
+++ b/tools/filters/gtf_to_bedgraph_converter.py
@@ -62,7 +62,7 @@ def __main__():
try:
os.system(cmd)
os.remove(tmp_name1)
- except Exception, ex:
+ except Exception as ex:
sys.stderr.write( "%s\n" % ex )
sys.exit(1)
@@ -71,7 +71,7 @@ def __main__():
try:
os.system(cmd)
os.remove(tmp_name2)
- except Exception, ex:
+ except Exception as ex:
sys.stderr.write( "%s\n" % ex )
sys.exit(1)
diff --git a/tools/filters/join.py b/tools/filters/join.py
index 7177f59440e..81a8fbe59da 100644
--- a/tools/filters/join.py
+++ b/tools/filters/join.py
@@ -359,7 +359,7 @@ def main():
if options.fill_options_file is not None:
try:
fill_options = Bunch( **stringify_dictionary_keys( json.load( open( options.fill_options_file ) ) ) ) # json.load( open( options.fill_options_file ) )
- except Exception, e:
+ except Exception as e:
print "Warning: Ignoring fill options due to json error (%s)." % e
if fill_options is None:
fill_options = Bunch()
diff --git a/tools/filters/joinWrapper.py b/tools/filters/joinWrapper.py
index b08e08c9fb5..e2a9820d418 100644
--- a/tools/filters/joinWrapper.py
+++ b/tools/filters/joinWrapper.py
@@ -29,7 +29,7 @@ def main():
# Sort the two files based on specified fields
os.system("sort -t ' ' -k %d,%d -o %s %s" % (field1, field1, tmpfile1.name, infile1))
os.system("sort -t ' ' -k %d,%d -o %s %s" % (field2, field2, tmpfile2.name, infile2))
- except Exception, exc:
+ except Exception as exc:
stop_err( 'Initialization error -> %s' % str(exc) )
option = ""
@@ -69,7 +69,7 @@ def main():
try:
os.system(cmdline)
- except Exception, exj:
+ except Exception as exj:
stop_err('Error joining the two datasets -> %s' % str(exj))
if __name__ == "__main__":
diff --git a/tools/filters/lav_to_bed.py b/tools/filters/lav_to_bed.py
index 79322c116aa..0aa2689936d 100644
--- a/tools/filters/lav_to_bed.py
+++ b/tools/filters/lav_to_bed.py
@@ -15,7 +15,7 @@ def main():
lav_file = open(sys.argv[1], 'r')
bed_file1 = open(sys.argv[2], 'w')
bed_file2 = open(sys.argv[3], 'w')
- except Exception, e:
+ except Exception as e:
stop_err( str( e ) )
lavsRead = 0
diff --git a/tools/filters/sff_extract.py b/tools/filters/sff_extract.py
index 06158434f19..7711a5e7f57 100644
--- a/tools/filters/sff_extract.py
+++ b/tools/filters/sff_extract.py
@@ -859,7 +859,7 @@ def extract_reads_from_sff(config, sff_files):
qual_fh = None
try:
os.remove(config['qual_fname'])
- except :
+ except:
pass
else:
qual_fh = open(config['qual_fname'], openmode)
@@ -1100,7 +1100,7 @@ def tests_for_ssaha():
subprocess.call(["ssaha2"], stdout=fh)
fh.close()
print "ok."
- except :
+ except:
print "nope? Uh oh ...\n\n"
raise RuntimeError('Could not launch ssaha2. Have you installed it? Is it in your path?')
@@ -1325,7 +1325,7 @@ def main():
if len(args) == 0:
raise RuntimeError("No SFF file given?")
extract_reads_from_sff(config, args)
- except (OSError, IOError, RuntimeError), errval:
+ except (OSError, IOError, RuntimeError) as errval:
print errval
return 1
diff --git a/tools/filters/sorter.py b/tools/filters/sorter.py
index 9d41101397f..d9619bce5e2 100644
--- a/tools/filters/sorter.py
+++ b/tools/filters/sorter.py
@@ -47,7 +47,7 @@ def main():
os.system(grep_comments)
os.system(sort_columns)
- except Exception, ex:
+ except Exception as ex:
stop_err('Error running sorter.py\n' + str(ex))
# exit
diff --git a/tools/filters/wiggle_to_simple.py b/tools/filters/wiggle_to_simple.py
index ca18084a1ea..bfb1a6dfcc9 100755
--- a/tools/filters/wiggle_to_simple.py
+++ b/tools/filters/wiggle_to_simple.py
@@ -34,7 +34,7 @@ def main():
except UCSCLimitException:
# Wiggle data was truncated, at the very least need to warn the user.
print 'Encountered message from UCSC: "Reached output limit of 100000 data values", so be aware your data was truncated.'
- except ValueError, e:
+ except ValueError as e:
in_file.close()
out_file.close()
stop_err( str( e ) )
diff --git a/tools/genomespace/genomespace_exporter.py b/tools/genomespace/genomespace_exporter.py
index 925ccf67f3b..a146bff7eb0 100644
--- a/tools/genomespace/genomespace_exporter.py
+++ b/tools/genomespace/genomespace_exporter.py
@@ -165,7 +165,7 @@ def galaxy_code_get_genomespace_folders( genomespace_site='prod', trans=None, va
# get url to upload to
try:
cur_directory = url_opener.open( cur_directory ).read()
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
log.debug( 'GenomeSpace export tool failed reading a directory "%s": %s' % ( url, e ) )
return # bad url, go to next
cur_directory = json.loads( cur_directory )
diff --git a/tools/maf/interval_maf_to_merged_fasta.py b/tools/maf/interval_maf_to_merged_fasta.py
index 079cc443baf..d51c2572cfb 100644
--- a/tools/maf/interval_maf_to_merged_fasta.py
+++ b/tools/maf/interval_maf_to_merged_fasta.py
@@ -141,7 +141,7 @@ def __main__():
overwrite_with_gaps=overwrite_with_gaps )
primary_name = secondary_name = fields[3]
alignment_strand = fields[5]
- except Exception, e:
+ except Exception as e:
print "Error loading exon positions from input line %i: %s" % ( line_count, e )
continue
else: # Process as standard intervals
@@ -154,7 +154,7 @@ def __main__():
primary_name = "%s(%s):%s-%s" % ( line.chrom, line.strand, line.start, line.end )
secondary_name = ""
alignment_strand = line.strand
- except Exception, e:
+ except Exception as e:
print "Error loading region positions from input line %i: %s" % ( line_count, e )
continue
@@ -181,7 +181,7 @@ def __main__():
output.write( "\n" )
regions_extracted += 1
- except Exception, e:
+ except Exception as e:
print "Unexpected error from input line %i: %s" % ( line_count, e )
continue
diff --git a/tools/maf/maf_split_by_species.py b/tools/maf/maf_split_by_species.py
index 85ee936a0c6..470b356cfa2 100644
--- a/tools/maf/maf_split_by_species.py
+++ b/tools/maf/maf_split_by_species.py
@@ -13,15 +13,15 @@ from galaxy.util import string_as_bool
def __main__():
try:
maf_reader = maf.Reader( open( sys.argv[1] ) )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error opening MAF: %s" % e )
try:
out = maf.Writer( open( sys.argv[2], "w") )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error opening file for output: %s" % e )
try:
collapse_columns = string_as_bool( sys.argv[3] )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error determining collapse columns value: %s" % e )
start_count = 0
diff --git a/tools/maf/maf_thread_for_species.py b/tools/maf/maf_thread_for_species.py
index 253cb68061d..2aca2e10bfd 100644
--- a/tools/maf/maf_thread_for_species.py
+++ b/tools/maf/maf_thread_for_species.py
@@ -41,7 +41,7 @@ def main():
m.components = new_components
m.score = 0.0
maf_writer.write( m )
- except Exception, e:
+ except Exception as e:
print >> sys.stderr, "Error steping through MAF File: %s" % e
sys.exit()
maf_reader.close()
diff --git a/tools/maf/maf_to_fasta_concat.py b/tools/maf/maf_to_fasta_concat.py
index e2fec94b520..d1b52295ac0 100755
--- a/tools/maf/maf_to_fasta_concat.py
+++ b/tools/maf/maf_to_fasta_concat.py
@@ -15,15 +15,15 @@ from galaxy.tools.util import maf_utilities
def __main__():
try:
species = maf_utilities.parse_species_option( sys.argv[1] )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error determining species value: %s" % e )
try:
input_filename = sys.argv[2]
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error reading MAF filename: %s" % e )
try:
file_out = open( sys.argv[3], 'w' )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error opening file for output: %s" % e )
if species:
@@ -34,7 +34,7 @@ def __main__():
if not species:
try:
species = maf_utilities.get_species_in_maf( input_filename )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error determining species in input MAF: %s" % e )
for spec in species:
@@ -48,7 +48,7 @@ def __main__():
file_out.write( component.text )
else:
file_out.write( "-" * block.text_size )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Your MAF file appears to be malformed: %s" % e )
file_out.write( "\n" )
file_out.close()
diff --git a/tools/maf/maf_to_fasta_multiple_sets.py b/tools/maf/maf_to_fasta_multiple_sets.py
index e1a5ee6ebd4..38d6170350f 100755
--- a/tools/maf/maf_to_fasta_multiple_sets.py
+++ b/tools/maf/maf_to_fasta_multiple_sets.py
@@ -14,11 +14,11 @@ from galaxy.tools.util import maf_utilities
def __main__():
try:
maf_reader = maf.Reader( open( sys.argv[1] ) )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error opening input MAF: %s" % e )
try:
file_out = open( sys.argv[2], 'w' )
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error opening file for output: %s" % e )
try:
species = maf_utilities.parse_species_option( sys.argv[3] )
@@ -26,11 +26,11 @@ def __main__():
num_species = len( species )
else:
num_species = 0
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error determining species value: %s" % e )
try:
partial = sys.argv[4]
- except Exception, e:
+ except Exception as e:
maf_utilities.tool_fail( "Error determining keep partial value: %s" % e )
if species:
diff --git a/tools/metag_tools/shrimp_color_wrapper.py b/tools/metag_tools/shrimp_color_wrapper.py
index 1e5d2dcc561..9faa2523ff0 100644
--- a/tools/metag_tools/shrimp_color_wrapper.py
+++ b/tools/metag_tools/shrimp_color_wrapper.py
@@ -80,7 +80,7 @@ def __main__():
try:
os.system(command)
- except Exception, e:
+ except Exception as e:
stop_err(str(e))
# check SHRiMP output: count number of lines
@@ -93,7 +93,7 @@ def __main__():
try:
line.split()
num_hits += 1
- except Exception, e:
+ except Exception as e:
stop_err(str(e))
if num_hits == 0: # no hits generated
diff --git a/tools/metag_tools/shrimp_wrapper.py b/tools/metag_tools/shrimp_wrapper.py
index 0a2eed33285..1083af7cc64 100644
--- a/tools/metag_tools/shrimp_wrapper.py
+++ b/tools/metag_tools/shrimp_wrapper.py
@@ -564,7 +564,7 @@ def __main__():
try:
os.system(command)
- except Exception, e:
+ except Exception as e:
if os.path.exists(query_fasta):
os.remove(query_fasta)
if os.path.exists(query_qual):
@@ -578,7 +578,7 @@ def __main__():
try:
os.system(command_end1)
os.system(command_end2)
- except Exception, e:
+ except Exception as e:
if os.path.exists(query_fasta_end1):
os.remove(query_fasta_end1)
if os.path.exists(query_fasta_end2):
@@ -599,7 +599,7 @@ def __main__():
try:
line.split()
num_hits += 1
- except Exception, e:
+ except Exception as e:
stop_err(str(e))
if num_hits == 0: # no hits generated
diff --git a/tools/next_gen_conversion/fastq_conversions.py b/tools/next_gen_conversion/fastq_conversions.py
index 6e52e8c5d7e..7b7a84af775 100644
--- a/tools/next_gen_conversion/fastq_conversions.py
+++ b/tools/next_gen_conversion/fastq_conversions.py
@@ -37,7 +37,7 @@ def __main__():
cmd = cmd % (options.command, options.input, options.outputFasta)
try:
os.system(cmd)
- except Exception, eq:
+ except Exception as eq:
stop_err("Error converting data format.\n" + str(eq))
if __name__ == "__main__":
diff --git a/tools/next_gen_conversion/solid_to_fastq.py b/tools/next_gen_conversion/solid_to_fastq.py
index 34c9a56cbff..642f478f41f 100644
--- a/tools/next_gen_conversion/solid_to_fastq.py
+++ b/tools/next_gen_conversion/solid_to_fastq.py
@@ -53,7 +53,7 @@ def __main__():
os.system(cmd1)
os.system('gunzip -c %s >> %s' % (tmpf.name, options.output1))
os.system('gunzip -c %s >> %s' % (tmpr.name, options.output2))
- except Exception, eq:
+ except Exception as eq:
stop_err("Error converting data to fastq format.\n" + str(eq))
tmpr.close()
tmpqr.close()
@@ -63,7 +63,7 @@ def __main__():
try:
os.system(cmd1)
os.system('gunzip -c %s >> %s' % (tmpf.name, options.output1))
- except Exception, eq:
+ except Exception as eq:
stop_err("Error converting data to fastq format.\n" + str(eq))
tmpqf.close()
tmpf.close()
diff --git a/tools/ngs_simulation/ngs_simulation.py b/tools/ngs_simulation/ngs_simulation.py
index 17ce765f726..5d2b5dbfa15 100644
--- a/tools/ngs_simulation/ngs_simulation.py
+++ b/tools/ngs_simulation/ngs_simulation.py
@@ -42,7 +42,7 @@ def __main__():
read_len = int( options.read_len )
if read_len <= 0:
raise Exception(' greater than 0')
- except TypeError, e:
+ except TypeError as e:
error = ': %s' % str( e )
if error:
stop_err( 'Make sure your number of reads is an integer value%s' % error )
@@ -51,7 +51,7 @@ def __main__():
avg_coverage = int( options.avg_coverage )
if avg_coverage <= 0:
raise Exception(' greater than 0')
- except Exception, e:
+ except Exception as e:
error = ': %s' % str( e )
if error:
stop_err( 'Make sure your average coverage is an integer value%s' % error )
@@ -62,13 +62,13 @@ def __main__():
error_rate = 10 ** ( -error_rate / 10.0 )
elif error_rate < 0:
raise Exception(' between 0 and 1')
- except Exception, e:
+ except Exception as e:
error = ': %s' % str( e )
if error:
stop_err( 'Make sure the error rate is a decimal value%s or the quality score is at least 1' % error )
try:
num_sims = int( options.num_sims )
- except TypeError, e:
+ except TypeError as e:
stop_err( 'Make sure the number of simulations is an integer value: %s' % str( e ) )
if options.polymorphism != 'None':
polymorphisms = [ float( p ) for p in options.polymorphism.split( ',' ) ]
diff --git a/tools/phenotype_association/pagetag.py b/tools/phenotype_association/pagetag.py
index 130fa305330..fe19062c10e 100755
--- a/tools/phenotype_association/pagetag.py
+++ b/tools/phenotype_association/pagetag.py
@@ -272,7 +272,7 @@ if __name__ == "__main__":
try:
opts, args = getopt(argv[1:], "hds:r:f:",
["help", "debug", "rsquare=", "freq=", "sample="])
- except GetoptError, err:
+ except GetoptError as err:
print str(err)
usage()
exit(2)
diff --git a/tools/phenotype_association/senatag.py b/tools/phenotype_association/senatag.py
index c8127b6e199..fd648c56d4f 100755
--- a/tools/phenotype_association/senatag.py
+++ b/tools/phenotype_association/senatag.py
@@ -225,7 +225,7 @@ if __name__ == "__main__":
try:
opts, args = getopt(argv[1:], "hdr:e:",
["help", "debug", "required=", "excluded="])
- except GetoptError, err:
+ except GetoptError as err:
print str(err)
usage()
exit(2)
diff --git a/tools/solid_tools/maq_cs_wrapper.py b/tools/solid_tools/maq_cs_wrapper.py
index 04144a2c0fb..f29f1fd7f44 100644
--- a/tools/solid_tools/maq_cs_wrapper.py
+++ b/tools/solid_tools/maq_cs_wrapper.py
@@ -56,7 +56,7 @@ def __main__():
os.system('gunzip -c %s >> %s' % (tmpr.name, tmprfastq.name))
os.system('gunzip -c %s >> %s' % (tmps.name, tmpsfastq.name))
- except Exception, eq:
+ except Exception as eq:
stop_err("Error converting data to fastq format." + str(eq))
# Make a temp directory where the split fastq files will be stored
@@ -129,7 +129,7 @@ def __main__():
except ValueError as we:
print >>sys.stderr, we
print >> out_f2, "%s\t%s\t%s\t%s\t%s\t%s" % ("\t".join(elems[:4]), coverage - ref_nt_count, a, t, g, c)
- except Exception, er2:
+ except Exception as er2:
stop_err("Encountered error while mapping: %s" % (str(er2)))
else: # single end reads
diff --git a/tools/stats/aggregate_scores_in_intervals.py b/tools/stats/aggregate_scores_in_intervals.py
index f527f37e339..77e8ca7c227 100755
--- a/tools/stats/aggregate_scores_in_intervals.py
+++ b/tools/stats/aggregate_scores_in_intervals.py
@@ -42,7 +42,7 @@ class PositionalScoresOnDisk:
try:
self.file.seek( i * self.fmt_size )
return struct.unpack( self.fmt, self.file.read( self.fmt_size ) )[0]
- except Exception, e:
+ except Exception as e:
raise IndexError(e)
def __setitem__( self, i, value ):
diff --git a/tools/stats/filtering.py b/tools/stats/filtering.py
index fd479fa56ff..fefbceda180 100644
--- a/tools/stats/filtering.py
+++ b/tools/stats/filtering.py
@@ -241,7 +241,7 @@ for i, line in enumerate( open( in_fname ) ):
valid_filter = True
try:
exec code
-except Exception, e:
+except Exception as e:
out.close()
if str( e ).startswith( 'invalid syntax' ):
valid_filter = False
diff --git a/tools/stats/grouping.py b/tools/stats/grouping.py
index c65992b466a..f7f8031de97 100644
--- a/tools/stats/grouping.py
+++ b/tools/stats/grouping.py
@@ -85,7 +85,7 @@ def main():
if ignorecase == 1:
case = '-f'
command_line = "sort -t ' ' %s -k%s,%s -o %s %s" % (case, group_col + 1, group_col + 1, tmpfile.name, inputfile)
- except Exception, exc:
+ except Exception as exc:
stop_err( 'Initialization error -> %s' % str(exc) )
error_code, stdout = commands.getstatusoutput(command_line)
diff --git a/tools/stats/gsummary.py b/tools/stats/gsummary.py
index 09c9019f18e..a2a6290e986 100755
--- a/tools/stats/gsummary.py
+++ b/tools/stats/gsummary.py
@@ -102,7 +102,7 @@ def main():
r.assign( col, r[ "$" ]( r_data_frame, col ) )
try:
summary = summary_func( r( expression ) )
- except RException, s:
+ except RException as s:
outfile.close()
stop_err( "Computation resulted in the following error: %s" % str( s ) )
summary = summary.as_py( BASIC_CONVERSION )