def background_percent_complete(report, run_dir, is_running): if is_running: return PKDict( percentComplete=0, frameCount=0, ) dump_file = _dump_file(run_dir) if os.path.exists(dump_file): beam_header = hellweg_dump_reader.beam_header(dump_file) last_update_time = int(os.path.getmtime(dump_file)) frame_count = beam_header.NPoints return PKDict( lastUpdateTime=last_update_time, percentComplete=100, frameCount=frame_count, summaryData=_summary_text(run_dir), ) return PKDict(percentComplete=100, frameCount=0, error=_parse_error_message(run_dir))
def background_percent_complete(report, run_dir, is_running): if is_running: return { 'percentComplete': 0, 'frameCount': 0, } dump_file = _dump_file(run_dir) if os.path.exists(dump_file): beam_header = hellweg_dump_reader.beam_header(dump_file) last_update_time = int(os.path.getmtime(dump_file)) frame_count = beam_header.NPoints return { 'lastUpdateTime': last_update_time, 'percentComplete': 100, 'frameCount': frame_count, 'summaryData': _summary_text(run_dir), } return { 'percentComplete': 100, 'frameCount': 0, 'error': _parse_error_message(run_dir) }
def _compute_range_across_files(run_dir, data): res = {} for v in _SCHEMA.enum.BeamReportType: x, y = v[0].split('-') res[x] = [] res[y] = [] dump_file = _dump_file(run_dir) if not os.path.exists(dump_file): return res beam_header = hellweg_dump_reader.beam_header(dump_file) for frame in xrange(beam_header.NPoints): beam_info = hellweg_dump_reader.beam_info(dump_file, frame) for field in res: values = hellweg_dump_reader.get_points(beam_info, field) if not len(values): pass elif len(res[field]): res[field][0] = min(min(values), res[field][0]) res[field][1] = max(max(values), res[field][1]) else: res[field] = [min(values), max(values)] return res