Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: cit.py

Issue 2181413004: If cit is run with an unknown tool, print usage rather than throwing an exception (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cit.py
diff --git a/cit.py b/cit.py
index b99411bc922a2b054e829fe44d7647d73dcc1f3a..f08ddddc5b057e9d86cbcc6617a32cdbdd558238 100755
--- a/cit.py
+++ b/cit.py
@@ -99,27 +99,7 @@ def get_available_tools():
return (sorted(infra_tools), sorted(cipd_tools))
-def run(args):
- if args:
- tool_name = args[0]
- # Check to see if it is a infra tool first.
- infra_dir = os.path.join(
- TARGET_DIR, 'infra', 'infra', 'tools', *tool_name.split('.'))
- cipd_file = os.path.join(TARGET_DIR, 'infra', 'cipd', tool_name)
- if sys.platform.startswith('win'):
- cipd_file += '.exe'
- if (os.path.isdir(infra_dir)
- and os.path.isfile(os.path.join(infra_dir, '__main__.py'))):
- cmd = [
- sys.executable, os.path.join(TARGET_DIR, 'infra', 'run.py'),
- 'infra.tools.%s' % tool_name]
- elif os.path.isfile(cipd_file) and is_exe(cipd_file):
- cmd = [cipd_file]
-
- # Add the remaining arguments.
- cmd.extend(args[1:])
- return subprocess.call(cmd)
-
+def usage():
infra_tools, cipd_tools = get_available_tools()
print """usage: cit.py <name of tool> [args for tool]
@@ -137,6 +117,32 @@ def run(args):
print ' * %s' % tool
+def run(args):
+ if not args:
+ return usage()
+
+ tool_name = args[0]
+ # Check to see if it is a infra tool first.
+ infra_dir = os.path.join(
+ TARGET_DIR, 'infra', 'infra', 'tools', *tool_name.split('.'))
+ cipd_file = os.path.join(TARGET_DIR, 'infra', 'cipd', tool_name)
+ if sys.platform.startswith('win'):
+ cipd_file += '.exe'
+ if (os.path.isdir(infra_dir)
+ and os.path.isfile(os.path.join(infra_dir, '__main__.py'))):
+ cmd = [
+ sys.executable, os.path.join(TARGET_DIR, 'infra', 'run.py'),
+ 'infra.tools.%s' % tool_name]
+ elif os.path.isfile(cipd_file) and is_exe(cipd_file):
+ cmd = [cipd_file]
+ else:
+ print >>sys.stderr, 'Unknown tool "%s"' % tool_name
+ return usage()
+
+ # Add the remaining arguments.
+ cmd.extend(args[1:])
+ return subprocess.call(cmd)
+
def main():
parser = argparse.ArgumentParser("Chrome Infrastructure CLI.")
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698