[Nym3-commit] r470 - in trunk: . tools tools/server
jr at conuropsis.org
jr at conuropsis.org
Sun Mar 12 16:10:39 CET 2006
Author: jr
Date: 2006-03-12 16:10:38 +0100 (Sun, 12 Mar 2006)
New Revision: 470
Added:
trunk/tools/
trunk/tools/server/
trunk/tools/server/Account_handler.py
Log:
- Add a tool to test server accounts. For the time being can display the
structure of the synbox. Will be used to add easily synopses in a synbox.
Added: trunk/tools/server/Account_handler.py
===================================================================
--- trunk/tools/server/Account_handler.py 2006-03-12 15:08:26 UTC (rev 469)
+++ trunk/tools/server/Account_handler.py 2006-03-12 15:10:38 UTC (rev 470)
@@ -0,0 +1,103 @@
+from optparse import OptionParser, make_option
+import os
+import sys
+import binascii
+import nymbaron.Mail as Mail
+import nymbaron.Server.Config as Config
+import nymbaron.Server.User as User
+from nymbaron.Client.Main import get_account_from_nickname
+from nymbaron.Server.Main import load_config
+from nymbaron.Mail import XNymSeq
+import nymbaron.Server.Main as Main
+
+config = None
+
+usage_string = """Usage: account_handler <command> [arguments]
+where command is one of:
+ \tadd-msg\t\tAdd synopses
+ \tdisplay-synbox\tDsiplays the content of the synbox
+ \thelp\t\tDisplay this help"""
+
+def main(args):
+ if len(args) < 2:
+ print usage_string
+ sys.exit(1)
+
+ load_config()
+
+ if args[1] == "add-msg":
+ parser = OptionParser(usage =
+ """nymbarond add-msg [options]
+ Adds a test message to the specified account.""")
+ parser.add_option("-n", "--nym", action = "store", dest = "nym",
+ help = "the nym to which deliver the message")
+ parser.add_option("-r", "--read-file", action = "store_true", dest =
+ "read_file", default = False, help = "whether to read the message \
+ from somewhere or generate a \"standard\" test message")
+ parser.add_option("-f", "--file", action = "store",
+ dest = "file", help = "if read_file is set: the file to read \
+ the message from, or stdin if omitted, otherwise: \
+ ignored")
+ parser.add_option("-a", "--age", action = "store", type = "int",
+ dest = "age", default = 0, help = "this option fakes the age \
+ of a message: age seconds are substracted from the \
+ time of arrival of the message to the server.")
+ parser.add_option("-b", "--batch", action = "store", type = "int",
+ dest = "batch", default = 1, help = "repeats the add-msg \
+ behaviour 'batch' times.")
+ (options, args) = parser.parse_args(args[2:])
+ if not options.nym:
+ print ("You must provide the nym of the account you which to \
+ handle\nUse -n option")
+ sys.exit(1)
+ else:
+ try:
+ nymUser = User.User(options.nym, config)
+ except User.NoSuchUser:
+ print "No such user %s" % options.nym
+ sys.exit(73)
+ if options.file and not options.read_file:
+ print ("You provided a file to read the message, but didn't ask \
+ to read the message from a file. See --read-file option.\n\
+ Options inconsistency, doing nothing.")
+ sys.exit(1)
+ for i in range(options.batch):
+ #TODO get_message
+ #TODO store message
+ #TODO tweak the stored message time of arrival.
+ pass
+ sys.exit(0)
+
+ if args[1] == "help":
+ print usage_string
+ sys.exit(0)
+
+ if args[1] == "display-synbox":
+ parser = OptionParser(usage =
+ """nymbarond display-synbox [options]
+ Displays the structure of the synbox.""")
+ parser.add_option("-n", "--nym", action = "store", dest = "nym",
+ help = "the nym of which we want to display the synbox")
+ (options, args) = parser.parse_args(args[2:])
+ if not options.nym:
+ print ("You must provide the nym of the account you which to \
+ handle\nUse -n option")
+ sys.exit(1)
+ try:
+ nymUser = User.User(options.nym, Main.config)
+ except User.NoSuchUser:
+ print "No such user %s" % options.nym
+ sys.exit(73)
+ nymUser.load_synbox()
+ print "synbox %s" % options.nym
+ for mids, status, content in nymUser.syn:
+ if status == "encrypted":
+ print "E:%d" % len(mids),
+ if status == "clear":
+ print "C:%d" % XNymSeq(content),
+ print
+ sys.exit(0)
+
+
+if __name__ == '__main__':
+ main(sys.argv)
More information about the Nym3-commit
mailing list