MCPcopy Index your code
hub / github.com/dothinking/PyAddin / __check_log_files

Function __check_log_files

pyaddin/resources/scripts/utils/context.py:99–130  ·  view source on GitHub ↗

Get log file names from configuration file.

(working_path:str)

Source from the content-addressed store, hash-verified

97
98
99def __check_log_files(working_path:str):
100 '''Get log file names from configuration file.'''
101 # default value
102 path_name = OUTPUT_PATH_NAME
103 output_name, error_name, debug_name = LOG_OUTPUT_NAME, LOG_ERROR_NAME, LOG_DEBUG_NAME
104
105 # check config file
106 config_file = os.path.join(working_path, CONFIG_FILENAME)
107 with open(config_file, 'r') as f:
108 while True:
109 line = f.readline()
110 if not line:
111 break
112 elif line.startswith('[output]'):
113 path_name = f.readline().strip()
114 elif line.startswith('[stdout]'):
115 output_name = f.readline().strip()
116 elif line.startswith('[stderr]'):
117 error_name = f.readline().strip()
118 elif line.startswith('[log]'):
119 debug_name = f.readline().strip()
120 # create output path
121 output_path = os.path.join(working_path, path_name)
122 if not os.path.exists(output_path):
123 os.mkdir(output_path)
124
125 # join path
126 output_file = os.path.join(output_path, output_name)
127 error_file = os.path.join(output_path, error_name)
128 debug_file = os.path.join(output_path, debug_name)
129
130 return output_file, error_file, debug_file

Callers 1

__config_loggerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected