Skip to content

Commit

Permalink
Check agent terminated.
Browse files Browse the repository at this point in the history
  • Loading branch information
chikatoike committed Jan 27, 2013
1 parent c3c38da commit 664e2f2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sublimeibus/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def setup(self):
# self.push('process_key_event(0, 0x61, 0, False)\n')
self.push('focus_in(0)\n')
# self.push('update_frame_coordinates(50331843)\n')
self.push('enable(0)\n')
# self.push('set_cursor_location(0, 100, 100, 0, 14)\n')

def push(self, data):
Expand All @@ -62,22 +61,21 @@ def feedkeys(self, keys):
if not isinstance(k, int):
k = ord(k)
self.push('process_key_event(0, %d, 0, None, None)\n' % k)
self.push('set_surrounding_text(0, "", 0, 0)\n')
# self.push('set_surrounding_text(0, "", 0, 0)\n')


agent = Agent()


def on_data(data):
if data.find('{') != 0:
print 'message:', data
print('message: ' + data)
else:
try:
print(json.loads(data))
except ValueError as e:
print 'error:', e
print('error: ' + e)
print(repr(data))
print ''


def main():
Expand All @@ -87,9 +85,12 @@ def main():
time.sleep(1)
agent.setup()
# time.sleep(1)
agent.push('enable(0)\n')
agent.feedkeys('aiu')
time.sleep(1)
agent.stop()
# agent.stop()
agent.chat.async.proc.stdin.close()
agent.chat.async.proc.wait()


if __name__ == "__main__":
Expand Down

0 comments on commit 664e2f2

Please sign in to comment.