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 |
|
|
import xml.dom.minidom
|
11 |
|
|
import xml.dom.ext
|
12 |
|
|
import TaskDB
|
13 |
|
|
|
14 |
|
|
class StatusServer(Actor):
|
15 |
|
|
|
16 |
|
|
def __init__(self, cfg_params,):
|
17 |
|
|
self.cfg_params = cfg_params
|
18 |
|
|
return
|
19 |
|
|
|
20 |
|
|
def run(self):
|
21 |
|
|
"""
|
22 |
|
|
The main method of the class: check the status of the task
|
23 |
|
|
"""
|
24 |
|
|
common.logger.debug(5, "status server::run() called")
|
25 |
|
|
start = time.time()
|
26 |
|
|
|
27 |
|
|
totalCreatedJobs = 0
|
28 |
|
|
flagSubmit = 1
|
29 |
|
|
for nj in range(common.jobDB.nJobs()):
|
30 |
|
|
if (common.jobDB.status(nj)!='S'):
|
31 |
|
|
totalCreatedJobs +=1
|
32 |
|
|
flagSubmit = 0
|
33 |
|
|
|
34 |
|
|
if not flagSubmit:
|
35 |
|
|
common.logger.message("Not all jobs are submitted: before checking the status submit all the jobs.")
|
36 |
|
|
return
|
37 |
|
|
|
38 |
|
|
server_name = self.cfg_params['CRAB.server_name'] # gsiftp://pcpg01.cern.ch/data/SEDir/
|
39 |
|
|
|
40 |
|
|
common.scheduler.checkProxy()
|
41 |
|
|
|
42 |
|
|
common.taskDB.load()
|
43 |
|
|
WorkDirName =os.path.basename(os.path.split(common.work_space.topDir())[0])
|
44 |
|
|
projectUniqName = 'crab_'+str(WorkDirName)+'_'+common.taskDB.dict('TasKUUID')
|
45 |
|
|
try:
|
46 |
|
|
common.logger.message ("Checking the status...\n")
|
47 |
|
|
cmd = 'lcg-cp --vo cms gsiftp://' + str(server_name) + str(projectUniqName)+'/res/xmlReportFile.xml file://'+common.work_space.resDir()+'xmlReportFile.xml'
|
48 |
|
|
os.system(cmd +' >& /dev/null')
|
49 |
|
|
|
50 |
|
|
except:
|
51 |
|
|
msg = ("task status not yet available")
|
52 |
|
|
raise CrabException(msg)
|
53 |
|
|
|
54 |
|
|
try:
|
55 |
|
|
file = open(common.work_space.resDir()+"xmlReportFile.xml", "r")
|
56 |
|
|
doc = xml.dom.minidom.parse(common.work_space.resDir()+ "xmlReportFile.xml" )
|
57 |
|
|
|
58 |
|
|
except:
|
59 |
|
|
msg = ("problems reading report file")
|
60 |
|
|
raise CrabException(msg)
|
61 |
|
|
|
62 |
|
|
task = doc.childNodes[0].childNodes[1].getAttribute("taskName")
|
63 |
|
|
success =str(doc.childNodes[0].childNodes[3].getAttribute("count"))
|
64 |
|
|
failed = str(doc.childNodes[0].childNodes[5].getAttribute("count"))
|
65 |
|
|
progress = str(doc.childNodes[0].childNodes[7].getAttribute("count"))
|
66 |
|
|
totJob =-1
|
67 |
|
|
try:
|
68 |
|
|
totJob = int(success)+ int(failed) +int(progress)
|
69 |
|
|
except:
|
70 |
|
|
pass
|
71 |
|
|
|
72 |
|
|
common.logger.message('This is a preliminary command line implementation for the status check\n')
|
73 |
|
|
if (totJob>=0):
|
74 |
|
|
msg = '**** Total number of jobs = '+str(totJob)
|
75 |
|
|
msg +='\n\n **** Jobs finished with success = '+str(success)
|
76 |
|
|
msg +='\n **** Jobs failed = '+str(failed)
|
77 |
|
|
msg +='\n **** Jobs running = '+str(progress)+'\n'
|
78 |
|
|
common.logger.message ( msg )
|
79 |
|
|
elif progress == "all":
|
80 |
|
|
common.logger.message ('**** The task '+str(task)+' is under management on the server.\n' )
|
81 |
|
|
elif failed == "all":
|
82 |
|
|
common.logger.message ('**** The task '+str(task)+' is failed.\n' )
|
83 |
|
|
elif success == "all":
|
84 |
|
|
common.logger.message ('**** The task '+str(task)+' is ended.\n' )
|
85 |
|
|
else:
|
86 |
|
|
common.logger.message ('**** The status of the task '+str(task)+' is not known.\n' )
|
87 |
|
|
|
88 |
|
|
return
|
89 |
|
|
|