6 |
|
import re |
7 |
|
import subprocess |
8 |
|
import signal |
9 |
+ |
import fcntl |
10 |
|
from optparse import OptionParser |
11 |
|
|
12 |
|
from OSUT3Analysis.Configuration.configurationOptions import * |
70 |
|
print dataset + "/" + arguments.skimChannel + " not in skim directory. Skipping." |
71 |
|
continue |
72 |
|
print command |
73 |
< |
output = subprocess.Popen (command.split (), stdout=subprocess.PIPE).communicate ()[0] |
74 |
< |
print output, |
73 |
> |
pid = os.getpid () |
74 |
> |
p0 = subprocess.Popen (command.split (), bufsize=1, stdout=subprocess.PIPE) |
75 |
> |
flags = fcntl.fcntl (p0.stdout.fileno (), fcntl.F_GETFL, 0) |
76 |
> |
fcntl.fcntl (p0.stdout.fileno (), fcntl.F_SETFL, flags | os.O_NONBLOCK) |
77 |
> |
output = "" |
78 |
> |
while p0.poll () is None: |
79 |
> |
try: |
80 |
> |
tmpOutput = p0.stdout.read (1024) |
81 |
> |
print tmpOutput, |
82 |
> |
output += tmpOutput |
83 |
> |
except IOError: |
84 |
> |
pass |
85 |
> |
tmpOutput = p0.stdout.read (1024) |
86 |
> |
print tmpOutput, |
87 |
> |
output += tmpOutput |
88 |
|
output = re.sub (r"[\f\n\r]", r"", output) |
89 |
|
output = re.sub (r".*submitted to cluster (.*)\..*$", r"\1", output) |
90 |
|
clusters += " " + output |