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

Side by Side Diff: tools/determinism/create_diffs_tarball.py

Issue 2547473002: Script to create tarball of differences. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | 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
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 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 """Create tarball of differences."""
7
8 import argparse
9 import json
10 import os
11 import shutil
12 import sys
13 import tarfile
14 import tempfile
15
16
17 def CreateArchive(first, second, input_files, output_file):
18 """Create archive of input files to output_dir.
19
20 Args:
21 first: the first build directory.
22 second: the second build directory.
23 input_files: list of input files to be archived.
24 output_file: an output file.
25 """
26 with tarfile.open(name=output_file, mode='w:gz') as tf:
27 for f in input_files:
28 tf.add(os.path.join(first, f))
29 tf.add(os.path.join(second, f))
30
31
32 def main():
33 parser = argparse.ArgumentParser()
34 parser.add_argument('-f', '--first-build-dir',
35 help='The first build directory')
36 parser.add_argument('-s', '--second-build-dir',
37 help='The second build directory')
38 parser.add_argument('--json-input',
39 help='JSON file to specify list of files to archive.')
40 parser.add_argument('--output', help='output filename.')
41 args = parser.parse_args()
42
43 if not args.first_build_dir:
44 parser.error('--first-build-dir is required')
45 if not args.second_build_dir:
46 parser.error('--second-build-dir is required')
47 if not args.json_input:
48 parser.error('--json-input is required')
49 if not args.output:
50 parser.error('--output is required')
51
52 with open(args.json_input) as f:
53 input_files = json.load(f)
54
55 CreateArchive(args.first_build_dir, args.second_build_dir, input_files,
56 args.output)
57
58
59 if __name__ == '__main__':
60 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698