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

Side by Side Diff: tools/export_tarball/export_tarball.py

Issue 1037753002: Add --progress option to export_tarball.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium 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 """ 6 """
7 This tool creates a tarball with all the sources, but without .svn directories. 7 This tool creates a tarball with all the sources, but without .svn directories.
8 8
9 It can also remove files which are not strictly required for build, so that 9 It can also remove files which are not strictly required for build, so that
10 the resulting tarball can be reasonably small (last time it was ~110 MB). 10 the resulting tarball can be reasonably small (last time it was ~110 MB).
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 def main(argv): 127 def main(argv):
128 parser = optparse.OptionParser() 128 parser = optparse.OptionParser()
129 parser.add_option("--basename") 129 parser.add_option("--basename")
130 parser.add_option("--remove-nonessential-files", 130 parser.add_option("--remove-nonessential-files",
131 dest="remove_nonessential_files", 131 dest="remove_nonessential_files",
132 action="store_true", default=False) 132 action="store_true", default=False)
133 parser.add_option("--test-data", action="store_true") 133 parser.add_option("--test-data", action="store_true")
134 # TODO(phajdan.jr): Remove --xz option when it's not needed for compatibility. 134 # TODO(phajdan.jr): Remove --xz option when it's not needed for compatibility.
135 parser.add_option("--xz", action="store_true") 135 parser.add_option("--xz", action="store_true")
136 parser.add_option("--verbose", action="store_true", default=False) 136 parser.add_option("--verbose", action="store_true", default=False)
137 parser.add_option("--progress", action="store_true", default=False)
137 138
138 options, args = parser.parse_args(argv) 139 options, args = parser.parse_args(argv)
139 140
140 if len(args) != 1: 141 if len(args) != 1:
141 print 'You must provide only one argument: output file name' 142 print 'You must provide only one argument: output file name'
142 print '(without .tar.xz extension).' 143 print '(without .tar.xz extension).'
143 return 1 144 return 1
144 145
145 if not os.path.exists(GetSourceDirectory()): 146 if not os.path.exists(GetSourceDirectory()):
146 print 'Cannot find the src directory ' + GetSourceDirectory() 147 print 'Cannot find the src directory ' + GetSourceDirectory()
(...skipping 20 matching lines...) Expand all
167 try: 168 try:
168 if options.test_data: 169 if options.test_data:
169 for directory in TESTDIRS: 170 for directory in TESTDIRS:
170 archive.add(os.path.join(GetSourceDirectory(), directory), 171 archive.add(os.path.join(GetSourceDirectory(), directory),
171 arcname=os.path.join(output_basename, directory)) 172 arcname=os.path.join(output_basename, directory))
172 else: 173 else:
173 archive.add(GetSourceDirectory(), arcname=output_basename) 174 archive.add(GetSourceDirectory(), arcname=output_basename)
174 finally: 175 finally:
175 archive.close() 176 archive.close()
176 177
177 if subprocess.call(['xz', '-9', output_fullname]) != 0: 178 if options.progress:
179 sys.stdout.flush()
180 pv = subprocess.Popen(
181 ['pv', '--force', output_fullname],
182 stdout=subprocess.PIPE,
183 stderr=sys.stdout)
184 with open(output_fullname + '.xz', 'w') as f:
185 rc = subprocess.call(['xz', '-9', '-'], stdin=pv.stdout, stdout=f)
186 pv.wait()
187 else:
188 rc = subprocess.call(['xz', '-9', output_fullname])
189
190 if rc != 0:
178 print 'xz -9 failed!' 191 print 'xz -9 failed!'
179 return 1 192 return 1
180 193
181 return 0 194 return 0
182 195
183 196
184 if __name__ == "__main__": 197 if __name__ == "__main__":
185 sys.exit(main(sys.argv[1:])) 198 sys.exit(main(sys.argv[1:]))
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