summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2011-01-18 19:40:14 -0800
committerAvery Pennarun <apenwarr@gmail.com>2011-01-22 16:44:01 -0800
commit701f59a5b86ef35b3c2e30badc95846937da9c24 (patch)
tree0e831ab90ef6e20adc484615d81a80b173b44016
parent9f7b2bb4f6630e96dff5935076d8dcd0b4caac3e (diff)
ui-macos: Smoother log messages in the log window.
-rw-r--r--ui-macos/main.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/ui-macos/main.py b/ui-macos/main.py
index 8cbca15..7e8eab8 100644
--- a/ui-macos/main.py
+++ b/ui-macos/main.py
@@ -41,6 +41,7 @@ class Runner:
self.promptfunc = promptfunc
self.serverobj = serverobj
self.buf = ''
+ self.logfunc('\nConnecting to %s.\n' % self.serverobj.host())
print 'will run: %r' % argv
self.serverobj.setConnected_(False)
pid,fd = pty.fork()
@@ -76,6 +77,7 @@ class Runner:
self.rv = -os.WSTOPSIG(code)
self.serverobj.setConnected_(False)
self.serverobj.setError_('VPN process died')
+ self.logfunc('Disconnected.\n')
print 'wait_result: %r' % self.rv
return self.rv
@@ -89,8 +91,9 @@ class Runner:
assert(self.pid > 0)
print 'killing: pid=%r rv=%r' % (self.pid, self.rv)
if self.rv == None:
+ self.logfunc('Disconnecting from %s.\n' % self.serverobj.host())
os.kill(self.pid, 15)
- self.serverobj.setConnected_(False)
+ self.wait()
def gotdata(self, notification):
print 'gotdata!'
@@ -141,6 +144,7 @@ class SshuttleController(NSObject):
self.logField.textStorage()\
.appendAttributedString_(NSAttributedString.alloc()\
.initWithString_(msg))
+ self.logField.didChangeText()
def promptfunc(prompt):
print 'prompt! %r' % prompt
return 'scss'
@@ -164,10 +168,12 @@ class SshuttleController(NSObject):
def _disconnect(self, server):
host = server.host()
print 'disconnecting %r' % host
- self.fill_menu()
conn = self.conns.get(host)
if conn:
conn.kill()
+ self.fill_menu()
+ self.logField.textStorage().setAttributedString_(
+ NSAttributedString.alloc().initWithString_(''))
@objc.IBAction
def cmd_connect(self, sender):