mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Remove config.json from repo.
Remove version checking. Move master config to helpers. Add config.json when not found on start.
This commit is contained in:
parent
3c0330de38
commit
8ee274a927
@ -392,6 +392,33 @@ class Helpers:
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def get_master_config():
|
||||
# Make changes for users' local config.json files here. As of 4.0.20
|
||||
# Config.json was removed from the repo to make it easier for users
|
||||
# To make non-breaking changes to the file.
|
||||
return {
|
||||
"http_port": 8000,
|
||||
"https_port": 8443,
|
||||
"language": "en_EN",
|
||||
"cookie_expire": 30,
|
||||
"cookie_secret": "random",
|
||||
"apikey_secret": "random",
|
||||
"show_errors": True,
|
||||
"history_max_age": 7,
|
||||
"stats_update_frequency": 30,
|
||||
"delete_default_json": False,
|
||||
"show_contribute_link": True,
|
||||
"virtual_terminal_lines": 70,
|
||||
"max_log_lines": 700,
|
||||
"max_audit_entries": 300,
|
||||
"disabled_language_files": ["lol_EN.json", ""],
|
||||
"stream_size_GB": 1,
|
||||
"keywords": ["help", "chunk"],
|
||||
"allow_nsfw_profile_pictures": False,
|
||||
"enable_user_self_delete": False,
|
||||
}
|
||||
|
||||
def get_all_settings(self):
|
||||
try:
|
||||
with open(self.settings_file, "r", encoding="utf-8") as f:
|
||||
|
@ -245,38 +245,14 @@ class Controller:
|
||||
)
|
||||
|
||||
def get_config_diff(self):
|
||||
master_config = {
|
||||
"config_ver": 1,
|
||||
"http_port": 8000,
|
||||
"https_port": 8443,
|
||||
"language": "en_EN",
|
||||
"cookie_expire": 30,
|
||||
"cookie_secret": "random",
|
||||
"apikey_secret": "random",
|
||||
"show_errors": True,
|
||||
"history_max_age": 7,
|
||||
"stats_update_frequency": 30,
|
||||
"delete_default_json": False,
|
||||
"show_contribute_link": True,
|
||||
"virtual_terminal_lines": 70,
|
||||
"max_log_lines": 700,
|
||||
"max_audit_entries": 300,
|
||||
"disabled_language_files": ["lol_EN.json", ""],
|
||||
"stream_size_GB": 1,
|
||||
"keywords": ["help", "chunk"],
|
||||
"allow_nsfw_profile_pictures": False,
|
||||
"enable_user_self_delete": False,
|
||||
}
|
||||
user_config = self.helper.get_all_settings()
|
||||
# Check user's config version
|
||||
master_config = Helpers.get_master_config()
|
||||
try:
|
||||
# If they are on the same version there is no need to remove this.
|
||||
if user_config["config_ver"] == master_config["config_ver"]:
|
||||
return user_config
|
||||
else:
|
||||
user_config["config_ver"] = master_config["config_ver"]
|
||||
user_config = self.helper.get_all_settings()
|
||||
except:
|
||||
logger.debug("No config version found")
|
||||
# Call helper to set updated config.
|
||||
Console.warning("No Config found. Setting Default Config.json")
|
||||
self.helper.set_settings(master_config)
|
||||
return
|
||||
items_to_del = []
|
||||
|
||||
# Iterate through user's config.json and check for
|
||||
@ -293,7 +269,6 @@ class Controller:
|
||||
for key, value in master_config.items():
|
||||
if key not in user_config.keys():
|
||||
user_config[key] = value
|
||||
|
||||
# Call helper to set updated config.
|
||||
self.helper.set_settings(user_config)
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
{
|
||||
"http_port": 8000,
|
||||
"https_port": 8443,
|
||||
"language": "en_EN",
|
||||
"cookie_expire": 30,
|
||||
"cookie_secret": "random",
|
||||
"apikey_secret": "random",
|
||||
"show_errors": true,
|
||||
"history_max_age": 7,
|
||||
"stats_update_frequency": 30,
|
||||
"delete_default_json": false,
|
||||
"show_contribute_link": true,
|
||||
"virtual_terminal_lines": 70,
|
||||
"max_log_lines": 700,
|
||||
"max_audit_entries": 300,
|
||||
"disabled_language_files": [
|
||||
"lol_EN.json",
|
||||
""
|
||||
],
|
||||
"stream_size_GB": 1,
|
||||
"keywords": [
|
||||
"help",
|
||||
"chunk"
|
||||
],
|
||||
"allow_nsfw_profile_pictures": false,
|
||||
"enable_user_self_delete": false
|
||||
}
|
7
main.py
7
main.py
@ -53,6 +53,9 @@ def do_intro():
|
||||
"""
|
||||
|
||||
Console.magenta(intro)
|
||||
if not helper.check_file_exists(helper.settings_file):
|
||||
Console.debug("No settings file detected. Creating one.")
|
||||
helper.set_settings(Helpers.get_master_config())
|
||||
|
||||
|
||||
def setup_logging(debug=True):
|
||||
@ -139,6 +142,9 @@ if __name__ == "__main__":
|
||||
import_helper = ImportHelpers(helper, file_helper)
|
||||
# now the tables are created, we can load the tasks_manager and server controller
|
||||
controller = Controller(database, helper, file_helper, import_helper)
|
||||
Console.info("Checking for remote changes to config.json")
|
||||
controller.get_config_diff()
|
||||
Console.info("Remote change complete.")
|
||||
import3 = Import3(helper, controller)
|
||||
tasks_manager = TasksManager(helper, controller)
|
||||
tasks_manager.start_webserver()
|
||||
@ -159,7 +165,6 @@ if __name__ == "__main__":
|
||||
logger.info("Initializing all servers defined")
|
||||
Console.info("Initializing all servers defined")
|
||||
controller.servers.init_all_servers()
|
||||
controller.get_config_diff()
|
||||
|
||||
def tasks_starter():
|
||||
# start stats logging
|
||||
|
Loading…
Reference in New Issue
Block a user