@@ -85,14 +85,11 @@ def add_arguments_to_parser(parser):
8585 default = default_workspace ,
8686 required = False ,
8787 help = "Directory where CodeChecker can store analysis "
88- "result related data, such as the database. "
89- "(Cannot be specified at the same time with "
90- "'--sqlite' or '--config-directory'.)" )
88+ "result related data, such as the database." )
9189
9290 parser .add_argument ('-f' , '--config-directory' ,
9391 type = str ,
9492 dest = "config_directory" ,
95- default = default_workspace ,
9693 required = False ,
9794 help = "Directory where CodeChecker server should read "
9895 "server-specific configuration (such as "
@@ -169,9 +166,6 @@ def add_arguments_to_parser(parser):
169166 type = str ,
170167 dest = "sqlite" ,
171168 metavar = 'SQLITE_FILE' ,
172- default = os .path .join (
173- '<CONFIG_DIRECTORY>' ,
174- "config.sqlite" ),
175169 required = False ,
176170 help = "Path of the SQLite database file to use." )
177171
@@ -373,54 +367,22 @@ def arg_match(options):
373367 # is intended later on.
374368 delattr (args , 'not_host_only' )
375369
376- # --workspace and --sqlite cannot be specified either, as
377- # both point to a database location.
378- options = ['--sqlite' , '--workspace' ]
379- options_short = ['--sqlite' , '-w' ]
380- if set (arg_match (options )) == set (options ) or \
381- set (arg_match (options_short )) == set (options_short ):
382- parser .error ("argument --sqlite: not allowed with "
383- "argument --workspace" )
384-
385- # --workspace and --config-directory also aren't allowed together now,
386- # the latter one is expected to replace the earlier.
387- options = ['--config-directory' , '--workspace' ]
388- options_short = ['--config-directory' , '-w' ]
389- if set (arg_match (options )) == set (options ) or \
390- set (arg_match (options_short )) == set (options_short ):
391- parser .error ("argument --config-directory: not allowed with "
392- "argument --workspace" )
393-
394370 # If workspace is specified, sqlite is workspace/config.sqlite
395371 # and config_directory is the workspace directory.
396- if arg_match ([ '--workspace' , '-w' ]) :
372+ if not args . config_directory :
397373 args .config_directory = args .workspace
374+
375+ if not args .sqlite :
398376 args .sqlite = os .path .join (args .workspace ,
399377 'config.sqlite' )
400- setattr (args , 'dbdatadir' , os .path .join (args .workspace ,
401- 'pgsql_data' ))
402-
403- # Workspace should not exist as a Namespace key.
404- delattr (args , 'workspace' )
405-
406- if '<CONFIG_DIRECTORY>' in args .sqlite :
407- # Replace the placeholder variable with the actual value.
408- args .sqlite = args .sqlite .replace ('<CONFIG_DIRECTORY>' ,
409- args .config_directory )
410378
411379 # Convert relative sqlite file path to absolute.
412- if 'sqlite' in args :
413- args .sqlite = os .path .abspath (args .sqlite )
380+ args .sqlite = os .path .abspath (args .sqlite )
414381
415382 if 'postgresql' not in args :
416383 # Later called database modules need the argument to be actually
417384 # present, even though the default is suppressed in the optstring.
418385 setattr (args , 'postgresql' , False )
419-
420- # This is not needed by the database starter as we are
421- # running SQLite.
422- if 'dbdatadir' in args :
423- delattr (args , 'dbdatadir' )
424386 else :
425387 # If --postgresql is given, --sqlite is useless.
426388 delattr (args , 'sqlite' )
@@ -429,6 +391,10 @@ def arg_match(options):
429391 if "list" in args or "stop" in args or "stop_all" in args :
430392 setattr (args , "instance_manager" , True )
431393
394+ # Log directories
395+ LOG .info (f"Workspace directory: { args .workspace } " )
396+ LOG .info (f"Config directory: { args .config_directory } " )
397+
432398 # If everything is fine, do call the handler for the subcommand.
433399 return main (args )
434400
@@ -808,7 +774,7 @@ def __instance_management(args):
808774 if 'stop' in args and \
809775 not (i ['port' ] == args .view_port and
810776 os .path .abspath (i ['workspace' ]) ==
811- os .path .abspath (args .config_directory )):
777+ os .path .abspath (args .workspace )):
812778 continue
813779
814780 try :
@@ -836,7 +802,7 @@ def __reload_config(args):
836802 if 'reload' in args and \
837803 not (i ['port' ] == args .view_port and
838804 os .path .abspath (i ['workspace' ]) ==
839- os .path .abspath (args .config_directory )):
805+ os .path .abspath (args .workspace )):
840806 continue
841807
842808 try :
@@ -890,13 +856,6 @@ def server_init_start(args):
890856 if not host_check .check_zlib ():
891857 raise ModuleNotFoundError ("zlib is not available on the system!" )
892858
893- # WARNING
894- # In case of SQLite args.dbaddress default value is used
895- # for which the is_localhost should return true.
896- if is_localhost (args .dbaddress ) and \
897- not os .path .exists (args .config_directory ):
898- os .makedirs (args .config_directory )
899-
900859 # Make sure the SQLite file can be created if it not exists.
901860 if 'sqlite' in args and \
902861 not os .path .isdir (os .path .dirname (args .sqlite )):
@@ -907,7 +866,7 @@ def server_init_start(args):
907866 "option. The server will ask for users to authenticate!" )
908867
909868 context = webserver_context .get_context ()
910- context .codechecker_workspace = args .config_directory
869+ context .codechecker_workspace = args .workspace
911870 context .db_username = args .dbusername
912871
913872 environ = env .extend (context .path_env_extra ,
@@ -993,8 +952,8 @@ def server_init_start(args):
993952
994953 # Create the main database link from the arguments passed over the
995954 # command line.
996- cfg_dir = os .path .abspath (args .config_directory )
997- default_product_path = os .path .join (cfg_dir , 'Default.sqlite' )
955+ workspace_dir = os .path .abspath (args .workspace )
956+ default_product_path = os .path .join (workspace_dir , 'Default.sqlite' )
998957 create_default_product = 'sqlite' in args and \
999958 not os .path .exists (default_product_path )
1000959
@@ -1073,6 +1032,7 @@ def server_init_start(args):
10731032
10741033 try :
10751034 return server .start_server (args .config_directory ,
1035+ args .workspace ,
10761036 package_data ,
10771037 args .view_port ,
10781038 cfg_sql_server ,
@@ -1098,20 +1058,21 @@ def main(args):
10981058 Setup a logger server based on the configuration and
10991059 manage the CodeChecker server.
11001060 """
1101- workspace = (
1102- args .config_directory
1103- if "config_directory" in args and not hasattr (args , "instance_manager" )
1104- else None
1105- )
11061061
11071062 # Create workspace directory before logging is initialized.
1108- if workspace and not os .path .exists (args .config_directory ):
1109- LOG .info ("Creating non existing config directory: %s" ,
1110- args .config_directory )
1111- os .makedirs (args .config_directory )
1063+ if not hasattr (args , "instance_manager" ):
1064+ if not os .path .exists (args .workspace ):
1065+ LOG .info ("Creating non existing workspace directory: %s" ,
1066+ args .workspace )
1067+ os .makedirs (args .workspace )
1068+
1069+ if not os .path .exists (args .config_directory ):
1070+ LOG .info ("Creating non existing config directory: %s" ,
1071+ args .config_directory )
1072+ os .makedirs (args .config_directory )
11121073
11131074 with logger .LogCfgServer (
1114- args .verbose if "verbose" in args else None , workspace = workspace
1075+ args .verbose if "verbose" in args else None , workspace = args . workspace
11151076 ):
11161077 try :
11171078 cmd_config .check_config_file (args )
0 commit comments