ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/Refresher.py
Revision: 1.2
Committed: Thu Sep 3 10:28:29 2009 UTC (15 years, 8 months ago) by calloni
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
*** empty log message ***

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 Refresher(Actor):
9     def __init__(self):
10     """
11     A class to clean:
12     - SiteDB cache
13     - CrabServer cache
14     - WMS cache
15     """
16     self.string_app = common.work_space.topDir()[0:len(common.work_space.topDir())-1]
17     self.index = string.rfind(self.string_app, "/")
18     self.submitting_dir = self.string_app[0:self.index]
19     self.username = gethnUserNameFromSiteDB()
20     self.flag = 0
21     return
22    
23     def run(self):
24     common.logger.debug("Refresher::run() called")
25     try:
26     #SiteDB cache
27     if os.path.exists(self.submitting_dir+'/SiteDBusername.conf'):
28     cmd = 'rm '+self.submitting_dir+'/SiteDBusername.conf'
29     cmd_out = runCommand(cmd)
30     self.flag = 1
31     else:
32     common.logger.debug(self.submitting_dir+'/SiteDBusername.conf'+' not found')
33    
34     if os.path.exists(self.submitting_dir+'/.cms_sitedbcache'):
35     cmd = 'rm -rf '+self.submitting_dir+'/.cms_sitedbcache'
36     cmd_out = runCommand(cmd)
37     self.flag = 1
38     else:
39     common.logger.debug(self.submitting_dir+'/.cms_sitedbcache'+' not found')
40    
41     if os.path.exists('/tmp/jsonparser_'+self.username):
42     cmd = 'rm -rf /tmp/jsonparser_'+self.username
43     cmd_out = runCommand(cmd)
44     self.flag = 1
45     else:
46     common.logger.debug('/tmp/jsonparser_'+self.username+' not found')
47    
48     #CrabServer cache and WMS cache
49     if len(glob.glob(os.path.join(self.submitting_dir,'*.conf'))) > 0:
50     cmd = 'rm -rf '+self.submitting_dir+'/*.conf'
51     cmd_out = runCommand(cmd)
52     self.flag = 1
53     else:
54     common.logger.debug(self.submitting_dir,'*.conf'+' not found')
55    
56     if self.flag == 1:
57     common.logger.info("Cache cleaned!")
58     else:
59     common.logger.info("Cache already cleaned")
60    
61     except Exception, e:
62     common.logger.debug("WARNING: Problem refreshing the cache.")
63     common.logger.debug( str(e))
64     common.logger.debug( traceback.format_exc() )
65     return