def check_or_request_fp_file(f_input_file: str, file_number: int, test_input: str = '') -> str: """ >>> fp_conf.interactive = True >>> check_or_request_fp_file(f_input_file='./testfiles/', file_number=1,test_input='./testfiles_source/fp_files_result1_difftest.csv') './testfiles_source/fp_files_result1_difftest.csv' >>> fp_conf.interactive = False >>> check_or_request_fp_file(f_input_file='./testfiles/', file_number=1) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE Traceback (most recent call last): ... SystemExit: 1 >>> fp_conf.interactive = False >>> check_or_request_fp_file(f_input_file='./testfiles_source/fp_files_result1_difftest.csv', file_number=1) './testfiles_source/fp_files_result1_difftest.csv' """ while not is_fp_input_file_ok(f_input_file): if fp_conf.interactive: if test_input: f_input_file = test_input else: f_input_file = input( 'file {} to fingerprint (e.g. c:\\test\\ ): '.format( file_number)) if not is_fp_input_file_ok(f_input_file): logger.info( 'can not read file {}, try again'.format(f_input_file)) lib_helper_functions.logger_flush_all_handlers() else: break else: logger.info('can not read file {}'.format(f_input_file)) lib_helper_functions.logger_flush_all_handlers() sys.exit(1) return f_input_file
def check_or_request_fp_dir(test_input: str = ''): """ >>> import test >>> timestamp = time.time() >>> test.create_testfiles_fingerprint_1(timestamp) >>> fp_conf.interactive = False >>> fp_files_conf.fp_dir = './testfiles/' >>> check_or_request_fp_dir() >>> fp_files_conf.fp_dir = './not_exist/' >>> check_or_request_fp_dir() # +ELLIPSIS, +NORMALIZE_WHITESPACE Traceback (most recent call last): ... SystemExit: 1 >>> fp_conf.interactive = True >>> check_or_request_fp_dir(test_input='./testfiles/') # +ELLIPSIS, +NORMALIZE_WHITESPACE can not read directory ./not_exist/ """ while not is_fp_dir_ok(): if fp_conf.interactive: if test_input: fp_files_conf.fp_dir = test_input else: fp_files_conf.fp_dir = input( 'directory to fingerprint (e.g. c:\\test\\ ): ') if not is_fp_dir_ok(): logger.info('can not read directory {}, try again'.format( fp_files_conf.fp_dir)) lib_helper_functions.logger_flush_all_handlers() else: break else: logger.info('can not read directory {}'.format( fp_files_conf.fp_dir)) lib_helper_functions.logger_flush_all_handlers() sys.exit(1)
def exit_message(): logger.info('Finished\n\n') lib_helper_functions.logger_flush_all_handlers() if fp_conf.interactive: input('enter for exit, check the logfile')