OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS 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 import datetime | 6 import datetime |
7 import multiprocessing | 7 import multiprocessing |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 """Update the key in file with the value passed. | 85 """Update the key in file with the value passed. |
86 File format: | 86 File format: |
87 key="value" | 87 key="value" |
88 Note quotes are added automatically | 88 Note quotes are added automatically |
89 | 89 |
90 Args: | 90 Args: |
91 filename: Name of file to modify. | 91 filename: Name of file to modify. |
92 value: Value to write with the key. | 92 value: Value to write with the key. |
93 key: The variable key to update. (Default: PORTAGE_BINHOST) | 93 key: The variable key to update. (Default: PORTAGE_BINHOST) |
94 """ | 94 """ |
95 file_fh = open(filename) | 95 if os.path.exists(filename): |
| 96 file_fh = open(filename) |
| 97 else: |
| 98 file_fh = open(filename, 'w+') |
96 file_lines = [] | 99 file_lines = [] |
97 found = False | 100 found = False |
98 keyval_str = '%(key)s=%(value)s' | 101 keyval_str = '%(key)s=%(value)s' |
99 for line in file_fh: | 102 for line in file_fh: |
100 # Strip newlines from end of line. We already add newlines below. | 103 # Strip newlines from end of line. We already add newlines below. |
101 line = line.rstrip("\n") | 104 line = line.rstrip("\n") |
102 | 105 |
103 if len(line.split('=')) != 2: | 106 if len(line.split('=')) != 2: |
104 # Skip any line that doesn't fit key=val. | 107 # Skip any line that doesn't fit key=val. |
105 file_lines.append(line) | 108 file_lines.append(line) |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 if options.board: | 542 if options.board: |
540 UploadPrebuilt(options.build_path, options.upload, version, | 543 UploadPrebuilt(options.build_path, options.upload, version, |
541 options.binhost_base_url, board=options.board, | 544 options.binhost_base_url, board=options.board, |
542 git_sync=options.git_sync, key=options.key, | 545 git_sync=options.git_sync, key=options.key, |
543 pkg_indexes=pkg_indexes, | 546 pkg_indexes=pkg_indexes, |
544 sync_binhost_conf=options.sync_binhost_conf) | 547 sync_binhost_conf=options.sync_binhost_conf) |
545 | 548 |
546 | 549 |
547 if __name__ == '__main__': | 550 if __name__ == '__main__': |
548 main() | 551 main() |
OLD | NEW |