Mercurial > repos > pieterlukasse > nist_wrapper
changeset 17:82368bd06e1d
small improvements
author | pieter.lukasse@wur.nl |
---|---|
date | Fri, 23 Jan 2015 17:13:06 +0100 |
parents | c21e96bb68c8 |
children | dae90b9abf61 |
files | nist_wrapper.py templates/spectrum_gen.js |
diffstat | 2 files changed, 26 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/nist_wrapper.py Fri Jan 23 14:57:55 2015 +0100 +++ b/nist_wrapper.py Fri Jan 23 17:13:06 2015 +0100 @@ -133,8 +133,6 @@ startUpTime = 30 # monitor process by checking state file: utils.log_message(log_file, "monitoring SRCREADY.TXT...") - # TODO2: do the controller part - # TODO3: do the popover part while True: # check if SRCREADY.TXT is there already: if os.path.exists(file_to_monitor): @@ -143,9 +141,10 @@ timeSleeping = timeSleeping+2 if timeSleeping > (startUpTime + job_size*2): # abort with timeout: - utils.log_message(log_file, "No results after " + timeSleeping + " seconds...") + utils.log_message(log_file, "No results after " + str(timeSleeping) + " seconds...") raise Exception('Error: timeout waiting for NIST results.') + utils.log_message(log_file, "done...") # kill process: #p.terminate() - not needed, nistm$ will terminate...nistms.exe is the one that #stays open...and orphan..killing it:
--- a/templates/spectrum_gen.js Fri Jan 23 14:57:55 2015 +0100 +++ b/templates/spectrum_gen.js Fri Jan 23 17:13:06 2015 +0100 @@ -90,20 +90,28 @@ } catch(e) { - //assume running locally: - alert("Error while trying to get data from NIST. Rendering library spectrum with dummy data."); - peakTable = "55,290 56,240 57,100 58,80"+ - " 63,30 65,150 66,50 67,1271"+ - " 68,370 69,100 70,210 71,10"+ - " 74,50 75,60 76,120 77,2312"+ - " 78,220 79,120 80,190 81,630"+ - " 82,4884 83,2702 84,240 85,20"+ - " 91,180 92,50 93,210 94,3353"+ - " 95,1371 96,1261 97,370 98,120"+ - " 105,1621 106,160 107,70 108,220"+ - " 109,80 110,60 111,30 112,40"+ - " 121,30 122,460 123,940 124,9999"; - //note that the intensities in jcamp response are 10x when compared to MSP format + try + { + //workaround for galaxy.wur.nl/galaxy_production/ scenario TODO: make more robust code: + peakTable = httpGet2("/galaxy_production/nist_controller/get_nistdata?casnr="+casNr); + } + catch(e2) + { + //assume running locally: + alert("Error while trying to get data from NIST. Rendering library spectrum with dummy data."); + peakTable = "55,290 56,240 57,100 58,80"+ + " 63,30 65,150 66,50 67,1271"+ + " 68,370 69,100 70,210 71,10"+ + " 74,50 75,60 76,120 77,2312"+ + " 78,220 79,120 80,190 81,630"+ + " 82,4884 83,2702 84,240 85,20"+ + " 91,180 92,50 93,210 94,3353"+ + " 95,1371 96,1261 97,370 98,120"+ + " 105,1621 106,160 107,70 108,220"+ + " 109,80 110,60 111,30 112,40"+ + " 121,30 122,460 123,940 124,9999"; + //note that the intensities in jcamp response are 10x when compared to MSP format + } } var spectrum1 = getSpectrumObjectFromMSPString(spectrumMSPString); var spectrum2 = getSpectrumObjectFromJCAMPString(peakTable); @@ -124,6 +132,8 @@ xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", theUrl, false ); xmlHttp.send( null ); + if (xmlHttp.status == 404) + throw new Exception("Error while trying to access the data: " + xmlHttp.statusText) return xmlHttp.responseText; }