def getAllJson(): prc = exprc.extractFromPerlRCLog() prc.get_last_scan() prc.last_scan_runs() prc.last_scan_filenames() files = prc.runFilenames date = prc.last_scan_date() files = [prc.datapath + date + '/' + f for f in files] data = [getjson(f) for f in files] scanvals = prc.last_scan_values() scanvar = prc.last_scan_variable() for d, y in zip(data, scanvals): for x in d: x['scanval'] = float(y) x['scanvar'] = scanvar x['scan'] = 1 if prc.last_scan_type() == "Scan2D": for d in data[1::2]: for x in d: x['scan'] = 2 return flatten(data)
def getAllJson(): ''' Gather the JSON data from all of the files in the PerlRC.log file for the last scan. ''' prc = exprc.extractFromPerlRCLog() prc.get_last_scan() prc.last_scan_runs() prc.last_scan_filenames() files = prc.runFilenames date = prc.last_scan_date() # Get the files with path files = [prc.datapath + date + '/' + f for f in files] # Get the JSON data data = [getjson(f) for f in files] scanvals = prc.last_scan_values() scanvar = prc.last_scan_variable() # Added the scan variable and scan values into the # JSON data. counter = 0 count_dict = dict() for d, y in zip(data, scanvals): for x in d: try: x['scanval'] = float(y) except: try: x['scanval'] = count_dict[y] except: count_dict[y] = counter counter = counter + 1 x['scanval'] = count_dict[y] x['scanvar'] = scanvar x['scan'] = 1 # If the scan is 2D, change the 'scan' to 2, to allow for the # second plot in prcview.html if prc.last_scan_type() == "Scan2D": for d in data[1::2]: for x in d: x['scan'] = 2 # flatten the JSON data. # Also include the last scan text from the log file, # to display on the prcview.html return [flatten(data), prc.lastScan]
#!/home/mpet/local/bin/python2.7 import extractFromPerlRCLog as prc import perlRCjsonData as jd x = prc.extractFromPerlRCLog() x.convert_PerlRC() jd.dumpJson()