@@ -190,7 +190,10 @@ def update_config(
190190 ATTENTION: will overwrite the environment if it exist.
191191 """
192192 if not os .path .isfile (path ):
193- sys .exit (color_error_msg ('The configuration file does not exist.' ))
193+ logging .info (
194+ color_error_msg ('The configuration file does not exist.' )
195+ )
196+ sys .exit (CodeError .FILE_DOES_NOT_EXIST )
194197 config = configparser .ConfigParser ()
195198 config .read (path )
196199 env = {
@@ -215,7 +218,9 @@ def update_config(
215218 for key , value in env .items (): # noqa: WPS110
216219 if value is not None :
217220 config [environment ][key ] = str (value )
218- return sys .exit (write_config_file (config , path ))
221+
222+ write_config_file (config , path )
223+ return sys .exit (CodeError .SUCCESS )
219224
220225
221226@main .command () # noqa: C901,WPS213
@@ -236,16 +241,15 @@ def update_config(
236241def create_backup (environment , save_type , path ): # noqa: C901,WPS213
237242 """Creates a backup according to the settings of the selected environment."""
238243 if not os .path .isfile (path ):
239- sys .exit (
240- color_error_msg (
241- 'The configuration file {0} does not exist.' .format (path )
242- )
244+ logging .info (
245+ 'The configuration file {0} does not exist.' .format (path )
243246 )
247+ return sys .exit (CodeError .FILE_DOES_NOT_EXIST )
244248
245249 config = configparser .ConfigParser (default_section = 'common' , allow_no_value = True )
246250 config .read (path )
247251 if not save_type :
248- save_type = environment
252+ save_type = 'local' if environment == 'test' else environment
249253 try :
250254 plugin = getattr (
251255 importlib .import_module (
@@ -262,7 +266,8 @@ def create_backup(environment, save_type, path): # noqa: C901,WPS213
262266 try :
263267 bk_handler .check_config ()
264268 except Exception as exp :
265- sys .exit (color_error_msg (exp ))
269+ logging .info (color_error_msg (exp ))
270+ return sys .exit (CodeError .NO_SETTINGS )
266271
267272 if config [environment ].get ('with_db' ):
268273 dump_db (config , environment )
0 commit comments