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

Unified Diff: prebuilt.py

Issue 6261013: Update prebuilt.py to handle files not existing. Add a unittest to test the case (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils@master
Patch Set: Created 9 years, 11 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 | prebuilt_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: prebuilt.py
diff --git a/prebuilt.py b/prebuilt.py
index 01f3d331ec8b37cde1773d6a3f6459ab89fb39b1..799253c8cf772cd890eac4008d8a49cb6be158c1 100755
--- a/prebuilt.py
+++ b/prebuilt.py
@@ -92,7 +92,10 @@ def UpdateLocalFile(filename, value, key='PORTAGE_BINHOST'):
value: Value to write with the key.
key: The variable key to update. (Default: PORTAGE_BINHOST)
"""
- file_fh = open(filename)
+ if os.path.exists(filename):
+ file_fh = open(filename)
+ else:
+ file_fh = open(filename, 'w+')
file_lines = []
found = False
keyval_str = '%(key)s=%(value)s'
« no previous file with comments | « no previous file | prebuilt_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698