Chromium Code Reviews| Index: scripts/slave/slave_utils.py |
| =================================================================== |
| --- scripts/slave/slave_utils.py (revision 132348) |
| +++ scripts/slave/slave_utils.py (working copy) |
| @@ -5,6 +5,8 @@ |
| """Functions specific to build slaves, shared by several buildbot scripts. |
| """ |
| +import datetime |
| +import glob |
| import inspect |
| import os |
| import re |
| @@ -491,6 +493,28 @@ |
| # Don't fail. |
| +def RemoveOldSnapshots(dir): |
| + """Removes ChromiumSnapshot files more than one day old. Such snapshots are |
| + created when certain tests timeout (e.g., Chrome Frame integration tests).""" |
| + # Compute the file prefix of a snapshot created one day ago. |
| + yesterday = datetime.datetime.now() - datetime.timedelta(1) |
| + old_snapshot = 'ChromiumSnapshot%04d%02d%02d%02d%02d%02d' % \ |
|
Marc-Antoine Ruel (Google)
2012/04/14 23:43:55
style nit: I prefer () to \
also we don't put whi
grt (UTC plus 2)
2012/04/17 17:17:24
Thanks, done.
|
| + ( yesterday.year, yesterday.month, yesterday.day, yesterday.hour, |
| + yesterday.minute, yesterday.second ) |
| + # Collect snapshots at least as old as that one created a day ago. |
| + to_delete = [] |
| + for snapshot in glob.iglob(os.path.join(dir, 'ChromiumSnapshot*.png')): |
| + if os.path.basename(snapshot) < old_snapshot: |
| + to_delete.append(snapshot) |
| + # Delete the collected snapshots. |
| + for snapshot in to_delete: |
| + print "Removing old snapshot: %s" % snapshot |
| + try: |
| + os.remove(snapshot) |
| + except OSError, e: |
| + print >> sys.stderr, e |
| + |
| + |
| def RemoveChromeDesktopFiles(): |
| """Removes Chrome files (i.e. shortcuts) from the desktop of the current user. |
| This does nothing if called on a non-Windows platform.""" |
| @@ -498,6 +522,7 @@ |
| desktop_path = os.environ['USERPROFILE'] |
| desktop_path = os.path.join(desktop_path, 'Desktop') |
| LogAndRemoveFiles(desktop_path, '^(Chromium|chrome) \(.+\)?\.lnk$') |
| + RemoveOldSnapshots(desktop_path) |
| def RemoveChromeTemporaryFiles(): |