diff options
author | Conley Owens <cco3@android.com> | 2012-10-25 10:03:36 -0700 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2012-10-25 10:03:37 -0700 |
commit | 608aff7f624e35348ff9fab74bad1d6921944238 (patch) | |
tree | e1bdbb8af5927dd226d8e22dc382fd24c4cdfa5e | |
parent | 13657c407d0424d0866993bea39ed01094caa1c1 (diff) | |
parent | a5be53f9c809009e67f217c00b8f30246aacc237 (diff) | |
download | git-repo-608aff7f624e35348ff9fab74bad1d6921944238.tar.gz |
Merge "Use modern Python exception syntax"
-rw-r--r-- | editor.py | 2 | ||||
-rw-r--r-- | git_command.py | 2 | ||||
-rw-r--r-- | git_config.py | 6 | ||||
-rwxr-xr-x | main.py | 10 | ||||
-rw-r--r-- | manifest_xml.py | 2 | ||||
-rw-r--r-- | project.py | 10 | ||||
-rwxr-xr-x | repo | 20 | ||||
-rw-r--r-- | subcmds/init.py | 2 | ||||
-rw-r--r-- | subcmds/sync.py | 6 | ||||
-rw-r--r-- | subcmds/upload.py | 4 |
10 files changed, 32 insertions, 32 deletions
@@ -91,7 +91,7 @@ least one of these before using this command.""" | |||
91 | 91 | ||
92 | try: | 92 | try: |
93 | rc = subprocess.Popen(args, shell=shell).wait() | 93 | rc = subprocess.Popen(args, shell=shell).wait() |
94 | except OSError, e: | 94 | except OSError as e: |
95 | raise EditorError('editor failed, %s: %s %s' | 95 | raise EditorError('editor failed, %s: %s %s' |
96 | % (str(e), editor, path)) | 96 | % (str(e), editor, path)) |
97 | if rc != 0: | 97 | if rc != 0: |
diff --git a/git_command.py b/git_command.py index 82709b91..a40e6c05 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -217,7 +217,7 @@ class GitCommand(object): | |||
217 | stdin = stdin, | 217 | stdin = stdin, |
218 | stdout = stdout, | 218 | stdout = stdout, |
219 | stderr = stderr) | 219 | stderr = stderr) |
220 | except Exception, e: | 220 | except Exception as e: |
221 | raise GitError('%s: %s' % (command[1], e)) | 221 | raise GitError('%s: %s' % (command[1], e)) |
222 | 222 | ||
223 | if ssh_proxy: | 223 | if ssh_proxy: |
diff --git a/git_config.py b/git_config.py index afaa6f15..ae288558 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -449,7 +449,7 @@ def _open_ssh(host, port=None): | |||
449 | try: | 449 | try: |
450 | Trace(': %s', ' '.join(command)) | 450 | Trace(': %s', ' '.join(command)) |
451 | p = subprocess.Popen(command) | 451 | p = subprocess.Popen(command) |
452 | except Exception, e: | 452 | except Exception as e: |
453 | _ssh_master = False | 453 | _ssh_master = False |
454 | print >>sys.stderr, \ | 454 | print >>sys.stderr, \ |
455 | '\nwarn: cannot enable ssh control master for %s:%s\n%s' \ | 455 | '\nwarn: cannot enable ssh control master for %s:%s\n%s' \ |
@@ -592,9 +592,9 @@ class Remote(object): | |||
592 | else: | 592 | else: |
593 | host, port = info.split() | 593 | host, port = info.split() |
594 | self._review_url = self._SshReviewUrl(userEmail, host, port) | 594 | self._review_url = self._SshReviewUrl(userEmail, host, port) |
595 | except urllib2.HTTPError, e: | 595 | except urllib2.HTTPError as e: |
596 | raise UploadError('%s: %s' % (self.review, str(e))) | 596 | raise UploadError('%s: %s' % (self.review, str(e))) |
597 | except urllib2.URLError, e: | 597 | except urllib2.URLError as e: |
598 | raise UploadError('%s: %s' % (self.review, str(e))) | 598 | raise UploadError('%s: %s' % (self.review, str(e))) |
599 | 599 | ||
600 | REVIEW_CACHE[u] = self._review_url | 600 | REVIEW_CACHE[u] = self._review_url |
@@ -146,13 +146,13 @@ class _Repo(object): | |||
146 | else: | 146 | else: |
147 | print >>sys.stderr, 'real\t%dh%dm%.3fs' \ | 147 | print >>sys.stderr, 'real\t%dh%dm%.3fs' \ |
148 | % (hours, minutes, seconds) | 148 | % (hours, minutes, seconds) |
149 | except DownloadError, e: | 149 | except DownloadError as e: |
150 | print >>sys.stderr, 'error: %s' % str(e) | 150 | print >>sys.stderr, 'error: %s' % str(e) |
151 | return 1 | 151 | return 1 |
152 | except ManifestInvalidRevisionError, e: | 152 | except ManifestInvalidRevisionError as e: |
153 | print >>sys.stderr, 'error: %s' % str(e) | 153 | print >>sys.stderr, 'error: %s' % str(e) |
154 | return 1 | 154 | return 1 |
155 | except NoSuchProjectError, e: | 155 | except NoSuchProjectError as e: |
156 | if e.name: | 156 | if e.name: |
157 | print >>sys.stderr, 'error: project %s not found' % e.name | 157 | print >>sys.stderr, 'error: project %s not found' % e.name |
158 | else: | 158 | else: |
@@ -390,14 +390,14 @@ def _Main(argv): | |||
390 | close_ssh() | 390 | close_ssh() |
391 | except KeyboardInterrupt: | 391 | except KeyboardInterrupt: |
392 | result = 1 | 392 | result = 1 |
393 | except RepoChangedException, rce: | 393 | except RepoChangedException as rce: |
394 | # If repo changed, re-exec ourselves. | 394 | # If repo changed, re-exec ourselves. |
395 | # | 395 | # |
396 | argv = list(sys.argv) | 396 | argv = list(sys.argv) |
397 | argv.extend(rce.extra_args) | 397 | argv.extend(rce.extra_args) |
398 | try: | 398 | try: |
399 | os.execv(__file__, argv) | 399 | os.execv(__file__, argv) |
400 | except OSError, e: | 400 | except OSError as e: |
401 | print >>sys.stderr, 'fatal: cannot restart repo after upgrade' | 401 | print >>sys.stderr, 'fatal: cannot restart repo after upgrade' |
402 | print >>sys.stderr, 'fatal: %s' % e | 402 | print >>sys.stderr, 'fatal: %s' % e |
403 | result = 128 | 403 | result = 128 |
diff --git a/manifest_xml.py b/manifest_xml.py index 71dbdc7d..11e4ee54 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -351,7 +351,7 @@ class XmlManifest(object): | |||
351 | # tricky. actual parsing implementation may vary. | 351 | # tricky. actual parsing implementation may vary. |
352 | except (KeyboardInterrupt, RuntimeError, SystemExit): | 352 | except (KeyboardInterrupt, RuntimeError, SystemExit): |
353 | raise | 353 | raise |
354 | except Exception, e: | 354 | except Exception as e: |
355 | raise ManifestParseError( | 355 | raise ManifestParseError( |
356 | "failed parsing included manifest %s: %s", (name, e)) | 356 | "failed parsing included manifest %s: %s", (name, e)) |
357 | else: | 357 | else: |
@@ -1077,7 +1077,7 @@ class Project(object): | |||
1077 | 1077 | ||
1078 | try: | 1078 | try: |
1079 | self._Checkout(revid, quiet=True) | 1079 | self._Checkout(revid, quiet=True) |
1080 | except GitError, e: | 1080 | except GitError as e: |
1081 | syncbuf.fail(self, e) | 1081 | syncbuf.fail(self, e) |
1082 | return | 1082 | return |
1083 | self._CopyFiles() | 1083 | self._CopyFiles() |
@@ -1099,7 +1099,7 @@ class Project(object): | |||
1099 | branch.name) | 1099 | branch.name) |
1100 | try: | 1100 | try: |
1101 | self._Checkout(revid, quiet=True) | 1101 | self._Checkout(revid, quiet=True) |
1102 | except GitError, e: | 1102 | except GitError as e: |
1103 | syncbuf.fail(self, e) | 1103 | syncbuf.fail(self, e) |
1104 | return | 1104 | return |
1105 | self._CopyFiles() | 1105 | self._CopyFiles() |
@@ -1184,7 +1184,7 @@ class Project(object): | |||
1184 | try: | 1184 | try: |
1185 | self._ResetHard(revid) | 1185 | self._ResetHard(revid) |
1186 | self._CopyFiles() | 1186 | self._CopyFiles() |
1187 | except GitError, e: | 1187 | except GitError as e: |
1188 | syncbuf.fail(self, e) | 1188 | syncbuf.fail(self, e) |
1189 | return | 1189 | return |
1190 | else: | 1190 | else: |
@@ -1901,7 +1901,7 @@ class Project(object): | |||
1901 | continue | 1901 | continue |
1902 | try: | 1902 | try: |
1903 | os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst) | 1903 | os.symlink(os.path.relpath(stock_hook, os.path.dirname(dst)), dst) |
1904 | except OSError, e: | 1904 | except OSError as e: |
1905 | if e.errno == errno.EPERM: | 1905 | if e.errno == errno.EPERM: |
1906 | raise GitError('filesystem must support symlinks') | 1906 | raise GitError('filesystem must support symlinks') |
1907 | else: | 1907 | else: |
@@ -1964,7 +1964,7 @@ class Project(object): | |||
1964 | os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) | 1964 | os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) |
1965 | else: | 1965 | else: |
1966 | raise GitError('cannot overwrite a local work tree') | 1966 | raise GitError('cannot overwrite a local work tree') |
1967 | except OSError, e: | 1967 | except OSError as e: |
1968 | if e.errno == errno.EPERM: | 1968 | if e.errno == errno.EPERM: |
1969 | raise GitError('filesystem must support symlinks') | 1969 | raise GitError('filesystem must support symlinks') |
1970 | else: | 1970 | else: |
@@ -185,7 +185,7 @@ def _Init(args): | |||
185 | if not os.path.isdir(repodir): | 185 | if not os.path.isdir(repodir): |
186 | try: | 186 | try: |
187 | os.mkdir(repodir) | 187 | os.mkdir(repodir) |
188 | except OSError, e: | 188 | except OSError as e: |
189 | print >>sys.stderr, \ | 189 | print >>sys.stderr, \ |
190 | 'fatal: cannot make %s directory: %s' % ( | 190 | 'fatal: cannot make %s directory: %s' % ( |
191 | repodir, e.strerror) | 191 | repodir, e.strerror) |
@@ -221,7 +221,7 @@ def _CheckGitVersion(): | |||
221 | cmd = [GIT, '--version'] | 221 | cmd = [GIT, '--version'] |
222 | try: | 222 | try: |
223 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) | 223 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
224 | except OSError, e: | 224 | except OSError as e: |
225 | print >>sys.stderr | 225 | print >>sys.stderr |
226 | print >>sys.stderr, "fatal: '%s' is not available" % GIT | 226 | print >>sys.stderr, "fatal: '%s' is not available" % GIT |
227 | print >>sys.stderr, 'fatal: %s' % e | 227 | print >>sys.stderr, 'fatal: %s' % e |
@@ -268,7 +268,7 @@ def _SetupGnuPG(quiet): | |||
268 | if not os.path.isdir(home_dot_repo): | 268 | if not os.path.isdir(home_dot_repo): |
269 | try: | 269 | try: |
270 | os.mkdir(home_dot_repo) | 270 | os.mkdir(home_dot_repo) |
271 | except OSError, e: | 271 | except OSError as e: |
272 | print >>sys.stderr, \ | 272 | print >>sys.stderr, \ |
273 | 'fatal: cannot make %s directory: %s' % ( | 273 | 'fatal: cannot make %s directory: %s' % ( |
274 | home_dot_repo, e.strerror) | 274 | home_dot_repo, e.strerror) |
@@ -277,7 +277,7 @@ def _SetupGnuPG(quiet): | |||
277 | if not os.path.isdir(gpg_dir): | 277 | if not os.path.isdir(gpg_dir): |
278 | try: | 278 | try: |
279 | os.mkdir(gpg_dir, 0700) | 279 | os.mkdir(gpg_dir, 0700) |
280 | except OSError, e: | 280 | except OSError as e: |
281 | print >>sys.stderr, \ | 281 | print >>sys.stderr, \ |
282 | 'fatal: cannot make %s directory: %s' % ( | 282 | 'fatal: cannot make %s directory: %s' % ( |
283 | gpg_dir, e.strerror) | 283 | gpg_dir, e.strerror) |
@@ -291,7 +291,7 @@ def _SetupGnuPG(quiet): | |||
291 | proc = subprocess.Popen(cmd, | 291 | proc = subprocess.Popen(cmd, |
292 | env = env, | 292 | env = env, |
293 | stdin = subprocess.PIPE) | 293 | stdin = subprocess.PIPE) |
294 | except OSError, e: | 294 | except OSError as e: |
295 | if not quiet: | 295 | if not quiet: |
296 | print >>sys.stderr, 'warning: gpg (GnuPG) is not available.' | 296 | print >>sys.stderr, 'warning: gpg (GnuPG) is not available.' |
297 | print >>sys.stderr, 'warning: Installing it is strongly encouraged.' | 297 | print >>sys.stderr, 'warning: Installing it is strongly encouraged.' |
@@ -392,13 +392,13 @@ def _DownloadBundle(url, local, quiet): | |||
392 | try: | 392 | try: |
393 | try: | 393 | try: |
394 | r = urllib2.urlopen(url) | 394 | r = urllib2.urlopen(url) |
395 | except urllib2.HTTPError, e: | 395 | except urllib2.HTTPError as e: |
396 | if e.code == 404: | 396 | if e.code == 404: |
397 | return False | 397 | return False |
398 | print >>sys.stderr, 'fatal: Cannot get %s' % url | 398 | print >>sys.stderr, 'fatal: Cannot get %s' % url |
399 | print >>sys.stderr, 'fatal: HTTP error %s' % e.code | 399 | print >>sys.stderr, 'fatal: HTTP error %s' % e.code |
400 | raise CloneFailure() | 400 | raise CloneFailure() |
401 | except urllib2.URLError, e: | 401 | except urllib2.URLError as e: |
402 | print >>sys.stderr, 'fatal: Cannot get %s' % url | 402 | print >>sys.stderr, 'fatal: Cannot get %s' % url |
403 | print >>sys.stderr, 'fatal: error %s' % e.reason | 403 | print >>sys.stderr, 'fatal: error %s' % e.reason |
404 | raise CloneFailure() | 404 | raise CloneFailure() |
@@ -427,7 +427,7 @@ def _Clone(url, local, quiet): | |||
427 | """ | 427 | """ |
428 | try: | 428 | try: |
429 | os.mkdir(local) | 429 | os.mkdir(local) |
430 | except OSError, e: | 430 | except OSError as e: |
431 | print >>sys.stderr, \ | 431 | print >>sys.stderr, \ |
432 | 'fatal: cannot make %s directory: %s' \ | 432 | 'fatal: cannot make %s directory: %s' \ |
433 | % (local, e.strerror) | 433 | % (local, e.strerror) |
@@ -436,7 +436,7 @@ def _Clone(url, local, quiet): | |||
436 | cmd = [GIT, 'init', '--quiet'] | 436 | cmd = [GIT, 'init', '--quiet'] |
437 | try: | 437 | try: |
438 | proc = subprocess.Popen(cmd, cwd = local) | 438 | proc = subprocess.Popen(cmd, cwd = local) |
439 | except OSError, e: | 439 | except OSError as e: |
440 | print >>sys.stderr | 440 | print >>sys.stderr |
441 | print >>sys.stderr, "fatal: '%s' is not available" % GIT | 441 | print >>sys.stderr, "fatal: '%s' is not available" % GIT |
442 | print >>sys.stderr, 'fatal: %s' % e | 442 | print >>sys.stderr, 'fatal: %s' % e |
@@ -699,7 +699,7 @@ def main(orig_args): | |||
699 | me.extend(extra_args) | 699 | me.extend(extra_args) |
700 | try: | 700 | try: |
701 | os.execv(repo_main, me) | 701 | os.execv(repo_main, me) |
702 | except OSError, e: | 702 | except OSError as e: |
703 | print >>sys.stderr, "fatal: unable to start %s" % repo_main | 703 | print >>sys.stderr, "fatal: unable to start %s" % repo_main |
704 | print >>sys.stderr, "fatal: %s" % e | 704 | print >>sys.stderr, "fatal: %s" % e |
705 | sys.exit(148) | 705 | sys.exit(148) |
diff --git a/subcmds/init.py b/subcmds/init.py index 007667e2..b6b98076 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -207,7 +207,7 @@ to update the working directory files. | |||
207 | 207 | ||
208 | try: | 208 | try: |
209 | self.manifest.Link(name) | 209 | self.manifest.Link(name) |
210 | except ManifestParseError, e: | 210 | except ManifestParseError as e: |
211 | print >>sys.stderr, "fatal: manifest '%s' not available" % name | 211 | print >>sys.stderr, "fatal: manifest '%s' not available" % name |
212 | print >>sys.stderr, 'fatal: %s' % str(e) | 212 | print >>sys.stderr, 'fatal: %s' % str(e) |
213 | sys.exit(1) | 213 | sys.exit(1) |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 90e2908f..28c154a0 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -417,7 +417,7 @@ uncommitted changes are present' % project.relpath | |||
417 | # in the .netrc file. | 417 | # in the .netrc file. |
418 | print >>sys.stderr, 'No credentials found for %s in .netrc' % \ | 418 | print >>sys.stderr, 'No credentials found for %s in .netrc' % \ |
419 | parse_result.hostname | 419 | parse_result.hostname |
420 | except netrc.NetrcParseError, e: | 420 | except netrc.NetrcParseError as e: |
421 | print >>sys.stderr, 'Error parsing .netrc file: %s' % e | 421 | print >>sys.stderr, 'Error parsing .netrc file: %s' % e |
422 | 422 | ||
423 | if (username and password): | 423 | if (username and password): |
@@ -464,11 +464,11 @@ uncommitted changes are present' % project.relpath | |||
464 | else: | 464 | else: |
465 | print >>sys.stderr, 'error: %s' % manifest_str | 465 | print >>sys.stderr, 'error: %s' % manifest_str |
466 | sys.exit(1) | 466 | sys.exit(1) |
467 | except (socket.error, IOError, xmlrpclib.Fault), e: | 467 | except (socket.error, IOError, xmlrpclib.Fault) as e: |
468 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%s' % ( | 468 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%s' % ( |
469 | self.manifest.manifest_server, e) | 469 | self.manifest.manifest_server, e) |
470 | sys.exit(1) | 470 | sys.exit(1) |
471 | except xmlrpclib.ProtocolError, e: | 471 | except xmlrpclib.ProtocolError as e: |
472 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%d %s' % ( | 472 | print >>sys.stderr, 'error: cannot connect to manifest server %s:\n%d %s' % ( |
473 | self.manifest.manifest_server, e.errcode, e.errmsg) | 473 | self.manifest.manifest_server, e.errcode, e.errmsg) |
474 | sys.exit(1) | 474 | sys.exit(1) |
diff --git a/subcmds/upload.py b/subcmds/upload.py index 685e3420..84a5e440 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -329,7 +329,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
329 | 329 | ||
330 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) | 330 | branch.UploadForReview(people, auto_topic=opt.auto_topic, draft=opt.draft) |
331 | branch.uploaded = True | 331 | branch.uploaded = True |
332 | except UploadError, e: | 332 | except UploadError as e: |
333 | branch.error = e | 333 | branch.error = e |
334 | branch.uploaded = False | 334 | branch.uploaded = False |
335 | have_errors = True | 335 | have_errors = True |
@@ -384,7 +384,7 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
384 | pending_proj_names = [project.name for (project, avail) in pending] | 384 | pending_proj_names = [project.name for (project, avail) in pending] |
385 | try: | 385 | try: |
386 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names) | 386 | hook.Run(opt.allow_all_hooks, project_list=pending_proj_names) |
387 | except HookError, e: | 387 | except HookError as e: |
388 | print >>sys.stderr, "ERROR: %s" % str(e) | 388 | print >>sys.stderr, "ERROR: %s" % str(e) |
389 | return | 389 | return |
390 | 390 | ||