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