def _parse_qstat_state(qstat_out, job_id):
 if (qstat_out.strip() == ''):
  return 'u'
 lines = qstat_out.split('\n')
 while (not lines.pop(0).startswith('---')):
  pass
 for line in lines:
  if line:
   (job, prior, name, user, state) = line.strip().split()[0:5]
   if (int(job) == int(job_id)):
    return state
 return 'u'

def _parse_qstat_state ( qstat_out , job_id ) : if ( qstat_out . strip ( ) == '' ) : return 'u' lines = qstat_out . split ( '\n' ) while ( not lines . pop ( 0 ) . startswith ( '---' ) ) : pass for line in lines : if line : ( job , prior , name , user , state ) = line . strip ( ) . split ( ) [ 0 : 5 ] if ( int ( job ) == int ( job_id ) ) : return state return 'u'
parse "state" column from qstat output for given job_id returns state for the *first* job matching job_id .