Merged with new version from NRL

This commit is contained in:
Rod A Santiago 2016-09-14 17:13:46 -07:00
parent 928617e613
commit ae4a4b903e

View file

@ -14,6 +14,7 @@ that manages a CORE session.
import os, sys, tempfile, shutil, shlex, atexit, gc, pwd import os, sys, tempfile, shutil, shlex, atexit, gc, pwd
import threading, time, random import threading, time, random
import traceback import traceback
import subprocess
from core.api import coreapi from core.api import coreapi
if os.uname()[0] == "Linux": if os.uname()[0] == "Linux":
@ -289,8 +290,16 @@ class Session(object):
self.warn("Error writing hook '%s': %s" % (filename, e)) self.warn("Error writing hook '%s': %s" % (filename, e))
self.info("Running hook %s for state %s" % (filename, state)) self.info("Running hook %s for state %s" % (filename, state))
try: try:
check_call(["/bin/sh", filename], cwd=self.sessiondir, stdout = open(os.path.join(self.sessiondir,
env=self.getenviron()) filename + '.log'), 'w')
stderr = subprocess.STDOUT
except:
stdout = None
stderr = None
try:
check_call(["/bin/sh", filename], stdin=open(os.devnull, 'r'),
stdout=stdout, stderr=stderr, close_fds=True,
cwd=self.sessiondir, env=self.getenviron())
except Exception, e: except Exception, e:
self.warn("Error running hook '%s' for state %s: %s" % self.warn("Error running hook '%s' for state %s: %s" %
(filename, state, e)) (filename, state, e))
@ -675,7 +684,6 @@ class Session(object):
self.info("Checking for runtime with %d of %d session nodes" % \ self.info("Checking for runtime with %d of %d session nodes" % \
(nc, session_node_count)) (nc, session_node_count))
if nc < session_node_count: if nc < session_node_count:
self.info("do not have information on all nodes")
return # do not have information on all nodes yet return # do not have information on all nodes yet
# information on all nodes has been received and they have been started # information on all nodes has been received and they have been started
# enter the runtime state # enter the runtime state
@ -684,7 +692,6 @@ class Session(object):
state = coreapi.CORE_EVENT_RUNTIME_STATE state = coreapi.CORE_EVENT_RUNTIME_STATE
self.evq.run() self.evq.run()
self.setstate(state, info=True, sendevent=True) self.setstate(state, info=True, sendevent=True)
self.info("Entered runtime state")
def datacollect(self): def datacollect(self):
''' Tear down a running session. Stop the event loop and any running ''' Tear down a running session. Stop the event loop and any running
@ -759,7 +766,6 @@ class Session(object):
| coreapi.CORE_API_LOC_FLAG, | coreapi.CORE_API_LOC_FLAG,
tlvdata) tlvdata)
try: try:
#Use the handler's sendall (Is this ok with CoreDatagramRequestHandler??)
handler.sendall(reply) handler.sendall(reply)
except Exception, e: except Exception, e:
self.warn("sendall() for node: %d error: %s" % (nodenum, e)) self.warn("sendall() for node: %d error: %s" % (nodenum, e))