Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: ensure_dependencies.py

Issue 29360030: Issue 4581 - Update buildtools dependency (Closed)
Patch Set: Include ensure_dependencies.py change Created Oct. 28, 2016, 6:38 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dependencies ('k') | 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/env python 1 #!/usr/bin/env python
2 2
3 # This Source Code Form is subject to the terms of the Mozilla Public 3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 6
7 import sys 7 import sys
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 handle.write(sourcedata) 348 handle.write(sourcedata)
349 if __name__ == '__main__': 349 if __name__ == '__main__':
350 logging.info('Restarting %s' % target) 350 logging.info('Restarting %s' % target)
351 os.execv(sys.executable, [sys.executable, target] + sys.argv[1:] ) 351 os.execv(sys.executable, [sys.executable, target] + sys.argv[1:] )
352 else: 352 else:
353 logging.warning('Cannot restart %s automatically, please rerun' % target) 353 logging.warning('Cannot restart %s automatically, please rerun' % target)
354 354
355 355
356 def _ensure_line_exists(path, pattern): 356 def _ensure_line_exists(path, pattern):
357 with open(path, 'a+') as f: 357 with open(path, 'a+') as f:
358 f.seek(0, os.SEEK_SET)
358 file_content = [l.strip() for l in f.readlines()] 359 file_content = [l.strip() for l in f.readlines()]
359 if not pattern in file_content: 360 if not pattern in file_content:
360 file_content.append(pattern) 361 file_content.append(pattern)
361 f.seek(0, os.SEEK_SET) 362 f.seek(0, os.SEEK_SET)
362 f.truncate() 363 f.truncate()
363 for l in file_content: 364 for l in file_content:
364 print >>f, l 365 print >>f, l
365 366
366 if __name__ == '__main__': 367 if __name__ == '__main__':
367 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) 368 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
368 369
369 parser = argparse.ArgumentParser(description='Verify dependencies for a set of repositories, by default the repository of this script.') 370 parser = argparse.ArgumentParser(description='Verify dependencies for a set of repositories, by default the repository of this script.')
370 parser.add_argument('repos', metavar='repository', type=str, nargs='*', help ='Repository path') 371 parser.add_argument('repos', metavar='repository', type=str, nargs='*', help ='Repository path')
371 parser.add_argument('-q', '--quiet', action='store_true', help='Suppress inf ormational output') 372 parser.add_argument('-q', '--quiet', action='store_true', help='Suppress inf ormational output')
372 args = parser.parse_args() 373 args = parser.parse_args()
373 374
374 if args.quiet: 375 if args.quiet:
375 logging.disable(logging.INFO) 376 logging.disable(logging.INFO)
376 377
377 repos = args.repos 378 repos = args.repos
378 if not len(repos): 379 if not len(repos):
379 repos = [os.path.dirname(__file__)] 380 repos = [os.path.dirname(__file__)]
380 for repo in repos: 381 for repo in repos:
381 resolve_deps(repo) 382 resolve_deps(repo)
OLDNEW
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld