ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PostMortemServer.py
Revision: 1.3
Committed: Tue Dec 11 09:05:08 2007 UTC (17 years, 4 months ago) by mcinquil
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_0_4, CRAB_2_0_4_pre2, CRAB_2_0_4_pre1
Changes since 1.2: +2 -0 lines
Log Message:
Added check and fix for server_name (path)

File Contents

# User Rev Content
1 spiga 1.1 from Actor import *
2     from crab_util import *
3     import common
4     from ApmonIf import ApmonIf
5     import Statistic
6     import time
7     from ProgressBar import ProgressBar
8     from TerminalController import TerminalController
9    
10     class PostMortemServer(Actor):
11    
12     def __init__(self, cfg_params,):
13     self.cfg_params = cfg_params
14     try:
15     self.server_name = self.cfg_params['CRAB.server_name'] # gsiftp://pcpg01.cern.ch/data/SEDir/
16 mcinquil 1.3 if not self.server_name.endswith("/"):
17     self.server_name = self.server_name + "/"
18 spiga 1.1 except KeyError:
19     msg = 'No server selected ...'
20     msg = msg + 'Please specify a server in the crab cfg file'
21     raise CrabException(msg)
22     return
23    
24     def run(self):
25     """
26     The main method of the class: retrieve the post mortem output from server
27     """
28     common.logger.debug(5, "PostMortem server::run() called")
29    
30     start = time.time()
31    
32     common.scheduler.checkProxy()
33    
34     common.taskDB.load()
35     WorkDirName =os.path.basename(os.path.split(common.work_space.topDir())[0])
36     projectUniqName = 'crab_'+str(WorkDirName)+'_'+common.taskDB.dict("TasKUUID")
37     #Need to add a check on the treashold level
38     # and on the task readness TODO
39     try:
40     ### retrieving poject from the server
41     common.logger.message("Retrieving the poject from the server...\n")
42    
43     copyHere = common.work_space.jobDir() # MATT
44    
45     cmd = 'lcg-cp --vo cms --verbose gsiftp://' + str(self.server_name) + str(projectUniqName)+'/res/failed.tgz file://'+copyHere+'failed.tgz'# MATT
46     common.logger.debug(5, cmd)
47     copyOut = os.system(cmd +' >& /dev/null')
48     except:
49     msg = ("postMortem output not yet available")
50     raise CrabException(msg)
51    
52     zipOut = "failed.tgz"
53     if os.path.exists( copyHere + zipOut ): # MATT
54     cwd = os.getcwd()
55     os.chdir( copyHere )# MATT
56     common.logger.debug( 5, 'tar -zxvf ' + zipOut )
57     cmd = 'tar -zxvf ' + zipOut
58     cmd += '; mv .tmpFailed/* .; rm -drf .tmpDone/'
59     cmd_out = runCommand(cmd)
60     os.chdir(cwd)
61     common.logger.debug( 5, 'rm -f '+copyHere+zipOut )# MATT
62     cmd = 'rm -f '+copyHere+zipOut# MATT
63     cmd_out = runCommand(cmd)
64    
65     msg='Logging info for project '+str(WorkDirName)+': \n'
66     msg+='written to '+copyHere+' \n' # MATT
67     common.logger.message(msg)
68     else:
69     common.logger.message("Logging info is not yet ready....\n")
70    
71     return
72