Skip to content

Commit

Permalink
BF(PY3): use except ... as syntax instead of except ...,
Browse files Browse the repository at this point in the history
was done via cmdline

git grep -l 'except.*, [a-z]\+:' | xargs sed -ie 's|\(except.*\), \([a-z]*:\)|\1 as \2|g'
  • Loading branch information
yarikoptic committed Dec 22, 2015
1 parent 22ab610 commit 8ab3476
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bin/cfadmin
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ if __name__ == "__main__":
cmd = help
try:
cmd(cf, *args)
except TypeError, e:
except TypeError as e:
print e
help(cf, cmd.__name__)
4 changes: 2 additions & 2 deletions bin/cq
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ def main():
if queue_name:
try:
rs = [c.create_queue(queue_name)]
except SQSError, e:
except SQSError as e:
print 'An Error Occurred:'
print '%s: %s' % (e.status, e.reason)
print e.body
sys.exit()
else:
try:
rs = c.get_all_queues()
except SQSError, e:
except SQSError as e:
print 'An Error Occurred:'
print '%s: %s' % (e.status, e.reason)
print e.body
Expand Down
2 changes: 1 addition & 1 deletion bin/cwutil
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ if __name__ == "__main__":
cmd = help
try:
cmd(*args)
except TypeError, e:
except TypeError as e:
print e
help(cmd.__name__)
2 changes: 1 addition & 1 deletion bin/route53
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,6 @@ if __name__ == "__main__":
cmd = help
try:
cmd(conn, *args)
except TypeError, e:
except TypeError as e:
print e
help(conn, cmd.__name__)
2 changes: 1 addition & 1 deletion boto/glacier/concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _process_chunk(self, work):
except self._retry_exceptions as e:
log.error("Exception caught uploading part number %s for "
"vault %s, attempt: (%s / %s), filename: %s, "
"exception: %s, msg: %s",
"exception: %s as msg: %s",
work[0], self._vault_name, i + 1, self._num_retries + 1,
self._filename, e.__class__, e)
time.sleep(self._time_between_retries)
Expand Down
4 changes: 2 additions & 2 deletions boto/pyami/installers/ubuntu/ebs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def main(self):
self.run("/usr/sbin/xfs_freeze -f ${mount_point}", exit_on_error = True)
snapshot = ec2.create_snapshot('${volume_id}')
boto.log.info("Snapshot created: %s " % snapshot)
except Exception, e:
except Exception as e:
self.notify(subject="${instance_id} Backup Failed", body=traceback.format_exc())
boto.log.info("Snapshot created: ${volume_id}")
except Exception, e:
except Exception as e:
self.notify(subject="${instance_id} Backup Failed", body=traceback.format_exc())
finally:
self.run("/usr/sbin/xfs_freeze -u ${mount_point}")
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
try:
release = os.environ.get('SVN_REVISION', 'HEAD')
print release
except Exception, e:
except Exception as e:
print e

html_title = "boto v%s" % version
2 changes: 1 addition & 1 deletion docs/source/swf_tut.rst
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ The workers only need to know which task lists to poll.
try:
print 'working on activity from tasklist %s at %i' % (self.task_list, time.time())
self.activity(activity_task.get('input'))
except Exception, error:
except Exception as error:
self.fail(reason=str(error))
raise error
Expand Down
2 changes: 1 addition & 1 deletion tests/fps/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_bad_request(self):
try:
self.fps.write_off_debt(CreditInstrumentId='foo',
AdjustmentAmount=123.45)
except Exception, e:
except Exception as e:
print e

@unittest.skip('cosmetic')
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/gs/test_resumable_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_failed_download_with_persistent_tracker(self):
dst_fp, cb=harness.call,
res_download_handler=res_download_handler)
self.fail('Did not get expected ResumableDownloadException')
except ResumableDownloadException, e:
except ResumableDownloadException as e:
# We'll get a ResumableDownloadException at this point because
# of CallbackTestHarness (above). Check that the tracker file was
# created correctly.
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_non_retryable_exception_handling(self):
dst_fp, cb=harness.call,
res_download_handler=res_download_handler)
self.fail('Did not get expected OSError')
except OSError, e:
except OSError as e:
# Ensure the error was re-raised.
self.assertEqual(e.errno, 13)

Expand Down Expand Up @@ -228,7 +228,7 @@ def test_multiple_in_process_failures_then_succeed_with_tracker_file(self):
dst_fp, cb=harness.call,
res_download_handler=res_download_handler)
self.fail('Did not get expected ResumableDownloadException')
except ResumableDownloadException, e:
except ResumableDownloadException as e:
self.assertEqual(e.disposition,
ResumableTransferDisposition.ABORT_CUR_PROCESS)
# Ensure a tracker file survived.
Expand Down Expand Up @@ -345,7 +345,7 @@ def test_download_with_unwritable_tracker_file(self):
os.chmod(tmp_dir, 0)
res_download_handler = ResumableDownloadHandler(
tracker_file_name=tracker_file_name)
except ResumableDownloadException, e:
except ResumableDownloadException as e:
self.assertEqual(e.disposition, ResumableTransferDisposition.ABORT)
self.assertNotEqual(
e.message.find('Couldn\'t write URI tracker file'), -1)
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/gs/test_resumable_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_failed_upload_with_persistent_tracker(self):
small_src_file, cb=harness.call,
res_upload_handler=res_upload_handler)
self.fail('Did not get expected ResumableUploadException')
except ResumableUploadException, e:
except ResumableUploadException as e:
# We'll get a ResumableUploadException at this point because
# of CallbackTestHarness (above). Check that the tracker file was
# created correctly.
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_non_retryable_exception_handling(self):
small_src_file, cb=harness.call,
res_upload_handler=res_upload_handler)
self.fail('Did not get expected OSError')
except OSError, e:
except OSError as e:
# Ensure the error was re-raised.
self.assertEqual(e.errno, 13)

