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

jr at conuropsis.org jr at conuropsis.org
Tue Nov 15 22:24:10 CET 2005


Author: jr
Date: 2005-11-15 22:24:10 +0100 (Tue, 15 Nov 2005)
New Revision: 402

Modified:
   trunk/TODO
   trunk/nymbaron/Client/Main.py
Log:
- add messages to inform the user of what the client does or why it does nothing
  [client]
- add TODO items


Modified: trunk/TODO
===================================================================
--- trunk/TODO	2005-11-15 17:51:13 UTC (rev 401)
+++ trunk/TODO	2005-11-15 21:24:10 UTC (rev 402)
@@ -34,6 +34,8 @@
  X reorder the items of the usage string [client]
 
 doc:
+ * document new client command (remove-accounts)
+ * improve the explanation of the client philosophy in Getting Started
  o add doc strings in __init__.py in every module.
 
 Message.py:

Modified: trunk/nymbaron/Client/Main.py
===================================================================
--- trunk/nymbaron/Client/Main.py	2005-11-15 17:51:13 UTC (rev 401)
+++ trunk/nymbaron/Client/Main.py	2005-11-15 21:24:10 UTC (rev 402)
@@ -398,10 +398,12 @@
     newpkc.fromData(idKey, encKey)
     surbc = Message.Surb()
     surbc.fromData(account.generateSurbs(7))
+    ui.display("Sending registration message")
     account.sendControl([createc, newpkc, surbc], idKey, "create an account")
     account['handshake'] = "initiated"
     #the creation of the account succeeded, we can keep the account
     account.creationSuccess()
+    ui.display("Account registration message successfully sent")
 
 def relayMessage(ui, config, nickname = None, to = None, input = None):
     body = None
@@ -438,7 +440,8 @@
     secring = decode_secring(config, ui)
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
     account.sendControl([relayc], idKey, "send an email")
