Commit 66c83e68 authored by maruel@chromium.org's avatar maruel@chromium.org

Rename retcode to returncode to be consistent with subprocess.

Change CheckCallError to inherit from Error. This will simplify try/except changes.

TEST=none
BUG=none

Review URL: http://codereview.chromium.org/3324007

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@58695 0039d316-1c4b-4281-b951-d872f2087c98
parent 6cafa13a
......@@ -27,13 +27,19 @@ import xml.dom.minidom
import xml.parsers.expat
class CheckCallError(OSError):
class Error(Exception):
"""gclient exception class."""
pass
class CheckCallError(OSError, Error):
"""CheckCall() returned non-0."""
def __init__(self, command, cwd, retcode, stdout, stderr=None):
OSError.__init__(self, command, cwd, retcode, stdout, stderr)
def __init__(self, command, cwd, returncode, stdout, stderr=None):
OSError.__init__(self, command, cwd, returncode, stdout, stderr)
Error.__init__(self)
self.command = command
self.cwd = cwd
self.retcode = retcode
self.returncode = returncode
self.stdout = stdout
self.stderr = stderr
......@@ -111,12 +117,6 @@ def GetNodeNamedAttributeText(node, node_name, attribute_name):
return child_nodes[0].getAttribute(attribute_name)
class Error(Exception):
"""gclient exception class."""
# TODO(maruel): Merge with CheckCallError.
pass
def SyntaxErrorToError(filename, e):
"""Raises a gclient_utils.Error exception with the human readable message"""
try:
......
......@@ -596,7 +596,7 @@ class FakeReposTestBase(unittest.TestCase):
self.assertEquals(expected, result, msg)
def check(self, expected, results):
"""Checks stdout, stderr, retcode."""
"""Checks stdout, stderr, returncode."""
self.checkString(expected[0], results[0])
self.checkString(expected[1], results[1])
self.assertEquals(expected[2], results[2])
......
......@@ -65,7 +65,7 @@ class CheckCallTestCase(GclientUtilBase):
except gclient_utils.CheckCallError, e:
self.assertEqual(e.command, args)
self.assertEqual(e.cwd, None)
self.assertEqual(e.retcode, 42)
self.assertEqual(e.returncode, 42)
self.assertEqual(e.stdout, 'bleh')
self.assertEqual(e.stderr, 'foo')
......
......@@ -430,10 +430,10 @@ def GuessVCS(options, path):
real_path)
return GIT(options, path)
except gclient_utils.CheckCallError, e:
if e.retcode != errno.ENOENT and e.retcode != 128:
if e.returncode != errno.ENOENT and e.returncode != 128:
# ENOENT == 2 = they don't have git installed.
# 128 = git error code when not in a repo.
logging.warn(e.retcode)
logging.warn(e.returncode)
raise
raise NoTryServerAccess("Could not guess version control system. "
"Are you in a working copy directory?")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment