Use modern Python exception syntax

"except Exception as e" instead of "except Exception, e"

This is part of a transition to supporting Python 3.  Python >= 2.6
support "as" syntax.

Note: this removes Python 2.5 support.

Change-Id: I309599f3981bba2b46111c43102bee38ff132803
This commit is contained in:
Sarah Owens
2012-09-09 15:37:57 -07:00
parent 9ed12c5d9c
commit a5be53f9c8
10 changed files with 32 additions and 32 deletions

20
repo
View File

@ -185,7 +185,7 @@ def _Init(args):
if not os.path.isdir(repodir):
try:
os.mkdir(repodir)
except OSError, e:
except OSError as e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
repodir, e.strerror)
@ -221,7 +221,7 @@ def _CheckGitVersion():
cmd = [GIT, '--version']
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
except OSError, e:
except OSError as e:
print >>sys.stderr
print >>sys.stderr, "fatal: '%s' is not available" % GIT
print >>sys.stderr, 'fatal: %s' % e
@ -268,7 +268,7 @@ def _SetupGnuPG(quiet):
if not os.path.isdir(home_dot_repo):
try:
os.mkdir(home_dot_repo)
except OSError, e:
except OSError as e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
home_dot_repo, e.strerror)
@ -277,7 +277,7 @@ def _SetupGnuPG(quiet):
if not os.path.isdir(gpg_dir):
try:
os.mkdir(gpg_dir, 0700)
except OSError, e:
except OSError as e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' % (
gpg_dir, e.strerror)
@ -291,7 +291,7 @@ def _SetupGnuPG(quiet):
proc = subprocess.Popen(cmd,
env = env,
stdin = subprocess.PIPE)
except OSError, e:
except OSError as e:
if not quiet:
print >>sys.stderr, 'warning: gpg (GnuPG) is not available.'
print >>sys.stderr, 'warning: Installing it is strongly encouraged.'
@ -392,13 +392,13 @@ def _DownloadBundle(url, local, quiet):
try:
try:
r = urllib2.urlopen(url)
except urllib2.HTTPError, e:
except urllib2.HTTPError as e:
if e.code == 404:
return False
print >>sys.stderr, 'fatal: Cannot get %s' % url
print >>sys.stderr, 'fatal: HTTP error %s' % e.code
raise CloneFailure()
except urllib2.URLError, e:
except urllib2.URLError as e:
print >>sys.stderr, 'fatal: Cannot get %s' % url
print >>sys.stderr, 'fatal: error %s' % e.reason
raise CloneFailure()
@ -427,7 +427,7 @@ def _Clone(url, local, quiet):
"""
try:
os.mkdir(local)
except OSError, e:
except OSError as e:
print >>sys.stderr, \
'fatal: cannot make %s directory: %s' \
% (local, e.strerror)
@ -436,7 +436,7 @@ def _Clone(url, local, quiet):
cmd = [GIT, 'init', '--quiet']
try:
proc = subprocess.Popen(cmd, cwd = local)
except OSError, e:
except OSError as e:
print >>sys.stderr
print >>sys.stderr, "fatal: '%s' is not available" % GIT
print >>sys.stderr, 'fatal: %s' % e
@ -699,7 +699,7 @@ def main(orig_args):
me.extend(extra_args)
try:
os.execv(repo_main, me)
except OSError, e:
except OSError as e:
print >>sys.stderr, "fatal: unable to start %s" % repo_main
print >>sys.stderr, "fatal: %s" % e
sys.exit(148)