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

Side by Side Diff: gcl.py

Issue 2942005: Add exception management on invalid codereview.settings. (Closed)
Patch Set: Created 10 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 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 169
170 def GetCodeReviewSetting(key): 170 def GetCodeReviewSetting(key):
171 """Returns a value for the given key for this repository.""" 171 """Returns a value for the given key for this repository."""
172 # Use '__just_initialized' as a flag to determine if the settings were 172 # Use '__just_initialized' as a flag to determine if the settings were
173 # already initialized. 173 # already initialized.
174 if '__just_initialized' not in CODEREVIEW_SETTINGS: 174 if '__just_initialized' not in CODEREVIEW_SETTINGS:
175 settings_file = GetCachedFile(CODEREVIEW_SETTINGS_FILE) 175 settings_file = GetCachedFile(CODEREVIEW_SETTINGS_FILE)
176 if settings_file: 176 if settings_file:
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 if not ':' in line:
181 raise gclient_utils.Error(
182 '%s is invalid, please fix. It\'s content:\n\n%s' %
183 (CODEREVIEW_SETTINGS_FILE, settings_file))
184 k, v = line.split(': ', 1)
181 CODEREVIEW_SETTINGS[k] = v 185 CODEREVIEW_SETTINGS[k] = v
182 CODEREVIEW_SETTINGS.setdefault('__just_initialized', None) 186 CODEREVIEW_SETTINGS.setdefault('__just_initialized', None)
183 return CODEREVIEW_SETTINGS.get(key, "") 187 return CODEREVIEW_SETTINGS.get(key, "")
184 188
185 189
186 def Warn(msg): 190 def Warn(msg):
187 print >> sys.stderr, msg 191 print >> sys.stderr, msg
188 192
189 193
190 def ErrorExit(msg): 194 def ErrorExit(msg):
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 return command(argv[1:]) 1305 return command(argv[1:])
1302 1306
1303 try: 1307 try:
1304 GetRepositoryRoot() 1308 GetRepositoryRoot()
1305 except gclient_utils.Error: 1309 except gclient_utils.Error:
1306 print('To use gcl, you need to be in a subversion checkout.') 1310 print('To use gcl, you need to be in a subversion checkout.')
1307 return 1 1311 return 1
1308 1312
1309 # Create the directories where we store information about changelists if it 1313 # Create the directories where we store information about changelists if it
1310 # doesn't exist. 1314 # doesn't exist.
1311 if not os.path.exists(GetInfoDir()): 1315 try:
1312 os.mkdir(GetInfoDir()) 1316 if not os.path.exists(GetInfoDir()):
1313 if not os.path.exists(GetChangesDir()): 1317 os.mkdir(GetInfoDir())
1314 os.mkdir(GetChangesDir()) 1318 if not os.path.exists(GetChangesDir()):
1315 if not os.path.exists(GetCacheDir()): 1319 os.mkdir(GetChangesDir())
1316 os.mkdir(GetCacheDir()) 1320 if not os.path.exists(GetCacheDir()):
1321 os.mkdir(GetCacheDir())
1317 1322
1318 if command: 1323 if command:
1319 return command(argv[1:]) 1324 return command(argv[1:])
1320 # Unknown command, try to pass that to svn 1325 # Unknown command, try to pass that to svn
1321 return CMDpassthru(argv) 1326 return CMDpassthru(argv)
1322 1327 except gclient_utils.Error, e:
1328 print('Got an exception')
1329 print(str(e))
1323 1330
1324 if __name__ == "__main__": 1331 if __name__ == "__main__":
1325 sys.exit(main(sys.argv[1:])) 1332 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