Skip to content

Instantly share code, notes, and snippets.

@ShaiberAlon
Created March 30, 2016 22:15
Show Gist options
  • Save ShaiberAlon/cce3329288a905ec856b52e6586b8e2b to your computer and use it in GitHub Desktop.
Save ShaiberAlon/cce3329288a905ec856b52e6586b8e2b to your computer and use it in GitHub Desktop.
waits for certain batch to finish before executing the next command (Copied from Meren)
import os
import sys
import time
import xml.dom.minidom
import string
import getpass
def still_running(job_name, job_owner):
f=os.popen('qstat -u \* -xml -r')
dom=xml.dom.minidom.parse(f)
jobs = dom.getElementsByTagName('job_info')
run = jobs[0]
joblist = run.getElementsByTagName('job_list')
for r in joblist:
job = r.getElementsByTagName('JB_name')[0].childNodes[0].data
owner = r.getElementsByTagName('JB_owner')[0].childNodes[0].data
if job == job_name and owner == job_owner:
return True
return False
job_owner = getpass.getuser()
job_name = sys.argv[1]
counter = 0
while still_running(job_name, job_owner):
time.sleep(5)
counter += 1
if counter == 11:
sys.stderr.write('.')
counter = 0
sys.stderr.write('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment