ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/CacheCleaner.py
Revision: 1.3
Committed: Sun Feb 21 12:56:29 2010 UTC (15 years, 2 months ago) by spiga
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_9_1, CRAB_2_9_1_pre2, CRAB_2_9_1_pre1, CRAB_2_9_0, CRAB_2_9_0_pre2, CRAB_2_9_0_pre1, CRAB_2_8_8, CRAB_2_8_8_pre1, CRAB_2_8_7_patch3, CRAB_2_8_7_patch2, CRAB_2_8_7_patch1, CRAB_2_8_7, CRAB_2_8_7_pre2, CRAB_2_8_7_pre1, CRAB_2_8_6, CRAB_2_8_6_pre1, CRAB_2_8_5_patch3, CRAB_2_8_5_patch2, CRAB_2_8_5_patch1, CRAB_2_8_5, CRAB_2_8_5_pre5, CRAB_2_8_5_pre4, CRAB_2_8_5_pre3, CRAB_2_8_4_patch3, CRAB_2_8_5_pre2, CRAB_2_8_4_patch2, CRAB_2_8_5_pre1, CRAB_2_8_4_patch1, CRAB_2_8_4, CRAB_2_8_4_pre5, CRAB_2_8_4_pre4, CRAB_2_8_4_pre3, CRAB_2_8_4_pre2, CRAB_2_8_4_pre1, CRAB_2_8_3, CRAB_2_8_3_pre4, CRAB_2_8_3_pre3, CRAB_2_8_3_pre2, CRAB_2_8_3_pre1, CRAB_2_8_2_patch1, CRAB_2_8_2, CRAB_2_8_2_pre5, CRAB_2_8_2_pre4, CRAB_2_8_2_pre3, CRAB_2_8_2_pre2, CRAB_2_8_2_pre1, CRAB_2_8_1, CRAB_2_8_0, CRAB_2_8_0_pre1, CRAB_2_7_10_pre3, CRAB_2_7_9_patch2_pre1, CRAB_2_7_10_pre2, CRAB_2_7_10_pre1, CRAB_2_7_9_patch1, CRAB_2_7_9, CRAB_2_7_9_pre5, CRAB_2_7_9_pre4, CRAB_2_7_9_pre3, CRAB_2_7_9_pre2, CRAB_2_7_8_patch2, CRAB_2_7_9_pre1, CRAB_2_7_8_patch2_pre1, CRAB_2_7_8_patch1, CRAB_2_7_8_patch1_pre1, CRAB_2_7_8, CRAB_2_7_8_pre3, CRAB_2_7_8_pre2, CRAB_2_7_8_dash3, CRAB_2_7_8_dash2, CRAB_2_7_8_dash, CRAB_2_7_7_patch1, CRAB_2_7_7_patch1_pre1, CRAB_2_7_8_pre1, CRAB_2_7_7, CRAB_2_7_7_pre2, CRAB_2_7_7_pre1, CRAB_2_7_6_patch1, CRAB_2_7_6, CRAB_2_7_6_pre1, CRAB_2_7_5_patch1, CRAB_2_7_5, CRAB_2_7_5_pre3, CRAB_2_7_5_pre2, CRAB_2_7_5_pre1, CRAB_2_7_4_patch1, CRAB_2_7_4, CRAB_2_7_4_pre6, CRAB_2_7_4_pre5, CRAB_2_7_4_pre4, CRAB_2_7_4_pre3, CRAB_2_7_4_pre2, CRAB_2_7_4_pre1, CRAB_2_7_3, CRAB_2_7_3_pre3, CRAB_2_7_3_pre3_beta, CRAB_2_7_3_pre2, CRAB_2_7_3_pre2_beta, CRAB_2_7_3_pre1, CRAB_2_7_3_beta3, CRAB_2_7_3_beta2, CRAB_2_7_3_beta1, CRAB_2_7_3_beta, fede_170310, CRAB_LumiMask, CRAB_2_7_lumi, HEAD
Branch point for: CRAB_multiout
Changes since 1.2: +31 -2 lines
Log Message:
from 2_7_1_branch

File Contents

# User Rev Content
1 calloni 1.1 from Actor import *
2     import common
3     import string, os, time, sys, glob
4     from crab_util import *
5     import traceback
6     #from ServerCommunicator import ServerCommunicator
7    
8     class CacheCleaner(Actor):
9     def __init__(self):
10     """
11     A class to clean:
12     - SiteDB cache
13 spiga 1.2 - Crab cache
14 calloni 1.1 """
15     return
16    
17     def run(self):
18     common.logger.debug("CacheCleaner::run() called")
19     try:
20 spiga 1.3 sitedbCache= self.findSiteDBcache()
21     # sitedbCache= '%s/.cms_sitedbcache'%os.getenv('HOME')
22 spiga 1.2 if os.path.isdir(sitedbCache):
23     cmd = 'rm -f %s/*'%sitedbCache
24 calloni 1.1 cmd_out = runCommand(cmd)
25 spiga 1.2 common.logger.info('%s Cleaned.'%sitedbCache)
26 calloni 1.1 else:
27 spiga 1.2 common.logger.info('%s not found'%sitedbCache)
28     except Exception, e:
29     common.logger.debug("WARNING: Problem cleaning the SiteDB cache.")
30     common.logger.debug( str(e))
31     common.logger.debug( traceback.format_exc() )
32 calloni 1.1
33 spiga 1.2 # Crab cache
34     try:
35 spiga 1.3 crabCache= self.findCRABcache()
36     # crabCache= '%s/.cms_crab'%os.getenv('HOME')
37 spiga 1.2 if os.path.isdir(crabCache):
38     cmd = 'rm -f %s/*'%crabCache
39 calloni 1.1 cmd_out = runCommand(cmd)
40 spiga 1.2 common.logger.info('%s Cleaned.'%crabCache)
41 calloni 1.1 else:
42 spiga 1.2 common.logger.debug('%s not found'%crabCache)
43 calloni 1.1 except Exception, e:
44     common.logger.debug("WARNING: Problem cleaning the cache.")
45     common.logger.debug( str(e))
46     common.logger.debug( traceback.format_exc() )
47 spiga 1.2 return
48 spiga 1.3
49     def findSiteDBcache(self):
50    
51     sitedbCache = None
52    
53     if os.getenv('CMS_SITEDB_CACHE_DIR'):
54     sitedbCache = os.getenv('CMS_SITEDB_CACHE_DIR') + '/.cms_sitedbcache'
55     elif os.getenv('HOME'):
56     sitedbCache = os.getenv('HOME') + '/.cms_sitedbcache'
57     else:
58     sitedbCache = '/tmp/sitedbjson_' + pwd.getpwuid(os.getuid())[0]
59    
60     return sitedbCache
61    
62    
63     def findCRABcache(self):
64    
65     crabCache = None
66    
67     if os.getenv('CMS_CRAB_CACHE_DIR'):
68     crabCache ='%s/.cms_crab'%os.getenv('CMS_CRAB_CACHE_DIR')
69     elif os.getenv('HOME'):
70     crabCache ='%s/.cms_crab'%os.getenv('HOME')
71     else:
72     crabCache = '/tmp/crab_cache_' + pwd.getpwuid(os.getuid())[0]
73    
74     return crabCache