[Nym3-commit] r214 - trunk/nym3/Client

laurent at conuropsis.org laurent at conuropsis.org
Sun May 1 17:22:55 CEST 2005


Author: laurent
Date: 2005-05-01 17:22:53 +0200 (Sun, 01 May 2005)
New Revision: 214

Modified:
   trunk/nym3/Client/Main.py
Log:
Added GET client command.


Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py	2005-05-01 15:19:34 UTC (rev 213)
+++ trunk/nym3/Client/Main.py	2005-05-01 15:22:53 UTC (rev 214)
@@ -305,6 +305,33 @@
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
     account.sendControl([delmsg], idKey)
 
+def Get(ui, config, nickname = None, midlist = None):
+    if not nickname:
+	ui.display("No nickname given, abort")
+	ui.display("Use -n <nickname>")
+	sys.exit(1)
+    account = None
+    try:
+	account = Account.Account(config, nickname)
+    except Account.NoSuchAccount:
+	ui.display("No account relative to the provided nickname, abort")
+	sys.exit(1)
+    getmsg = Message.Get()
+    midlist = map(binascii.unhexlify, midlist)
+    getmsg.fromData(midlist)
+    try:
+	secring = Keyring.Keyring(config.secring_path)
+	ui.display("You need to provide your passphrase to unlock your keyring")
+	while True:
+		passphrase1 = ui.prompthidden("Passphrase")
+		if secring.decrypt(passphrase1): break
+		ui.display("wrong passphrase")
+    except Keyring.NewKeyring:
+	# The Keyring is new. That shouldn't happen
+	raise Exception('Bug keyring?')
+    idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
+    account.sendControl([getmsg], idKey)
+
 def main(args):
     if len(args) < 2:
 	print "Usage: WRITEME"
@@ -378,6 +405,17 @@
 	Delete(ui, config, options.nickname, args)
 	sys.exit(0)
 
+    if args[1] == "get":
+	parser = OptionParser()
+	parser.add_option("-n", "--nickname", action = "store",
+			  dest = "nickname", help = "The nickname "
+			  "of the account whose emails to request")
+	(options, args) = parser.parse_args(args[2:])
+	ui = CLI()
+	config = Config.Config()
+	Get(ui, config, options.nickname, args)
+	sys.exit(0)
+
     if args[1] == "process":
 	parser = OptionParser()
 	parser.add_option("-i", "--idtag", action = "store",



More information about the Nym3-commit mailing list