Expand Down Expand Up @@ -247,7 +247,7 @@ def test_multiple_in_process_failures_then_succeed_with_tracker_file(self):
larger_src_file, cb=harness.call,
res_upload_handler=res_upload_handler)
self.fail('Did not get expected ResumableUploadException')
except ResumableUploadException, e:
except ResumableUploadException as e:
self.assertEqual(e.disposition,
ResumableTransferDisposition.ABORT_CUR_PROCESS)
# Ensure a tracker file survived.
Expand Down Expand Up @@ -351,7 +351,7 @@ def test_upload_with_file_size_change_between_starts(self):
larger_src_file, cb=harness.call,
res_upload_handler=res_upload_handler)
self.fail('Did not get expected ResumableUploadException')
except ResumableUploadException, e:
except ResumableUploadException as e:
# First abort (from harness-forced failure) should be
# ABORT_CUR_PROCESS.
self.assertEqual(e.disposition, ResumableTransferDisposition.ABORT_CUR_PROCESS)
Expand All @@ -368,7 +368,7 @@ def test_upload_with_file_size_change_between_starts(self):
dst_key.set_contents_from_file(
largest_src_file, res_upload_handler=res_upload_handler)
self.fail('Did not get expected ResumableUploadException')
except ResumableUploadException, e:
except ResumableUploadException as e:
# This abort should be a hard abort (file size changing during
# transfer).
self.assertEqual(e.disposition, ResumableTransferDisposition.ABORT)
Expand All @@ -391,7 +391,7 @@ def test_upload_with_file_size_change_during_upload(self):
test_file, cb=harness.call,
res_upload_handler=res_upload_handler)
self.fail('Did not get expected ResumableUploadException')
except ResumableUploadException, e:
except ResumableUploadException as e:
self.assertEqual(e.disposition, ResumableTransferDisposition.ABORT)
self.assertNotEqual(
e.message.find('File changed during upload'), -1)
Expand All @@ -411,7 +411,7 @@ def Execute():
test_file, cb=harness.call,
res_upload_handler=res_upload_handler)
return False
except ResumableUploadException, e:
except ResumableUploadException as e:
self.assertEqual(e.disposition, ResumableTransferDisposition.ABORT)
# Ensure the file size didn't change.
test_file.seek(0, os.SEEK_END)
Expand All @@ -422,7 +422,7 @@ def Execute():
try:
dst_key_uri.get_key()
self.fail('Did not get expected InvalidUriError')
except InvalidUriError, e:
except InvalidUriError as e:
pass
return True

Expand Down Expand Up @@ -477,7 +477,7 @@ def test_upload_with_content_length_header_set(self):
small_src_file, res_upload_handler=res_upload_handler,
headers={'Content-Length' : SMALL_KEY_SIZE})
self.fail('Did not get expected ResumableUploadException')
except ResumableUploadException, e:
except ResumableUploadException as e:
self.assertEqual(e.disposition, ResumableTransferDisposition.ABORT)
self.assertNotEqual(
e.message.find('Attempt to specify Content-Length header'), -1)
Expand Down Expand Up @@ -543,7 +543,7 @@ def test_upload_with_unwritable_tracker_file(self):
os.chmod(tmp_dir, 0)
res_upload_handler = ResumableUploadHandler(
tracker_file_name=tracker_file_name)
except ResumableUploadException, e:
except ResumableUploadException as e:
self.assertEqual(e.disposition, ResumableTransferDisposition.ABORT)
self.assertNotEqual(
e.message.find('Couldn\'t write URI tracker file'), -1)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/gs/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ def tearDown(self):
for k in bucket.list_versions():
try:
bucket.delete_key(k.name, generation=k.generation)
except GSResponseError, e:
except GSResponseError as e:
if e.status != 404:
raise
bucket.delete()
except GSResponseError, e:
except GSResponseError as e:
if e.status != 404:
raise
self._buckets.pop()
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/gs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def f_retry(*args, **kwargs):
return f(*args, **kwargs)
try_one_last_time = False
break
except ExceptionToCheck, e:
except ExceptionToCheck as e:
msg = "%s, Retrying in %d seconds..." % (str(e), mdelay)
if logger:
logger.warning(msg)
Expand Down
2 changes: 1 addition & 1 deletion tests/mturk/selenium_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def has_selenium():
# a little trick to see if the server is responding
try:
sel.do_command('shutdown', '')
except Exception, e:
except Exception as e:
if not 'Server Exception' in str(e):
raise
result = True
Expand Down

0 comments on commit 8ab3476

Please sign in to comment.