Skip to content

Commit

Permalink
fixes #663 and #664. Also fixes owlcat cab
Browse files Browse the repository at this point in the history
  • Loading branch information
o-smirnov committed Jul 26, 2020
1 parent b07bf77 commit 8efc559
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions stimela/cargo/base/owlcat/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM stimela/base:1.6.0
FROM stimela/base:1.4.6
RUN docker-apt-install python3-casacore \
casacore-dev \
libcfitsio-dev \
wcslib-dev
RUN pip install meqtrees-cattery "python-casacore>=3.3.1" "owlcat>=1.6.3" scabha
RUN pip install meqtrees-cattery "python-casacore>=3.3.1" "owlcat>=1.6.3" scabha future-fstrings
ENV MEQTREES_CATTERY_PATH /usr/local/lib/python3.6/dist-packages/Cattery
4 changes: 4 additions & 0 deletions stimela/cargo/cab/wsclean/src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@

_runc = " ".join([cab["binary"]] + args + [mslist])

# This line must never be deleted again. Empires will rise and fall, and certain students will graduate, but this line MUST LIVE ON. When Stimela,
# Caracal, MeerKAT and SKA are long forgotten ancient history, this line MUST REMAIN. Let it be the last remaining line of Python in history, but let it remain!
print(_runc)

try:
subprocess.check_call(shlex.split(_runc))
finally:
Expand Down
17 changes: 10 additions & 7 deletions stimela/utils/xrun_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,33 @@ class Poller(object):
def __init__ (self, log):
self.fdlabels = {}
self.log = log
self.poll = select.poll()
self._poll = select.poll()

def register_file(self, fobj, label):
self.fdlabels[fobj.fileno()] = label, fobj
self.poll.register(fobj.fileno(), select.POLLIN)
self._poll.register(fobj.fileno(), select.POLLIN)

def register_process(self, po, label_stdout='stdout', label_stderr='stderr'):
self.fdlabels[po.stdout.fileno()] = label_stdout, po.stdout
self.fdlabels[po.stderr.fileno()] = label_stderr, po.stderr
self.poll.register(po.stdout.fileno(), select.POLLIN)
self.poll.register(po.stderr.fileno(), select.POLLIN)
self._poll.register(po.stdout.fileno(), select.POLLIN)
self._poll.register(po.stderr.fileno(), select.POLLIN)

def poll(self, timeout=5, verbose=False):
try:
to_read = [fd for (fd, _) in self.poll.poll(timeout)]
to_read = self._poll.poll(timeout*1000)
if verbose:
self.log.debug("poll(): ready to read: {}".format(to_read))
return [self.fdlabels[fd] for fd in to_read]
return [self.fdlabels[fd] for (fd, ev) in to_read]
except Exception:
if verbose:
self.log.debug("poll() exception: {}".format(traceback.format_exc()))
raise

def unregister_file(self, fobj):
if fobj.fileno() in self.fdlabels:
self.poll.unregister(fobj.fileno())
self._poll.unregister(fobj.fileno())
del self.fdlabels[fobj.fileno()]

def __contains__(self, fobj):
return fobj.fileno() in self.fdlabels
Expand Down Expand Up @@ -164,11 +165,13 @@ def xrun(command, options, log=None, logfile=None, env=None, timeout=-1, kill_ca
try:
while proc_running and poller.fdlabels:
fdlist = poller.poll(verbose=DEBUG>0)
# print(f"fdlist is {fdlist}")
for fname, fobj in fdlist:
try:
line = fobj.readline()
except EOFError:
line = b''
# print("read {} from {}".format(line, fname))
empty_line = not line
line = (line.decode('utf-8') if type(line) is bytes else line).rstrip()
# break out if process closes
Expand Down

0 comments on commit 8efc559

Please sign in to comment.