Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
python.batchstatus.BatchStatus Class Reference

Public Member Functions

def __init__ (self, projects)
 
def update (self, projects)
 
def get_stage_status (self, stagename)
 

Static Public Member Functions

def update_jobs ()
 
def get_jobs ()
 

Public Attributes

 projects
 
 stage_stats
 

Detailed Description

Definition at line 32 of file batchstatus.py.

Constructor & Destructor Documentation

def python.batchstatus.BatchStatus.__init__ (   self,
  projects 
)

Definition at line 36 of file batchstatus.py.

36  def __init__(self, projects):
37 
38  # Initialize attributes.
39 
40  self.projects = projects
41 
42  # The status for each stage is a 4-tuple of integers consisting
43  # of the following values.
44  # 1. Number of idle batch jobs (state 'I')
45  # 2. Number of running batch jobs (state 'R')
46  # 3. Number of held batch jobs (state 'H')
47  # 4. Number of batch jobs in any other stage.
48 
49  self.stage_stats = {}
50  self.update(projects)
51 
52 
def update(self, projects)
Definition: batchstatus.py:55
def __init__(self, projects)
Definition: batchstatus.py:36

Member Function Documentation

def python.batchstatus.BatchStatus.get_jobs ( )
static

Definition at line 121 of file batchstatus.py.

121  def get_jobs():
122 
123  global jobs
124  return jobs
125 
def python.batchstatus.BatchStatus.get_stage_status (   self,
  stagename 
)

Definition at line 129 of file batchstatus.py.

129  def get_stage_status(self, stagename):
130  return self.stage_stats[stagename]
def python.batchstatus.BatchStatus.update (   self,
  projects 
)

Definition at line 55 of file batchstatus.py.

55  def update(self, projects):
56 
57  global jobs, server
58 
59  for project in projects:
60  if project.server != '-' and project.server != '':
61  server = project.server
62  for stage in project.stages:
63  self.stage_stats[stage.name] = [0, 0, 0, 0]
64 
65  # Get information from the batch system.
66 
67  if jobs == None:
68  BatchStatus.update_jobs()
69  for job in jobs:
70  words = job.split()
71  if len(words) > 4:
72  state = words[-4]
73  script = words[-1]
74 
75  # Loop over stages.
76 
77  for project in projects:
78  for stage in project.stages:
79  workscript = '%s-%s-%s.sh' % (stage.name, project.name, project.release_tag)
80  if script.find(workscript) == 0:
81  if state == 'I':
82  self.stage_stats[stage.name][0] = \
83  self.stage_stats[stage.name][0] + 1
84  elif state == 'R':
85  self.stage_stats[stage.name][1] = \
86  self.stage_stats[stage.name][1] + 1
87  elif state == 'H':
88  self.stage_stats[stage.name][2] = \
89  self.stage_stats[stage.name][2] + 1
90  else:
91  self.stage_stats[stage.name][3] = \
92  self.stage_stats[stage.name][3] + 1
93 
def update(self, projects)
Definition: batchstatus.py:55
def python.batchstatus.BatchStatus.update_jobs ( )
static

Definition at line 97 of file batchstatus.py.

97  def update_jobs():
98 
99  global jobs, server
100 
101  command = ['jobsub_q']
102  if server != None:
103  command.append('--jobsub-server=%s' % server)
104  command.append('--group=%s' % project_utilities.get_experiment())
105  command.append('--user=%s' % project_utilities.get_user())
106  command.append('--role=%s' % project_utilities.get_role())
107  jobinfo = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
108  jobout, joberr = jobinfo.communicate()
109  jobout = convert_str(jobout)
110  joberr = convert_str(joberr)
111  rc = jobinfo.poll()
112  if rc != 0:
113  #raise JobsubError(command, rc, jobout, joberr)
114  # Simply return in case jobsub_q fails.
115  return
116  jobs = jobout.split('\n')
117 

Member Data Documentation

python.batchstatus.BatchStatus.projects

Definition at line 40 of file batchstatus.py.

python.batchstatus.BatchStatus.stage_stats

Definition at line 49 of file batchstatus.py.


The documentation for this class was generated from the following file: