mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Set up back end for master server dir
This commit is contained in:
parent
d7d27b00c4
commit
8a5cc6d1e6
@ -159,3 +159,14 @@ class ManagementController:
|
||||
|
||||
def del_excluded_backup_dir(self, server_id: int, dir_to_del: str):
|
||||
self.management_helper.del_excluded_backup_dir(server_id, dir_to_del)
|
||||
|
||||
# **********************************************************************************
|
||||
# Crafty Methods
|
||||
# **********************************************************************************
|
||||
@staticmethod
|
||||
def get_master_server_dir():
|
||||
return HelpersManagement.get_master_server_dir()
|
||||
|
||||
@staticmethod
|
||||
def set_master_server_dir(server_dir):
|
||||
HelpersManagement.set_master_server_dir(server_dir)
|
||||
|
@ -44,6 +44,7 @@ class AuditLog(BaseModel):
|
||||
class CraftySettings(BaseModel):
|
||||
secret_api_key = CharField(default="")
|
||||
login_photo = CharField(default="login_1.jpg")
|
||||
master_server_dir = CharField(default="")
|
||||
|
||||
class Meta:
|
||||
table_name = "crafty_settings"
|
||||
@ -268,6 +269,19 @@ class HelpersManagement:
|
||||
CraftySettings.id == 1
|
||||
).execute()
|
||||
|
||||
@staticmethod
|
||||
def get_master_server_dir():
|
||||
settings = CraftySettings.select(CraftySettings.master_server_dir).where(
|
||||
CraftySettings.id == 1
|
||||
)
|
||||
return settings[0].master_server_dir
|
||||
|
||||
@staticmethod
|
||||
def set_master_server_dir(server_dir):
|
||||
CraftySettings.update({CraftySettings.master_server_dir: server_dir}).where(
|
||||
CraftySettings.id == 1
|
||||
).execute()
|
||||
|
||||
# **********************************************************************************
|
||||
# Schedules Methods
|
||||
# **********************************************************************************
|
||||
|
@ -972,3 +972,7 @@ class Controller:
|
||||
@staticmethod
|
||||
def clear_support_status():
|
||||
HelperUsers.clear_support_status()
|
||||
|
||||
def set_master_server_dir(self, server_dir):
|
||||
self.helper.servers_dir = server_dir
|
||||
HelpersManagement.set_master_server_dir(server_dir)
|
||||
|
18
app/migrations/20230126_master_server.py
Normal file
18
app/migrations/20230126_master_server.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by database migrator
|
||||
import peewee
|
||||
|
||||
|
||||
def migrate(migrator, database, **kwargs):
|
||||
migrator.add_columns(
|
||||
"crafty_settings", master_server_dir=peewee.CharField(default="")
|
||||
)
|
||||
"""
|
||||
Write your migrations here.
|
||||
"""
|
||||
|
||||
|
||||
def rollback(migrator, database, **kwargs):
|
||||
migrator.drop_columns("crafty_settings", ["master_server_dir"])
|
||||
"""
|
||||
Write your rollback migrations here.
|
||||
"""
|
9
main.py
9
main.py
@ -210,6 +210,15 @@ if __name__ == "__main__":
|
||||
running_mode = "Interactive"
|
||||
|
||||
controller.set_project_root(application_path)
|
||||
master_server_dir = controller.management.get_master_server_dir()
|
||||
if master_server_dir == "":
|
||||
Console.warning("Could not find master server path. Setting default")
|
||||
controller.set_master_server_dir(
|
||||
os.path.join(controller.project_root, "servers")
|
||||
)
|
||||
else:
|
||||
helper.servers_dir = master_server_dir
|
||||
|
||||
Console.debug(f"Execution Mode: {running_mode}")
|
||||
Console.debug(f"Application path : '{application_path}'")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user