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