Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 # This script runs "pub get" on a given directory and outputs the filenames of | |
|
tonyg
2015/04/08 13:52:38
This looks like a module-level docstring, """Lorem
blundell
2015/04/09 11:53:41
Done.
| |
| 7 # the files that are thus pulled in relative to that given directory. | |
|
tonyg
2015/04/08 13:52:38
I think a link to documentation would be helpful i
blundell
2015/04/09 11:53:41
Done.
| |
| 8 # | |
| 9 # The first argument should be the parent directory of the Dart SDK relative to | |
| 10 # the directory in which this script is being run. | |
| 11 # The second argument should be the directory on which to run "pub get" relative | |
| 12 # to the directory in which this script is being run. | |
| 13 | |
| 14 import os | |
| 15 import subprocess | |
| 16 import sys | |
| 17 | |
| 18 def main(args): | |
| 19 dart_sdk_root = args[0] | |
|
tonyg
2015/04/08 13:52:38
This is a nit, but I'd recommend using argparse in
blundell
2015/04/09 11:53:41
Done.
| |
| 20 target_directory = args[1] | |
| 21 cmd = [ | |
| 22 os.path.join(os.getcwd(), dart_sdk_root, "dart-sdk/bin/pub") | |
|
tonyg
2015/04/08 13:52:38
I could be mistaken, but I don't think os.getcwd()
blundell
2015/04/09 11:53:41
Done.
| |
| 23 ] | |
| 24 cmd.extend(["get"]) | |
| 25 | |
| 26 os.chdir(target_directory) | |
| 27 subprocess.check_output(cmd, shell=False, stderr=subprocess.STDOUT) | |
|
tonyg
2015/04/08 13:52:38
Cleaner to pass cwd=target_dir rather than than do
blundell
2015/04/09 11:53:41
Done.
| |
| 28 | |
| 29 for root, _, files in os.walk("packages", followlinks=True): | |
| 30 for f in files: | |
| 31 print os.path.join(root, f) | |
| 32 | |
| 33 if __name__ == '__main__': | |
| 34 sys.exit(main(sys.argv[1:])) | |
| OLD | NEW |