rev 196, Configurable data dir, log dir and config file, fix for getFile unhandled exceptions, add http://zeronet.io to readme
This commit is contained in:
parent
1c1d9fb75c
commit
66eca389bf
15 changed files with 69 additions and 53 deletions
|
@ -1,6 +1,8 @@
|
|||
import logging, json, time
|
||||
from Crypt import CryptBitcoin
|
||||
from Plugin import PluginManager
|
||||
from Config import config
|
||||
|
||||
|
||||
@PluginManager.acceptPlugins
|
||||
class User(object):
|
||||
|
@ -22,13 +24,13 @@ class User(object):
|
|||
|
||||
# Save to data/users.json
|
||||
def save(self):
|
||||
users = json.load(open("data/users.json"))
|
||||
users = json.load(open("%s/users.json" % config.data_dir))
|
||||
if not self.master_address in users: users[self.master_address] = {} # Create if not exits
|
||||
user_data = users[self.master_address]
|
||||
if self.master_seed: user_data["master_seed"] = self.master_seed
|
||||
user_data["sites"] = self.sites
|
||||
user_data["certs"] = self.certs
|
||||
open("data/users.json", "w").write(json.dumps(users, indent=2, sort_keys=True))
|
||||
open("%s/users.json" % config.data_dir, "w").write(json.dumps(users, indent=2, sort_keys=True))
|
||||
self.log.debug("Saved")
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import json, logging, os
|
||||
from User import User
|
||||
from Plugin import PluginManager
|
||||
from Config import config
|
||||
|
||||
|
||||
@PluginManager.acceptPlugins
|
||||
|
@ -16,7 +17,7 @@ class UserManager(object):
|
|||
user_found = []
|
||||
added = 0
|
||||
# Load new users
|
||||
for master_address, data in json.load(open("data/users.json")).items():
|
||||
for master_address, data in json.load(open("%s/users.json" % config.data_dir)).items():
|
||||
if master_address not in self.users:
|
||||
user = User(master_address, data=data)
|
||||
self.users[master_address] = user
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue