Example #1
0
 def reporting(self):
     try:
         while 1:
             time.sleep(.5)
             self.seconds_since_last_poll += .5
             if self.seconds_since_last_poll < self.poll_interval and not self.exited:
                 continue
             self.seconds_since_last_poll = 0
             try:
                 rpc_connection = CONNECT.sim_client()
                 #rpc_connection=DUMMY_RPC()
             except:
                 print "Failed to get rpc_connection for reporting"
                 pass
             else:
                 events = self.simulation_event_queue.Consume_All()
                 for event_function, event_data in events:
                     #print "events func=%s data=%s"%(repr(event_function),repr(event_data))
                     try:
                         ret = event_function(self.pid, rpc_connection,
                                              self.session, event_data)
                         #print "ret=%s"%ret
                     except EXIT_REPORTING_EXCEPTION:
                         raise EXIT_REPORTING_EXCEPTION
                     except:
                         pass
                 for poll_function in self.polled_events:
                     #try:
                     poll_function(self.pid, rpc_connection, self.session)
                     #except: pass
     except EXIT_REPORTING_EXCEPTION:
         pass
Example #2
0
    def run(self):
        # set up signal handling
        signal.signal(signal.SIGTERM, self.kill)
        signal.signal(signal.SIGINT, self.kill)

        # make the reporting thread
        self.reporting_thread = threading.Thread()
        self.reporting_thread.run = self.reporting
        self.reporting_thread.start()

        # launch the process and capture the pid
        pipe = popen2.Popen4(self.cmd)
        self.input, self.pid = pipe.fromchild, pipe.pid

        # report that we have started the program
        rpc_connection = CONNECT.sim_client()
        self.report_start(self.pid, rpc_connection, self.session)
        rpc_connection = None

        # parse and pipe input
        while 1:
            line = ""
            try:
                line = self.input.readline()
            except IOError:
                continue
            if line == "": break  # cmd died, break to find out why
            print line,
            line = line.strip()
            for regexp, match_func, act_func in self.simulation_events:
                match = regexp.match(line)
                try:
                    event_data = match_func(match)
                except:
                    pass
                else:
                    self.simulation_event_queue.Produce((act_func, event_data))
        # end of process detect exit code
        exit_code = pipe.wait()
        print "\ngot exit code %d - should exit in at most a couple of seconds" % exit_code
        self.simulation_event_queue.Produce(
            (self.report_exit, (exit_code, time.time())))
        self.reporting_thread.join()
Example #3
0
            text += ("    <td>%s</td>\n" % c)
        text += ("  </tr>\n")

    text += ("</table>\n")
    return text


# grab fields
form = cgi.FieldStorage()
username_filter = ""
state_filter = ""

print "Content-type: text/html\n\n"

# get session list
client = CONNECT.sim_client()
sessions = client.Session_List()
client = None

# grab form options
if form.has_key("username_filter"):
    username_filter = form["username_filter"].value
if form.has_key("state_filter"): state_filter = form["state_filter"].value

# make the filter regular expressions
filter_conditions = [("username", re.compile(username_filter)),
                     ("state", re.compile(state_filter))]

# make a list of accepted sessions
accepted_sessions = []
for i in sessions.keys():