All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
python.batchstatus.BatchStatus Class Reference

Public Member Functions

def __init__
 
def update
 
def get_stage_status
 

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

Member Function Documentation

def python.batchstatus.BatchStatus.get_jobs ( )
static

Definition at line 121 of file batchstatus.py.

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

Definition at line 129 of file batchstatus.py.

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

Definition at line 55 of file batchstatus.py.

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

Definition at line 97 of file batchstatus.py.

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

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: