now returns the farm id when submitting a job!

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@825 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2009-05-26 22:23:24 +00:00
parent a488d2dbb2
commit c72601322a
1 changed files with 16 additions and 1 deletions

View File

@ -1,9 +1,12 @@
#!/usr/bin/env python
import os
import subprocess
import re
#justPrintCommands = False
def cmd(cmd_str_from_user, farm_queue=False, output_head=None, just_print_commands=False, outputFile = None):
def cmd(cmd_str_from_user, farm_queue=False, output_head=None, just_print_commands=False, outputFile = None, waitID = None):
# if farm_queue is non-False, submits to queue, other
if farm_queue:
@ -17,9 +20,21 @@ def cmd(cmd_str_from_user, farm_queue=False, output_head=None, just_print_comman
cmd_str = "bsub -q "+farm_queue
if farm_stdout <> None:
cmd_str += " -o " + farm_stdout
if waitID <> None:
cmd_str += " -w \"done(%s)\"" % (str(waitID))
cmd_str += " "+cmd_str_from_user
print ">>> Farming via "+cmd_str
#result = 'Job <2542666> is submitted to queue <broad>.'
result = subprocess.Popen([cmd_str, ""], shell=True, stdout=subprocess.PIPE).communicate()[0]
p = re.compile('Job <(\d+)> is submitted to queue')
jobid = p.match(result).group(1)
return jobid
else:
cmd_str = cmd_str_from_user
print ">>> Executing "+cmd_str