@@ -87,14 +87,11 @@ def add_arguments_to_parser(parser):
8787 default = default_workspace ,
8888 required = False ,
8989 help = "Directory where CodeChecker can store analysis "
90- "result related data, such as the database. "
91- "(Cannot be specified at the same time with "
92- "'--sqlite' or '--config-directory'.)" )
90+ "result related data, such as the database." )
9391
9492 parser .add_argument ('-f' , '--config-directory' ,
9593 type = str ,
9694 dest = "config_directory" ,
97- default = default_workspace ,
9895 required = False ,
9996 help = "Directory where CodeChecker server should read "
10097 "server-specific configuration (such as "
@@ -152,9 +149,6 @@ def add_arguments_to_parser(parser):
152149 type = str ,
153150 dest = "sqlite" ,
154151 metavar = 'SQLITE_FILE' ,
155- default = os .path .join (
156- '<CONFIG_DIRECTORY>' ,
157- "config.sqlite" ),
158152 required = False ,
159153 help = "Path of the SQLite database file to use." )
160154
@@ -356,54 +350,22 @@ def arg_match(options):
356350 # is intended later on.
357351 delattr (args , 'not_host_only' )
358352
359- # --workspace and --sqlite cannot be specified either, as
360- # both point to a database location.
361- options = ['--sqlite' , '--workspace' ]
362- options_short = ['--sqlite' , '-w' ]
363- if set (arg_match (options )) == set (options ) or \
364- set (arg_match (options_short )) == set (options_short ):
365- parser .error ("argument --sqlite: not allowed with "
366- "argument --workspace" )
367-
368- # --workspace and --config-directory also aren't allowed together now,
369- # the latter one is expected to replace the earlier.
370- options = ['--config-directory' , '--workspace' ]
371- options_short = ['--config-directory' , '-w' ]
372- if set (arg_match (options )) == set (options ) or \
373- set (arg_match (options_short )) == set (options_short ):
374- parser .error ("argument --config-directory: not allowed with "
375- "argument --workspace" )
376-
377353 # If workspace is specified, sqlite is workspace/config.sqlite
378354 # and config_directory is the workspace directory.
379- if arg_match ([ '--workspace' , '-w' ]) :
355+ if not args . config_directory :
380356 args .config_directory = args .workspace
357+
358+ if not args .sqlite :
381359 args .sqlite = os .path .join (args .workspace ,
382360 'config.sqlite' )
383- setattr (args , 'dbdatadir' , os .path .join (args .workspace ,
384- 'pgsql_data' ))
385-
386- # Workspace should not exist as a Namespace key.
387- delattr (args , 'workspace' )
388-
389- if '<CONFIG_DIRECTORY>' in args .sqlite :
390- # Replace the placeholder variable with the actual value.
391- args .sqlite = args .sqlite .replace ('<CONFIG_DIRECTORY>' ,
392- args .config_directory )
393361
394362 # Convert relative sqlite file path to absolute.
395- if 'sqlite' in args :
396- args .sqlite = os .path .abspath (args .sqlite )
363+ args .sqlite = os .path .abspath (args .sqlite )
397364
398365 if 'postgresql' not in args :
399366 # Later called database modules need the argument to be actually
400367 # present, even though the default is suppressed in the optstring.
401368 setattr (args , 'postgresql' , False )
402-
403- # This is not needed by the database starter as we are
404- # running SQLite.
405- if 'dbdatadir' in args :
406- delattr (args , 'dbdatadir' )
407369 else :
408370 # If --postgresql is given, --sqlite is useless.
409371 delattr (args , 'sqlite' )
@@ -412,6 +374,10 @@ def arg_match(options):
412374 if "list" in args or "stop" in args or "stop_all" in args :
413375 setattr (args , "instance_manager" , True )
414376
377+ # Log directories
378+ LOG .info (f"Workspace directory: { args .workspace } " )
379+ LOG .info (f"Config directory: { args .config_directory } " )
380+
415381 # If everything is fine, do call the handler for the subcommand.
416382 main (args )
417383
@@ -827,7 +793,7 @@ def __instance_management(args):
827793 if 'stop' in args and \
828794 not (i ['port' ] == args .view_port and
829795 os .path .abspath (i ['workspace' ]) ==
830- os .path .abspath (args .config_directory )):
796+ os .path .abspath (args .workspace )):
831797 continue
832798
833799 try :
@@ -855,7 +821,7 @@ def __reload_config(args):
855821 if 'reload' in args and \
856822 not (i ['port' ] == args .view_port and
857823 os .path .abspath (i ['workspace' ]) ==
858- os .path .abspath (args .config_directory )):
824+ os .path .abspath (args .workspace )):
859825 continue
860826
861827 try :
@@ -909,13 +875,6 @@ def server_init_start(args):
909875 if not host_check .check_zlib ():
910876 raise ModuleNotFoundError ("zlib is not available on the system!" )
911877
912- # WARNING
913- # In case of SQLite args.dbaddress default value is used
914- # for which the is_localhost should return true.
915- if is_localhost (args .dbaddress ) and \
916- not os .path .exists (args .config_directory ):
917- os .makedirs (args .config_directory )
918-
919878 # Make sure the SQLite file can be created if it not exists.
920879 if 'sqlite' in args and \
921880 not os .path .isdir (os .path .dirname (args .sqlite )):
@@ -926,7 +885,7 @@ def server_init_start(args):
926885 "option. The server will ask for users to authenticate!" )
927886
928887 context = webserver_context .get_context ()
929- context .codechecker_workspace = args .config_directory
888+ context .codechecker_workspace = args .workspace
930889 context .db_username = args .dbusername
931890
932891 environ = env .extend (context .path_env_extra ,
@@ -1012,8 +971,8 @@ def server_init_start(args):
1012971
1013972 # Create the main database link from the arguments passed over the
1014973 # command line.
1015- cfg_dir = os .path .abspath (args .config_directory )
1016- default_product_path = os .path .join (cfg_dir , 'Default.sqlite' )
974+ workspace_dir = os .path .abspath (args .workspace )
975+ default_product_path = os .path .join (workspace_dir , 'Default.sqlite' )
1017976 create_default_product = 'sqlite' in args and \
1018977 not os .path .exists (default_product_path )
1019978
@@ -1088,6 +1047,7 @@ def server_init_start(args):
10881047
10891048 try :
10901049 server .start_server (args .config_directory ,
1050+ args .workspace ,
10911051 package_data ,
10921052 args .view_port ,
10931053 cfg_sql_server ,
@@ -1112,20 +1072,21 @@ def main(args):
11121072 Setup a logger server based on the configuration and
11131073 manage the CodeChecker server.
11141074 """
1115- workspace = (
1116- args .config_directory
1117- if "config_directory" in args and not hasattr (args , "instance_manager" )
1118- else None
1119- )
11201075
11211076 # Create workspace directory before logging is initialized.
1122- if workspace and not os .path .exists (args .config_directory ):
1123- LOG .info ("Creating non existing config directory: %s" ,
1124- args .config_directory )
1125- os .makedirs (args .config_directory )
1077+ if not hasattr (args , "instance_manager" ):
1078+ if not os .path .exists (args .workspace ):
1079+ LOG .info ("Creating non existing workspace directory: %s" ,
1080+ args .workspace )
1081+ os .makedirs (args .workspace )
1082+
1083+ if not os .path .exists (args .config_directory ):
1084+ LOG .info ("Creating non existing config directory: %s" ,
1085+ args .config_directory )
1086+ os .makedirs (args .config_directory )
11261087
11271088 with logger .LogCfgServer (
1128- args .verbose if "verbose" in args else None , workspace = workspace
1089+ args .verbose if "verbose" in args else None , workspace = args . workspace
11291090 ):
11301091 try :
11311092 cmd_config .check_config_file (args )
0 commit comments