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

Unified 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 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: gcl.py
diff --git a/gcl.py b/gcl.py
index c98c11ee7d209eca0dd96457624c282965ccc078..dc73e1a0a804bd8f405c246e73665a1eeb61ff7c 100755
--- a/gcl.py
+++ b/gcl.py
@@ -175,9 +175,13 @@ def GetCodeReviewSetting(key):
settings_file = GetCachedFile(CODEREVIEW_SETTINGS_FILE)
if settings_file:
for line in settings_file.splitlines():
- if not line or line.startswith("#"):
+ if not line or line.startswith('#'):
continue
- k, v = line.split(": ", 1)
+ if not ':' in line:
+ raise gclient_utils.Error(
+ '%s is invalid, please fix. It\'s content:\n\n%s' %
+ (CODEREVIEW_SETTINGS_FILE, settings_file))
+ k, v = line.split(': ', 1)
CODEREVIEW_SETTINGS[k] = v
CODEREVIEW_SETTINGS.setdefault('__just_initialized', None)
return CODEREVIEW_SETTINGS.get(key, "")
@@ -1308,18 +1312,21 @@ def main(argv):
# Create the directories where we store information about changelists if it
# doesn't exist.
- if not os.path.exists(GetInfoDir()):
- os.mkdir(GetInfoDir())
- if not os.path.exists(GetChangesDir()):
- os.mkdir(GetChangesDir())
- if not os.path.exists(GetCacheDir()):
- os.mkdir(GetCacheDir())
-
- if command:
- return command(argv[1:])
- # Unknown command, try to pass that to svn
- return CMDpassthru(argv)
-
+ try:
+ if not os.path.exists(GetInfoDir()):
+ os.mkdir(GetInfoDir())
+ if not os.path.exists(GetChangesDir()):
+ os.mkdir(GetChangesDir())
+ if not os.path.exists(GetCacheDir()):
+ os.mkdir(GetCacheDir())
+
+ if command:
+ return command(argv[1:])
+ # Unknown command, try to pass that to svn
+ return CMDpassthru(argv)
+ except gclient_utils.Error, e:
+ print('Got an exception')
+ print(str(e))
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
« 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