Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import optparse | |
| 6 import os | |
| 7 import shutil | |
| 8 import sys | |
| 9 | |
| 10 | |
| 11 def CleanUpOldVersions(path_to_app, keep_version, stamp_path): | |
| 12 versions_dir = os.path.join(path_to_app, 'Contents', 'Versions') | |
| 13 for version in os.listdir(versions_dir): | |
| 14 if version != keep_version: | |
| 15 shutil.rmtree(os.path.join(versions_dir, version)) | |
| 16 | |
| 17 open(stamp_path, 'w').close() | |
|
Mark Mentovai
2016/07/25 18:13:46
You should also call os.utime(stamp_path, None) to
Robert Sesek
2016/07/25 18:21:41
Done.
| |
| 18 | |
| 19 | |
| 20 def Main(): | |
| 21 parser = optparse.OptionParser( | |
| 22 usage='%prog path/to/Chromium.app keep_version stamp_path') | |
| 23 opts, args = parser.parse_args() | |
| 24 if len(args) != 3: | |
| 25 parser.error('missing arguments') | |
| 26 return 1 | |
| 27 | |
| 28 CleanUpOldVersions(*args) | |
| 29 return 0 | |
| 30 | |
| 31 if __name__ == '__main__': | |
| 32 sys.exit(Main()) | |
| OLD | NEW |