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

Side by Side Diff: bootstrap/remove_orphaned_pycs.py

Issue 1200843003: Added virtualenv for depot_tools (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix on Windows Created 5 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2014 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 import logging
7 import os
8 import sys
9
10
11 def main(argv):
12 logging.basicConfig(level=logging.DEBUG)
13 if len(argv) == 0:
14 bootstrap_dir = os.path.dirname(os.path.abspath(__file__))
15 infra_dir = os.path.dirname(bootstrap_dir)
16 argv = [infra_dir]
17
18 for root in argv:
19 # This could take an argument, except gclient DEPS has no good way to pass
20 # us an argument, and gclient getcwd() is ../ from our .gclient file. :(
21 logging.debug("Cleaning orphaned *.pyc files from: %s" % root)
22
23 for (dirpath, _, filenames) in os.walk(root):
24 fnset = set(filenames)
25 for filename in filenames:
26 if filename.endswith(".pyc") and filename[:-1] not in fnset:
27 path = os.path.join(dirpath, filename)
28 logging.info("Deleting orphan *.pyc file: %s" % path)
29 os.remove(path)
30
31
32 if __name__ == '__main__':
33 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698