-
+    ui.display("Message sent")
+    
 def Summarize(ui, config, nickname = None, max = None, older = None):
     if not max: max = config.max_syn
     account = get_account_from_nickname(ui, config, nickname,
@@ -469,6 +472,8 @@
     secring = decode_secring(config, ui)
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
     account.sendControl([summ], idKey, "request summaries")
+    ui.display("Summary request sent")
+    
 
 def Delete(ui, config, nickname = None, midlist = None):
     account = get_account_from_nickname(ui, config, nickname,
@@ -485,10 +490,13 @@
 	ui.display(str(inst))
 	sys.exit(1)
     #if the midlist is empty, do nothing
-    if not midlist: return
+    if not midlist:
+	ui.display("No valid message references given, doing nothing")
+	return
     delmsg.fromData(midlist)
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
     account.sendControl([delmsg], idKey, "delete messages")
+    ui.display("Deletion request of messages stored on the server sent")
 
 def Get(ui, config, nickname = None, midlist = None):
     account = get_account_from_nickname(ui, config, nickname,
@@ -502,10 +510,13 @@
 	ui.display(str(inst))
 	sys.exit(1)
     #if the midlist is empty, do nothing
-    if not midlist: return
+    if not midlist:
+	ui.display("No valid message references given, doing nothing")
+	return
     getmsg.fromData(midlist)
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
     account.sendControl([getmsg], idKey, "get messages")
+    ui.display("Retrieval request of messages stored on the server sent")
 
 def resend_command(ui, config, nickname = None, seqnolist = None):
     account = get_account_from_nickname(ui, config, nickname,
@@ -522,7 +533,9 @@
 	ui.display(str(inst))
 	sys.exit(1)
     #if the seqnolist is empty, do nothing
-    if not seqnolist: return
+    if not seqnolist:
+	ui.display("No valid command references given, doing nothing")
+	return
     key = secring.get_key(account['admKey'])
     journal = account.get_journal()
     for seqno in seqnolist:
@@ -530,7 +543,8 @@
 	m, t, d = pickle.loads(clear)
 	account.send(m)
 	account.record(seqno, m, d)
-	ui.display("resend message seqno: %s" % binascii.hexlify(seqno))
+	ui.display("resend message seqno: %s (%s)" % 
+		(binascii.hexlify(seqno), d))
     
 def SendSurb(ui, config, nickname = None, number = None):
     if not number: number = config.nb_surb
@@ -541,12 +555,16 @@
     surbc = Message.Surb()
     surbc.fromData(account.generateSurbs(number))
     account.sendControl([surbc], idKey, "send surbs")
+    ui.display("%d surbs sent", number)
 
 def list_syn(ui, config, nickname = None, summarize = True):
     account = get_account_from_nickname(ui, config, nickname,
 	    "No nickname given, abort\nUse -n <nickname>")
     secring = decode_secring(config, ui)
     synbox = account.get_synbox(secring)
+    if len(synbox) == 0:
+	ui.display("empty synbox")
+	return
     mbox = account.get_mbox()[0]
     for xnymseq, (mid, flag, syn) in synbox.iteritems():
 	if mbox.has_key(mid):
@@ -566,6 +584,9 @@
 	    "No nickname given, abort\nUse -n <nickname>")
     mbox, mids = account.get_mbox()
     secring = decode_secring(config, ui)
+    if len(mbox) == 0:
+	ui.display("empty mbox")
+	return
     for i, mid in enumerate(mids):
 	clear = decipher_string(mbox[mid], secring, account['encKeys'])
 	ui.display("%d %s" % (i, binascii.hexlify(mid)))
@@ -588,6 +609,9 @@
     secring = decode_secring(config, ui)
     key = secring.get_key(account['admKey'])
     l = []
+    if len(journal.keys()) == 0:
+	ui.display("empty journal")
+	return
     for seqno in journal.keys():
 	clear = Crypto.nym_decrypt(journal[seqno], key)
 	m, t, d = pickle.loads(clear)
@@ -610,7 +634,11 @@
 	ui.display("%s does not exist" % config.path)
 	return
     tagmap = Account.TagMap(config.path + os.sep + 'tagmap')
-    for nickname in tagmap.getNicks():
+    nicks = tagmap.getNicks()
+    if len(nicks) == 0:
+	ui.display("No account")
+	return
+    for nickname in nicks:
 	a = Account.Account(config, nickname)
 	#TODO be more verbose?
 	ui.display(nickname)
@@ -661,8 +689,12 @@
 	except IOError:
 	    ui.display("Unable to write in output file, abort")
 	    sys.exit(1)
+    if len(args) == 0:
+	ui.display("No valid message reference, doing nothing")
+	return
     for mid in args:
 	if mbox.has_key(mid):
+	    ui.display("exporting %s", mid)
 	    clear = decipher_string(mbox[mid], secring, account['encKeys'])
 	    output_f.write(clear)
 	else:
@@ -678,6 +710,9 @@
 	    "No nickname given, abort\nUse -n <nickname>")
     mids = decode_message_references(args, ['mbox'],
 	        {'mbox': (build_mbox_index, (account,))})
+    if len(mids) == 0:
+	ui.display("No valid message reference given, doing nothing")
+	return
     for mid in mids:
 	account.delete_msg(mid)
 
@@ -688,7 +723,9 @@
     mids = decode_message_references(args, ['syn'],
 	        {'syn': (build_syn_index, (secring, account))})
     #if mids is empty, do nothing
-    if not mids: return
+    if len(mids) == 0:
+	ui.display("No valid syn reference given, doing nothing")
+	return
     for mid in mids:
 	account.delete_syn(secring, mid)
 
@@ -698,6 +735,9 @@
     secring = decode_secring(config, ui)
     seqnos = decode_message_references(args, ['journal'],
 	        {'journal': (build_journal_index, (secring, account))})
+    if len(seqnos) == 0:
+	ui.display("No valid journal reference given, doing nothing")
+	return
     account.acknowledge(seqnos, verbose = False)
 	
 def main(args):



More information about the Nym3-commit mailing list