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

Side by Side Diff: gcl.py

Issue 2671003: Fix a bug in Warn(), simplify code (Closed)
Patch Set: Created 10 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """\ 6 """\
7 Wrapper script around Rietveld's upload.py that simplifies working with groups 7 Wrapper script around Rietveld's upload.py that simplifies working with groups
8 of files. 8 of files.
9 """ 9 """
10 10
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 for line in settings_file.splitlines(): 177 for line in settings_file.splitlines():
178 if not line or line.startswith("#"): 178 if not line or line.startswith("#"):
179 continue 179 continue
180 k, v = line.split(": ", 1) 180 k, v = line.split(": ", 1)
181 CODEREVIEW_SETTINGS[k] = v 181 CODEREVIEW_SETTINGS[k] = v
182 CODEREVIEW_SETTINGS.setdefault('__just_initialized', None) 182 CODEREVIEW_SETTINGS.setdefault('__just_initialized', None)
183 return CODEREVIEW_SETTINGS.get(key, "") 183 return CODEREVIEW_SETTINGS.get(key, "")
184 184
185 185
186 def Warn(msg): 186 def Warn(msg):
187 ErrorExit(msg, exit=False) 187 print >> sys.stderr, msg
188 188
189 189
190 def ErrorExit(msg, do_exit=True): 190 def ErrorExit(msg):
191 """Print an error message to stderr and optionally exit."""
192 print >> sys.stderr, msg 191 print >> sys.stderr, msg
193 if do_exit: 192 sys.exit(1)
194 sys.exit(1)
195 193
196 194
197 def RunShellWithReturnCode(command, print_output=False): 195 def RunShellWithReturnCode(command, print_output=False):
198 """Executes a command and returns the output and the return code.""" 196 """Executes a command and returns the output and the return code."""
199 # Use a shell for subcommands on Windows to get a PATH search, and because svn 197 # Use a shell for subcommands on Windows to get a PATH search, and because svn
200 # may be a batch file. 198 # may be a batch file.
201 use_shell = sys.platform.startswith("win") 199 use_shell = sys.platform.startswith("win")
202 p = subprocess.Popen(command, stdout=subprocess.PIPE, 200 p = subprocess.Popen(command, stdout=subprocess.PIPE,
203 stderr=subprocess.STDOUT, shell=use_shell, 201 stderr=subprocess.STDOUT, shell=use_shell,
204 universal_newlines=True) 202 universal_newlines=True)
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 argv = ['help'] 1312 argv = ['help']
1315 command = Command(argv[0]) 1313 command = Command(argv[0])
1316 if command: 1314 if command:
1317 return command(argv[1:]) 1315 return command(argv[1:])
1318 # Unknown command, try to pass that to svn 1316 # Unknown command, try to pass that to svn
1319 return CMDpassthru(argv) 1317 return CMDpassthru(argv)
1320 1318
1321 1319
1322 if __name__ == "__main__": 1320 if __name__ == "__main__":
1323 sys.exit(main(sys.argv[1:])) 1321 sys.exit(main(sys.argv[1:]))
OLDNEW
« 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