parent
e50558a118
commit
8913363ca8
3 changed files with 33 additions and 20 deletions
|
@ -16,7 +16,7 @@ class Config(object):
|
||||||
self.version = "0.7.6+"
|
self.version = "0.7.6+"
|
||||||
self.user_agent = "conservancy"
|
self.user_agent = "conservancy"
|
||||||
# DEPRECATED ; replace with git-generated commit
|
# DEPRECATED ; replace with git-generated commit
|
||||||
self.rev = 5032
|
self.rev = 5033
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
self.action = None
|
self.action = None
|
||||||
self.test_parser = None
|
self.test_parser = None
|
||||||
|
|
49
src/main.py
49
src/main.py
|
@ -25,23 +25,34 @@ gevent.monkey.patch_all(thread=False, subprocess=False)
|
||||||
update_after_shutdown = False # If set True then update and restart zeronet after main loop ended
|
update_after_shutdown = False # If set True then update and restart zeronet after main loop ended
|
||||||
restart_after_shutdown = False # If set True then restart zeronet after main loop ended
|
restart_after_shutdown = False # If set True then restart zeronet after main loop ended
|
||||||
|
|
||||||
# Load config
|
|
||||||
from Config import config
|
from Config import config
|
||||||
config.parse(silent=True) # Plugins need to access the configuration
|
|
||||||
if not config.arguments: # Config parse failed, show the help screen and exit
|
def load_config():
|
||||||
|
config.parse(silent=True) # Plugins need to access the configuration
|
||||||
|
if not config.arguments: # Config parse failed, show the help screen and exit
|
||||||
|
config.parse()
|
||||||
|
|
||||||
|
load_config()
|
||||||
|
|
||||||
|
def init_dirs():
|
||||||
config.parse()
|
config.parse()
|
||||||
|
if not os.path.isdir(config.data_dir):
|
||||||
|
os.mkdir(config.data_dir)
|
||||||
|
try:
|
||||||
|
os.chmod(config.data_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||||
|
except Exception as err:
|
||||||
|
startupError("Can't change permission of %s: %s" % (config.data_dir, err))
|
||||||
|
|
||||||
if not os.path.isdir(config.data_dir):
|
sites_json = f"{config.data_dir}/sites.json"
|
||||||
os.mkdir(config.data_dir)
|
if not os.path.isfile(sites_json):
|
||||||
try:
|
with open(sites_json, "w") as f:
|
||||||
os.chmod(config.data_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
f.write("{}")
|
||||||
except Exception as err:
|
users_json = f"{config.data_dir}/users.json"
|
||||||
startupError("Can't change permission of %s: %s" % (config.data_dir, err))
|
if not os.path.isfile(users_json):
|
||||||
|
with open(users_json, "w") as f:
|
||||||
|
f.write("{}")
|
||||||
|
|
||||||
if not os.path.isfile("%s/sites.json" % config.data_dir):
|
init_dirs()
|
||||||
open("%s/sites.json" % config.data_dir, "w").write("{}")
|
|
||||||
if not os.path.isfile("%s/users.json" % config.data_dir):
|
|
||||||
open("%s/users.json" % config.data_dir, "w").write("{}")
|
|
||||||
|
|
||||||
if config.action == "main":
|
if config.action == "main":
|
||||||
from util import helper
|
from util import helper
|
||||||
|
@ -69,12 +80,14 @@ config.initLogging()
|
||||||
|
|
||||||
# Debug dependent configuration
|
# Debug dependent configuration
|
||||||
from Debug import DebugHook
|
from Debug import DebugHook
|
||||||
|
|
||||||
# Load plugins
|
|
||||||
from Plugin import PluginManager
|
from Plugin import PluginManager
|
||||||
PluginManager.plugin_manager.loadPlugins()
|
|
||||||
config.loadPlugins()
|
def load_plugins():
|
||||||
config.parse() # Parse again to add plugin configuration options
|
PluginManager.plugin_manager.loadPlugins()
|
||||||
|
config.loadPlugins()
|
||||||
|
config.parse() # Parse again to add plugin configuration options
|
||||||
|
|
||||||
|
load_plugins()
|
||||||
|
|
||||||
# Log current config
|
# Log current config
|
||||||
logging.debug("Config: %s" % config)
|
logging.debug("Config: %s" % config)
|
||||||
|
|
|
@ -44,7 +44,7 @@ def main():
|
||||||
print("Error: Python 3.x is required")
|
print("Error: Python 3.x is required")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if "--silent" not in sys.argv:
|
if '--silent' not in sys.argv:
|
||||||
fancy_greet()
|
fancy_greet()
|
||||||
|
|
||||||
main = None
|
main = None
|
||||||
|
|
Loading…
Reference in a new issue