# HG changeset patch # User pieter.lukasse@wur.nl # Date 1421960760 -3600 # Node ID 165c22633081f29a415021b7d806f78b1432aa5c # Parent e19a6fbcf1db4f5be59324dafe84e32fa8221c63 adding log diff -r e19a6fbcf1db -r 165c22633081 nist_wrapper.py --- a/nist_wrapper.py Thu Jan 22 21:52:00 2015 +0100 +++ b/nist_wrapper.py Thu Jan 22 22:06:00 2015 +0100 @@ -22,7 +22,7 @@ -def _prepare_NIST(uuid_value, nist_home_dir, nist_ini_file, spectrum_file, is_wine): +def _prepare_NIST(uuid_value, nist_home_dir, nist_ini_file, spectrum_file, is_wine, log_file): ''' executes the following steps: - copy nist_home_dir folder to nist_home_dir+_uuid @@ -48,6 +48,7 @@ utils.copy_file(spectrum_file, new_nist_home+"/spectrum_file.msp") + log_file.write("configuring NIST input...") # remove old file: os.remove(new_nist_home+"/MSSEARCH/AUTOIMP.MSD") with open(new_nist_home + "/MSSEARCH/AUTOIMP.MSD", "a") as text_file: @@ -70,6 +71,7 @@ # remove old file os.remove(new_nist_home+"/MSSEARCH/nistms.INI") # make new one + log_file.write("configuring NIST ini...") o = open(new_nist_home+"/MSSEARCH/nistms.INI","a") #open for append # TODO : this loop/replace below is a bit limited to specific variables...either test different NIST versions or make more generic (harder in case of wine, or we need extra "home in .INI file" parameter): for line in open(nist_ini_file): @@ -83,7 +85,7 @@ return new_nist_home -def _run_NIST(new_nist_home, output_file, is_wine): +def _run_NIST(new_nist_home, output_file, is_wine, log_file): ''' - run : (wine) new_nist_home/MSSEARCH/nistms$.exe /INSTRUMENT /PAR=2 - monitor : new_nist_home/MSSEARCH/SRCREADY.TXT for content = "1" @@ -114,6 +116,7 @@ pro = "" if is_wine: + log_file.write("calling wine with " + exec_path) print "calling wine with " + exec_path cmd = ["wine "+ exec_path + " /INSTRUMENT /PAR=2"] # The os.setsid() is passed in the argument preexec_fn so @@ -130,6 +133,7 @@ timeSleeping = 0 # monitor process by checking state file: + log_file.write("monitoring SRCREADY.TXT...") while True and timeSleeping < 20: # check if SRCREADY.TXT is there already: if os.path.exists(file_to_monitor): @@ -141,6 +145,7 @@ #p.terminate() - not needed, nistm$ will terminate...nistms.exe is the one that #stays open...and orphan..killing it: + log_file.write("killing wine process...") if is_wine: # pid = utils.get_process_pid("nistms.exe") # os.kill(pid, 9) @@ -287,21 +292,23 @@ spectrum_file = sys.argv[3] nist_output_file = sys.argv[4] final_output_file = sys.argv[5] + output_log_file = sys.argv[6] # html report pars: output_html_report = None output_html_report_files_path = None - if len(sys.argv) > 6: - output_html_report = sys.argv[6] - output_html_report_files_path = sys.argv[7] + if len(sys.argv) > 7: + output_html_report = sys.argv[7] + output_html_report_files_path = sys.argv[8] is_wine = False if "wine" in nist_home_dir: is_wine = True uuid_value = str(uuid.uuid4()) + log_file = open(output_log_file,'w') # prepare NIST environment for running: - new_nist_home = _prepare_NIST(uuid_value, nist_home_dir, nist_ini_file, spectrum_file, is_wine) + new_nist_home = _prepare_NIST(uuid_value, nist_home_dir, nist_ini_file, spectrum_file, is_wine, log_file) # run NIST search command: _run_NIST(new_nist_home, nist_output_file, is_wine) @@ -316,6 +323,7 @@ _create_html_report(output_html_report, output_html_report_files_path, hits_dict, spectra_dict) + log_file.close() #_save_data(enriched_data, headers, output_result) seconds_end = int(round(time.time())) diff -r e19a6fbcf1db -r 165c22633081 nist_wrapper.xml --- a/nist_wrapper.xml Thu Jan 22 21:52:00 2015 +0100 +++ b/nist_wrapper.xml Thu Jan 22 22:06:00 2015 +0100 @@ -17,6 +17,7 @@ $spectraFile $outputFile $outputFileFinal + $outputLog $htmlReportFile $htmlReportFile.files_path