comparison nist_wrapper.py @ 20:3abd271b4626 default tip

killing nist at exception
author pieter.lukasse@wur.nl
date Fri, 23 Jan 2015 17:57:00 +0100
parents a394029414c6
children
comparison
equal deleted inserted replaced
19:a394029414c6 20:3abd271b4626
140 time.sleep(2) 140 time.sleep(2)
141 timeSleeping = timeSleeping+2 141 timeSleeping = timeSleeping+2
142 if timeSleeping > (startUpTime + job_size*2): 142 if timeSleeping > (startUpTime + job_size*2):
143 # abort with timeout: 143 # abort with timeout:
144 utils.log_message(log_file, "No results after " + str(timeSleeping) + " seconds...") 144 utils.log_message(log_file, "No results after " + str(timeSleeping) + " seconds...")
145 _kill_NIST(pro, is_wine)
145 # uggly workaround: 146 # uggly workaround:
146 utils.kill_process_by_name("nistms.exe") 147 utils.kill_process_by_name("nistms.exe")
147 utils.kill_process_by_name("nistms$.exe") 148 utils.kill_process_by_name("nistms$.exe")
148 raise Exception('Error: timeout waiting for NIST results.') 149 raise Exception('Error: timeout waiting for NIST results.')
149 150
150 utils.log_message(log_file, "done...") 151 utils.log_message(log_file, "done...")
151 # kill process: 152 # kill process:
152 #p.terminate() - not needed, nistm$ will terminate...nistms.exe is the one that 153 #p.terminate() - not needed, nistm$ will terminate...nistms.exe is the one that
153 #stays open...and orphan..killing it: 154 #stays open...and orphan..killing it:
154 155 _kill_NIST(pro, is_wine)
156
157 # copy SRCRESLT.TXT to output_file
158 result_file = new_nist_home+"/MSSEARCH/SRCRESLT.TXT"
159 utils.copy_file(result_file, output_file)
160
161
162
163 def _kill_NIST(process_group, is_wine):
164 '''
165 nistm$ will terminate...nistms.exe is the one that
166 stays open...and orphan. This method kills it.
167 '''
155 if is_wine: 168 if is_wine:
156 # pid = utils.get_process_pid("nistms.exe") 169 # pid = utils.get_process_pid("nistms.exe")
157 # os.kill(pid, 9) 170 # os.kill(pid, 9)
158 os.killpg(pro.pid, 9) 171 os.killpg(process_group.pid, 9)
159 else: 172 else:
160 # windows case: 173 # windows case:
161 proc_name = "nistms.exe" 174 proc_name = "nistms.exe"
162 os.system("taskkill /f /im " + proc_name) 175 os.system("taskkill /f /im " + proc_name)
163 176
164 # copy SRCRESLT.TXT to output_file 177
165 result_file = new_nist_home+"/MSSEARCH/SRCRESLT.TXT"
166 utils.copy_file(result_file, output_file)
167 178
168 179
169 def _create_html_report(output_html_report, output_html_report_files_path, hits_dict, spectra_dict): 180 def _create_html_report(output_html_report, output_html_report_files_path, hits_dict, spectra_dict):
170 ''' 181 '''
171 This report will contain a page that displays essentially the same list as found in the 182 This report will contain a page that displays essentially the same list as found in the