@@ -45,24 +45,8 @@ def write_configfile(config, config_path):
4545 config .write (configfile )
4646
4747
48- def create_workspace (workspace_name , p_loader = None ):
49- """
50- Create a new workspace with the given name.
51-
52- Args:
53- ----
54- workspace_name (str): The name of the workspace.
55-
56- Returns:
57- -------
58- None
59- """
60- if exists (path_join (WORKSPACE_DIR , workspace_name )):
61- print (f"[-] Workspace { workspace_name } already exists" )
62- else :
63- print (f"[*] Creating { workspace_name } workspace" )
64- mkdir (path_join (WORKSPACE_DIR , workspace_name ))
65-
48+ def init_protocol_dbs (workspace_name , p_loader = None ):
49+ """Check for each protocol if the database exists, if not create it."""
6650 if p_loader is None :
6751 p_loader = ProtocolLoader ()
6852 protocols = p_loader .get_protocols ()
@@ -87,11 +71,35 @@ def create_workspace(workspace_name, p_loader=None):
8771 conn .close ()
8872
8973
74+ def create_workspace (workspace_name , p_loader = None ):
75+ """
76+ Create a new workspace with the given name.
77+
78+ Args:
79+ ----
80+ workspace_name (str): The name of the workspace.
81+
82+ Returns:
83+ -------
84+ None
85+ """
86+ if exists (path_join (WORKSPACE_DIR , workspace_name )):
87+ print (f"[-] Workspace { workspace_name } already exists" )
88+ else :
89+ print (f"[*] Creating { workspace_name } workspace" )
90+ mkdir (path_join (WORKSPACE_DIR , workspace_name ))
91+
92+ init_protocol_dbs (workspace_name , p_loader )
93+
94+
9095def delete_workspace (workspace_name ):
9196 shutil .rmtree (path_join (WORKSPACE_DIR , workspace_name ))
9297 print (f"[*] Workspace { workspace_name } deleted" )
9398
9499
95100def initialize_db ():
96101 if not exists (path_join (WORKSPACE_DIR , "default" )):
97- create_workspace ("default" )
102+ create_workspace ("default" )
103+
104+ # Even if the default workspace exists, we still need to check if every protocol has a database (in case of a new protocol)
105+ init_protocol_dbs ("default" )
0 commit comments