def resolve_dataval(self): if self.string_callback is not None: decoded_dataval = decode_datavalue(self.ref) self.string_callback(decoded_dataval) else: create_datavalue_file(self.ref) self.set_filename(filename_for_ref(self.ref), True) self.result(True, None)
def default(self, job_id, ref_id): try: job = self.job_pool.get_job_by_id(job_id) except KeyError: raise HTTPError(404) try: ref = job.task_graph.get_reference_info(ref_id).ref except KeyError: raise HTTPError(404) ref_string = '<html><head><title>Task Browser</title></head>' ref_string += '<body><table>' ref_string += table_row('ID', ref_id) ref_string += table_row('Ref type', ref.__class__.__name__) if isinstance(ref, SWDataValue): ref_string += table_row('Value', decode_datavalue(ref)) elif hasattr(ref, 'location_hints'): ref_string += span_row('Locations') for netloc in ref.location_hints: ref_string += table_row(netloc, swbs_link(netloc, ref.id)) ref_string += '</table></body></html>' return ref_string
def create_datavalue_file(ref): bs_ctx = create_fetch_file_for_ref(ref) with open(bs_ctx.filename, 'w') as obj_file: obj_file.write(decode_datavalue(ref)) bs_ctx.commit()