Permalink
Browse files

more test coverage

  • Loading branch information...
1 parent 5f2440e commit f02a767cd63ce68f6d4ff0c7616957a541af638f @buzztroll buzztroll committed Dec 11, 2011
Showing with 50 additions and 37 deletions.
  1. +13 −3 eeagent/agent.py
  2. +1 −34 eeagent/client.py
  3. +36 −0 example/console_client.py
View
@@ -94,11 +94,21 @@ def run(self):
def end(self):
self._main.end()
+eeagent = None
+def death_handler(signum, frame):
+ if not eeagent:
+ return
+ eeagent.end()
+
def main(args=sys.argv):
+ global eeagent
+ try:
+ signal.signal(signal.SIGTERM, death_handler)
+ signal.signal(signal.SIGINT, death_handler)
+ signal.signal(signal.SIGQUIT, death_handler)
+ except Exception, ex:
+ pass
eeagent = EEAgentMain(args)
- signal.signal(signal.SIGTERM, eeagent.death_handler)
- signal.signal(signal.SIGINT, eeagent.death_handler)
- signal.signal(signal.SIGQUIT, eeagent.death_handler)
eeagent.start()
return eeagent.wait()
View
@@ -45,37 +45,4 @@ def poll(self, timeout=None, count=None):
try:
self.dashi.consume(timeout=timeout, count=count)
except socket.timeout, ex:
- pass
-
-def launch(talker, line_a):
- talker.launch(line_a)
-
-def proc_term(talker, line_a):
- talker.terminate(line_a[0], int(line_a[1]))
-
-def proc_clean(talker, line_a):
- talker.cleanup(line_a[0], int(line_a[1]))
-
-def proc_dump(talker, line_a):
- talker.dump()
-
-
-g_command_table = {}
-g_command_table['launch'] = launch
-g_command_table['terminate'] = proc_term
-g_command_table['cleanup'] = proc_clean
-g_command_table['dump'] = proc_dump
-
-class EEAgentCLIMessageReaderThread(Thread):
-
- def __init__(self, client):
- Thread.__init__(self)
- self.done = False
- self.client = client
-
- def end(self):
- self.done = True
-
- def run(self):
- while not self.done:
- self.client.poll(timeout=2)
+ pass
View
@@ -1,3 +1,5 @@
+import sys
+
class TalkConsole(object):
def __init__(self):
@@ -13,6 +15,25 @@ def input(self):
return line.strip()
+def launch(talker, line_a):
+ talker.launch(line_a)
+
+def proc_term(talker, line_a):
+ talker.terminate(line_a[0], int(line_a[1]))
+
+def proc_clean(talker, line_a):
+ talker.cleanup(line_a[0], int(line_a[1]))
+
+def proc_dump(talker, line_a):
+ talker.dump()
+
+
+g_command_table = {}
+g_command_table['launch'] = launch
+g_command_table['terminate'] = proc_term
+g_command_table['cleanup'] = proc_clean
+g_command_table['dump'] = proc_dump
+
class EEAgentClientMain(object):
def __init__(self, args):
@@ -54,6 +75,21 @@ def end(self):
self._done = True
+class EEAgentCLIMessageReaderThread(Thread):
+
+ def __init__(self, client):
+ Thread.__init__(self)
+ self.done = False
+ self.client = client
+
+ def end(self):
+ self.done = True
+
+ def run(self):
+ while not self.done:
+ self.client.poll(timeout=2)
+
+
def main(args=sys.argv):
client = EEAgentClientMain(args)
client.start()

0 comments on commit f02a767

Please sign in to comment.