[Nym3-commit] r401 - in trunk: . nymbaron/Client
jr at conuropsis.org
jr at conuropsis.org
Tue Nov 15 18:51:15 CET 2005
Author: jr
Date: 2005-11-15 18:51:13 +0100 (Tue, 15 Nov 2005)
New Revision: 401
Modified:
trunk/TODO
trunk/nymbaron/Client/Account.py
trunk/nymbaron/Client/Main.py
Log:
- add remove-accounts command [client]
- display the username in list-accounts [client]
- update TODO
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2005-11-14 20:38:49 UTC (rev 400)
+++ trunk/TODO 2005-11-15 17:51:13 UTC (rev 401)
@@ -10,10 +10,12 @@
* be able to cope with base64 encoded as well as raw binary input
flawlessly for nymbaron -m [server]
- * display the username in list-accounts [client]
* let the user set the domainname of the account when known.
+ * do not return silently without giving explanation of what went wrong or what
+ was done
. don't fail miserably when another instance holds a lock, instead simply
wait for it a few times [client]
+ o display the username in list-accounts [client]
o clarify the "localpart" thing in nymbarond(8) [doc]
o catch Ctrl-C interruption on passphrase input [client]
o check every command that ask for user input can be interrupted cleanly
Modified: trunk/nymbaron/Client/Account.py
===================================================================
--- trunk/nymbaron/Client/Account.py 2005-11-14 20:38:49 UTC (rev 400)
+++ trunk/nymbaron/Client/Account.py 2005-11-15 17:51:13 UTC (rev 401)
@@ -189,12 +189,12 @@
if create:
self.data = {}
self.succeeded = False
- self['idTag'] = self.tagmap.getnewId(nickname)
+ self.idTag = self.tagmap.getnewId(nickname)
self._lock()
# If the nick already existed, we're out of this because of
# a thrown AlreadySuchAccount.
# Create the dir that holds this account data
- self.base_path = config.path + os.sep + self['idTag']
+ self.base_path = config.path + os.sep + self.idTag
os.mkdir(self.base_path)
self.data_status = 'dirty'
self.journal = {}
@@ -213,10 +213,10 @@
self.journal_status = 'unloaded'
self.mbox_status = 'unloaded'
self.synbox_status = 'unloaded'
- idTag = self.tagmap.idFromNick(nickname)
- self.base_path = config.path + os.sep + idTag
+ self.idTag = self.tagmap.idFromNick(nickname)
+ self._lock()
+ self.base_path = config.path + os.sep + self.idTag
self._load_data()
- self._lock()
self.journal = None
self.mbox = None
self.synbox = None
@@ -233,7 +233,7 @@
surbdir = tempfile.mkdtemp()
surbspath = surbdir + os.sep + "surbs"
mixcall = "mixminion generate-surb -t %s -b -n %d -o %s --identity='%s'"
- mixcall = mixcall % (self['returnaddress'], n, surbspath, self['idTag'])
+ mixcall = mixcall % (self['returnaddress'], n, surbspath, self.idTag)
os.system(mixcall)
f = open(surbspath, "r")
data = f.read()
@@ -284,14 +284,15 @@
def _lock(self):
"""Locks the user. For well behaved functions."""
- self.lock = mixminion.Common.Lockfile(self.config.path + os.sep +
- self['idTag'] + '.lck')
+ self.lock = mixminion.Common.Lockfile(self.config.path + os.sep + \
+ self.idTag + '.lck')
self.lock.acquire(blocking = 1)
def _release(self):
"""Releases the lock"""
- self.lock.release()
- self.lock = None
+ if hasattr(self, 'lock'):
+ self.lock.release()
+ self.lock = None
def homeDir(self):
"""Gets the home directory of this account"""
@@ -398,7 +399,7 @@
self._save_data()
else:
os.removedirs(self.base_path)
- self.tagmap.remove(self['idTag'])
+ self.tagmap.remove(self.idTag)
self._release()
def _load_mbox(self):
@@ -513,3 +514,6 @@
def add_enckey(self, key):
self['encKeys'].insert(0, key)
+
+ def removeAccount(self):
+ self.succeeded = False
Modified: trunk/nymbaron/Client/Main.py
===================================================================
--- trunk/nymbaron/Client/Main.py 2005-11-14 20:38:49 UTC (rev 400)
+++ trunk/nymbaron/Client/Main.py 2005-11-15 17:51:13 UTC (rev 401)
@@ -71,6 +71,7 @@
\tldelete-syn\tDelete synopses from the local synbox
\tldelete-journal\tDelete journal items from the local journal
\tlist-accounts\tList the accounts of the user
+ \tremove-accounts\Remove a local account
\tpasswd\t\tChange the passphrase that protects the user keyring"""
class CLI:
@@ -612,9 +613,25 @@
for nickname in tagmap.getNicks():
a = Account.Account(config, nickname)
#TODO be more verbose?
- ui.display("%s@%s" % (nickname, a['servername']))
- ui.display("Return address: %s" % a['returnaddress'])
+ ui.display(nickname)
+ if a['username']:
+ ui.display("\t%s@%s" % (a['username'], a['servername']))
+ else:
+ ui.display("\tcreation in process")
+ ui.display("\tserver: %s" % a['servername'])
+ ui.display("\tReturn address: %s" % a['returnaddress'])
+def remove_accounts(ui, config, args):
+ if not args:
+ ui.display("Removing no account : no nickname given""")
+ for nickname in args:
+ ui.display("Removing account %s" % nickname)
+ try:
+ a = Account.Account(config, nickname)
+ a.removeAccount()
+ except Account.NoSuchAccount:
+ ui.display("\tAccount %s does not exist" % nickname)
+
def passwd(ui, config):
"""changes the passphrase protecting the user Keyring"""
secring = Keyring.Keyring(config.secring_path)
@@ -1033,6 +1050,16 @@
list_accounts(ui, config)
sys.exit(0)
+ if args[1] == "remove-accounts":
+ parser = OptionParser(usage =
+ """nymbaron remove-accounts [nickname1 [nickname2 [...]]
+ Remove the accounts designed by the given list of nicknames.""")
+ ui = CLI()
+ config = Config.Config()
+ (options, args) = parser.parse_args(args[2:])
+ remove_accounts(ui, config, args)
+ sys.exit(0)
+
if args[1] == "passwd":
parser = OptionParser(usage =
"""nymbaron passwd
More information about the Nym3-commit
mailing list