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

Side by Side Diff: testing/chromoting/download_test_files.py

Issue 1231663003: Add functionality to download files from GCS, and include them in the Chromoting isolate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/python
2 #
3 """A script to download files required for Remoting integration tests from GCS.
4
5 The script expects 2 parameters:
6
7 input_files: a file containing the full path in GCS to each file that is to
8 be downloaded.
9 output_folder: the folder to which the specified files should be downloaded.
10
11 This scripts expects that its execution is done on a machine where the
12 credentials are correctly setup to obtain the required permissions for
13 downloading files from the specified GCS buckets.
14 """
15
16 import argparse
17 import ntpath
18 import os
19 import subprocess
20 import sys
21
22
23 def CopyFromGCS(source, destination):
24 """Given path to a source file in GCS, copies it to the specified destination.
25
26 Assumes gsutil is accessible from command-shell (i.e., is in $PATH), and
27 required privileges to access GCS are available.
28
29 Args:
30 source: path to file in GCS.
joedow 2015/07/13 19:10:12 nit: capitalize first letter of the first word.
anandc 2015/07/14 01:03:07 Acknowledged.
31 destination: path to destination on local file system.
32 Returns:
33 True on success, False on failure.
34 """
35
36 cp_cmd = ['gsutil cp %s %s' % (source, destination)]
37 process = subprocess.Popen(cp_cmd, shell=True,
38 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
39 process.communicate()
40 if not process.returncode:
41 return True
42 return False
joedow 2015/07/13 19:10:12 Is it pythonic to just use: return (not process.re
anandc 2015/07/14 01:03:07 Got rid of this function because it wasn't really
43
44
45 def main():
46
47 parser = argparse.ArgumentParser()
48 parser.add_argument('-i', '--input_files',
49 help='File specifying files to be downloaded .')
50 parser.add_argument(
51 '-o', '--output_folder',
52 help='Folder where specified files should be downloaded .')
53
54 if len(sys.argv) < 3:
55 parser.print_help()
56 sys.exit(1)
57
58 args = parser.parse_args()
59 if not args.input_files or not args.output_folder:
60 parser.print_help()
61 sys.exit(1)
62
63 with open(args.input_files) as f:
64 for line in f:
65 output_file = os.path.join(args.output_folder, ntpath.basename(line))
66 CopyFromGCS(line, output_file)
67
68 if __name__ == '__main__':
69 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698