def dump_attributes(self, obj): try: dev_attrs = obj.dump_attributes() except AttributeError: return row_head, values = [], [] for dev_attr in dev_attrs: row_head.append(dev_attr.name) if dev_attr.has_failed: err = dev_attr.get_err_stack() if len(err): value = err[0].desc else: value = "Unknown error!" else: value = str(dev_attr.value) values.append(value) table = Table([values], row_head_str=row_head, row_head_fmt='%*s', col_sep=' = ') self.output("Attributes:") self.output("-----------") for line in table.genOutput(): self.output(line)
def dump_properties(self, obj): data = obj.serialize() table = Table([data.values()], row_head_str=data.keys(), row_head_fmt='%*s', col_sep=' = ') self.output("Properties:") self.output("-----------") for line in table.genOutput(): self.output(line)
def output_homing_status(macro, motorsInfoList): """ Flushes homing status to the door output attribute. Status is represented in a table with homed state, home icepap position, home status, and motor positions as columns and motors as rows. :param macro: (macro obj) macro which will perform homing :param motorsInfoList: (list<dict>) list of motors info dictionary""" rowHead = [] colHead = [['homed'], ['home icepap pos'], ['status'], ['position']] data = [[], [], [], []] for motInfo in motorsInfoList: rowHead.append(motInfo['motor'].alias()) data[0].append(str(motInfo['homed'])) data[1].append(str(motInfo['home_ice_pos'])) data[2].append(str(motInfo['status'])) data[3].append(str(motInfo['position'])) table = Table(data, elem_fmt=['%*s'], term_width=None, col_head_str=colHead, col_head_fmt='%*s', col_head_width=15, row_head_str=rowHead, row_head_fmt='%-*s', row_head_width=15, col_sep='|', row_sep='_', col_head_sep='-', border='=') output = '' output += '{0}\n'.format(colHead) output += '{0}\n'.format(rowHead) output += '{0}'.format(data) for l in table.genOutput(): output += '\n{0}'.format(l) macro.outputBlock(output) macro.flushOutput()