ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PostMortemServer.py
Revision: 1.2
Committed: Mon Nov 19 18:01:32 2007 UTC (17 years, 5 months ago) by farinafa
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_0_3, CRAB_2_0_3_pre1
Changes since 1.1: +0 -3 lines
Log Message:
Replaced PyXML dependencies with standard xml.dom + fixed the traceback back-compatibility printout problem

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