diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-09 17:26:04 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-09 17:26:04 +0200 |
commit | 95a412d21d89af67ab1736768c7efbc742ad87e7 (patch) | |
tree | f23faad8e7f330365973c47f1ea4ebda99d4d5b5 /module/AccountManager.py | |
parent | netload premium (diff) | |
download | pyload-95a412d21d89af67ab1736768c7efbc742ad87e7.tar.xz |
account save function, DELETE OLD accounts.conf !!!
Diffstat (limited to 'module/AccountManager.py')
-rw-r--r-- | module/AccountManager.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/module/AccountManager.py b/module/AccountManager.py index 391c8e775..5c3c99276 100644 --- a/module/AccountManager.py +++ b/module/AccountManager.py @@ -18,6 +18,9 @@ """ from os.path import exists +from shutil import copy + +ACC_VERSION = 1 ######################################################################## class AccountManager(): @@ -35,6 +38,8 @@ class AccountManager(): self.initAccountPlugins() self.loadAccounts() + self.saveAccounts() # save to add categories to conf + #---------------------------------------------------------------------- def getAccountPlugin(self, plugin): """get account instance for plugin or None if anonymous""" @@ -53,11 +58,25 @@ class AccountManager(): if not exists("accounts.conf"): f = open("accounts.conf", "wb") + f.write("version: " + str(ACC_VERSION)) f.close() f = open("accounts.conf", "rb") content = f.readlines() + version = content.pop(0) + + if int(version.split(":")[1]) < ACC_VERSION: + copy("accounts.conf", "accounts.backup") + f.close() + f = open("accounts.conf", "wb") + f.write("version: " + str(ACC_VERSION)) + f.close() + self.core.log.warning(_("Account settings deleted, due to new config format.")) + return + + + plugin = "" account = "" @@ -85,7 +104,21 @@ class AccountManager(): #---------------------------------------------------------------------- def saveAccounts(self): """save all account information""" - pass + + f = open("accounts.conf", "wb") + f.write("version: " + str(ACC_VERSION) + "\n") + + for plugin, accounts in self.accounts.iteritems(): + f.write("\n") + f.write(plugin+":\n") + + for name,data in accounts.iteritems(): + f.write("\n\t%s:%s\n" % (name,data["password"]) ) + for option in data["options"]: + f.write("\t@%s\n" % " ".join(option) ) + + f.close() + #---------------------------------------------------------------------- def initAccountPlugins(self): |