Main Page
Namespaces
Classes
Package Documentation
CVS Directory
WorkBook
Offline Guide
Release schedule
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
CalibMuon
DTCalibration
python
Workflow
CrabWatch.py
Go to the documentation of this file.
1
#from CrabTask import CrabTask
2
from
crabWrap
import
crabStatus,convertStatus,getOutput
3
import
os,time
4
from
threading
import
Thread,Lock,Event
5
6
class
CrabWatch
(Thread):
7
#def __init__(self, task):
8
# Thread.__init__(self)
9
# self.task = task
10
def
__init__
(self, project, action = getOutput):
11
Thread.__init__(self)
12
self.
project
= project
13
self.
action
= action
14
self.
threshold
= 100.0
15
16
self.
lock
= Lock()
17
self.
finish
= Event()
18
19
def
setThreshold
(self,threshold):
20
self.
threshold
= float(threshold)
21
22
def
run
(self):
23
exit =
False
24
while
not
exit:
25
#if checkStatus(self.project,80.0): break
26
status =
crabStatus
(self.
project
)
27
statusNew =
convertStatus
(status)
28
print
"Relative percentage finished: %.0f%%"
% statusNew[
'Finished'
]
29
print
"Relative percentage failed : %.0f%%"
% statusNew[
'Failed'
]
30
print
"Relative percentage running : %.0f%%"
% statusNew[
'Running'
]
31
if
statusNew[
'Failed'
] > 50.0:
raise
RuntimeError,
'Too many jobs have failed (%.0f%%).'
% statusNew[
'Failed'
]
32
if
statusNew[
'Finished'
] >= self.
threshold
:
break
33
34
self.lock.acquire()
35
if
self.finish.isSet(): exit =
True
36
self.lock.release()
37
38
if
not
exit: time.sleep(180)
39
40
print
"Finished..."
41
42
if
self.
action
: self.
action
(self.
project
)
43
44
if
__name__ ==
'__main__'
:
45
46
project =
None
47
import
sys
48
for
opt
in
sys.argv:
49
if
opt[:8] ==
'project='
:
50
project = opt[8:]
51
52
if
not
project:
raise
ValueError,
'Need to set project'
53
54
crab =
CrabWatch
(project)
55
crab.start()
CrabWatch.CrabWatch.lock
lock
Definition:
CrabWatch.py:16
CrabWatch.CrabWatch.action
action
Definition:
CrabWatch.py:13
CrabWatch.CrabWatch.project
project
Definition:
CrabWatch.py:12
CrabWatch.CrabWatch.threshold
threshold
Definition:
CrabWatch.py:14
CrabWatch.CrabWatch.setThreshold
def setThreshold
Definition:
CrabWatch.py:19
crabWrap.convertStatus
def convertStatus
Definition:
crabWrap.py:174
CrabWatch.CrabWatch.__init__
def __init__
Definition:
CrabWatch.py:10
crabWrap.crabStatus
def crabStatus
Definition:
crabWrap.py:157
CrabWatch.CrabWatch.finish
finish
Definition:
CrabWatch.py:17
CrabWatch.CrabWatch
Definition:
CrabWatch.py:6
CrabWatch.CrabWatch.run
def run
Definition:
CrabWatch.py:22
Generated for CMSSW Reference Manual by
1.8.5