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

Side by Side Diff: scripts/slave/slave_utils.py

Issue 9972002: Delete snapshots more than a day old. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/build/
Patch Set: Created 8 years, 8 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
« 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Functions specific to build slaves, shared by several buildbot scripts. 5 """Functions specific to build slaves, shared by several buildbot scripts.
6 """ 6 """
7 7
8 import datetime
9 import glob
8 import inspect 10 import inspect
9 import os 11 import os
10 import re 12 import re
11 import socket 13 import socket
12 import sys 14 import sys
13 import tempfile 15 import tempfile
14 import time 16 import time
15 17
16 from common import chromium_utils 18 from common import chromium_utils
17 from slave import xvfb 19 from slave import xvfb
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 os.remove(full_path) 486 os.remove(full_path)
485 elif os.path.isdir(full_path): 487 elif os.path.isdir(full_path):
486 chromium_utils.RemoveDirectory(full_path) 488 chromium_utils.RemoveDirectory(full_path)
487 else: 489 else:
488 print "Temp item wasn't a file or directory?" 490 print "Temp item wasn't a file or directory?"
489 except OSError, e: 491 except OSError, e:
490 print >> sys.stderr, e 492 print >> sys.stderr, e
491 # Don't fail. 493 # Don't fail.
492 494
493 495
496 def RemoveOldSnapshots(desktop):
497 """Removes ChromiumSnapshot files more than one day old. Such snapshots are
498 created when certain tests timeout (e.g., Chrome Frame integration tests)."""
499 # Compute the file prefix of a snapshot created one day ago.
500 yesterday = datetime.datetime.now() - datetime.timedelta(1)
501 old_snapshot = yesterday.strftime('ChromiumSnapshot%Y%m%d%H%M%S')
502 # Collect snapshots at least as old as that one created a day ago.
503 to_delete = []
504 for snapshot in glob.iglob(os.path.join(desktop, 'ChromiumSnapshot*.png')):
505 if os.path.basename(snapshot) < old_snapshot:
506 to_delete.append(snapshot)
507 # Delete the collected snapshots.
508 for snapshot in to_delete:
509 print "Removing old snapshot: %s" % snapshot
510 try:
511 os.remove(snapshot)
512 except OSError, e:
513 print >> sys.stderr, e
514
515
494 def RemoveChromeDesktopFiles(): 516 def RemoveChromeDesktopFiles():
495 """Removes Chrome files (i.e. shortcuts) from the desktop of the current user. 517 """Removes Chrome files (i.e. shortcuts) from the desktop of the current user.
496 This does nothing if called on a non-Windows platform.""" 518 This does nothing if called on a non-Windows platform."""
497 if chromium_utils.IsWindows(): 519 if chromium_utils.IsWindows():
498 desktop_path = os.environ['USERPROFILE'] 520 desktop_path = os.environ['USERPROFILE']
499 desktop_path = os.path.join(desktop_path, 'Desktop') 521 desktop_path = os.path.join(desktop_path, 'Desktop')
500 LogAndRemoveFiles(desktop_path, '^(Chromium|chrome) \(.+\)?\.lnk$') 522 LogAndRemoveFiles(desktop_path, '^(Chromium|chrome) \(.+\)?\.lnk$')
523 RemoveOldSnapshots(desktop_path)
501 524
502 525
503 def RemoveChromeTemporaryFiles(): 526 def RemoveChromeTemporaryFiles():
504 """A large hammer to nuke what could be leaked files from unittests or 527 """A large hammer to nuke what could be leaked files from unittests or
505 files left from a unittest that crashed, was killed, etc.""" 528 files left from a unittest that crashed, was killed, etc."""
506 # NOTE: print out what is cleaned up so the bots don't timeout if 529 # NOTE: print out what is cleaned up so the bots don't timeout if
507 # there is a lot to cleanup and also se we see the leaks in the 530 # there is a lot to cleanup and also se we see the leaks in the
508 # build logs. 531 # build logs.
509 # At some point a leading dot got added, support with and without it. 532 # At some point a leading dot got added, support with and without it.
510 kLogRegex = '^\.?(com\.google\.Chrome|org\.chromium)\.' 533 kLogRegex = '^\.?(com\.google\.Chrome|org\.chromium)\.'
(...skipping 15 matching lines...) Expand all
526 if ns_temp_dir: 549 if ns_temp_dir:
527 LogAndRemoveFiles(ns_temp_dir, kLogRegex) 550 LogAndRemoveFiles(ns_temp_dir, kLogRegex)
528 for i in ('Chromium', 'Google Chrome'): 551 for i in ('Chromium', 'Google Chrome'):
529 # Remove dumps. 552 # Remove dumps.
530 crash_path = '%s/Library/Application Support/%s/Crash Reports' % ( 553 crash_path = '%s/Library/Application Support/%s/Crash Reports' % (
531 os.environ['HOME'], i) 554 os.environ['HOME'], i)
532 LogAndRemoveFiles(crash_path, r'^.+\.dmp$') 555 LogAndRemoveFiles(crash_path, r'^.+\.dmp$')
533 else: 556 else:
534 raise NotImplementedError( 557 raise NotImplementedError(
535 'Platform "%s" is not currently supported.' % sys.platform) 558 'Platform "%s" is not currently supported.' % sys.platform)
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