[Nym3-commit] r346 - in trunk/nymbaron: . Client

jr at conuropsis.org jr at conuropsis.org
Thu Oct 13 19:30:56 CEST 2005


Author: jr
Date: 2005-10-13 19:30:55 +0200 (Thu, 13 Oct 2005)
New Revision: 346

Modified:
   trunk/nymbaron/Client/Main.py
   trunk/nymbaron/TODO
Log:
- catch Ctrl-C when we ask some input to the user 


Modified: trunk/nymbaron/Client/Main.py
===================================================================
--- trunk/nymbaron/Client/Main.py	2005-10-12 21:26:47 UTC (rev 345)
+++ trunk/nymbaron/Client/Main.py	2005-10-13 17:30:55 UTC (rev 346)
@@ -76,12 +76,18 @@
     def __init__(self):
 	pass
 
-    def prompt(self, s):
+    def prompt(self, s, modified_tty = False):
 	try:
 	    return raw_input(s + ": ")
 	except EOFError:
 	    return ""
-	
+	except KeyboardInterrupt:
+	    if modified_tty:
+		raise KeyboardInterrupt()
+	    else:
+		print "Interrupted the User"
+		sys.exit(2)
+
     def promptmultiline(self, s):
 	res = []
 	while True:
@@ -101,11 +107,15 @@
 	new = termios.tcgetattr(fd)
 	new[3] = new[3] & ~termios.ECHO          # lflags
 	try:
-	    termios.tcsetattr(fd, termios.TCSADRAIN, new)
-	    passwd = self.prompt(s)
-	finally:
-	    termios.tcsetattr(fd, termios.TCSADRAIN, old)
-	print ''	
+	    try:
+		termios.tcsetattr(fd, termios.TCSADRAIN, new)
+		passwd = self.prompt(s, True)
+	    finally:
+		termios.tcsetattr(fd, termios.TCSADRAIN, old)
+		print ''	
+	except KeyboardInterrupt:
+	    print "Interrupted by the user"
+	    sys.exit(2)
 	return passwd
 
     def display(self, s):

Modified: trunk/nymbaron/TODO
===================================================================
--- trunk/nymbaron/TODO	2005-10-12 21:26:47 UTC (rev 345)
+++ trunk/nymbaron/TODO	2005-10-13 17:30:55 UTC (rev 346)
@@ -8,7 +8,9 @@
         D Deferred
         X Abandoned
 
- - catch Ctrl-C interruption on passphrase input[client]
+ o catch Ctrl-C interruption on passphrase input[client]
+ - check every command that ask for user input can be interrupted cleanly
+   [client]
  - periodically scan for emails that need to be relayed [server]
  - periodically scan for synopses that have stayed that need to be encrypted
  [server]



More information about the Nym3-commit mailing list