def AsXML(self): dom = catocommon.ET.fromstring('<Users />') for user in self.SafeList(): xml = catocommon.dict2xml(user, "User") node = catocommon.ET.fromstring(xml.tostring()) dom.append(node) return catocommon.ET.tostring(dom)
def AsXML(self): """ Returns an XML representation of the document. :rtype: string :return : XML representation of the document """ if self.doc: try: xml = catocommon.dict2xml(self.doc, "Document") return xml.tostring() except Exception as ex: raise ex
def list_processes(self, args): """Lists all running processes. Returns: A list of [Process Objects](restapi/api-response-objects.html#Process){:target="_blank"}. """ db = catocommon.new_conn() sSQL = """select app_instance as Instance, app_name as Component, heartbeat as Heartbeat, case master when 1 then 'Yes' else 'No' end as Enabled, timestampdiff(MINUTE, heartbeat, now()) as MinutesIdle, load_value as LoadValue, platform, hostname from application_registry order by component, master desc""" rows = db.select_all_dict(sSQL) db.close() if rows: if args.get("output_format") == "json": resp = catocommon.ObjectOutput.IterableAsJSON(rows) return R(response=resp) elif args.get("output_format") == "text": keys = ['Instance', 'Component', 'Heartbeat', 'Enabled', 'LoadValue', 'MinutesIdle'] outrows = [] if rows: for row in rows: cols = [] for key in keys: cols.append(str(row[key])) outrows.append("\t".join(cols)) return "%s\n%s" % ("\t".join(keys), "\n".join(outrows)) else: dom = catocommon.ET.fromstring('<Processes />') if rows: for row in rows: xml = catocommon.dict2xml(row, "Process") node = catocommon.ET.fromstring(xml.tostring()) dom.append(node) return R(response=catocommon.ET.tostring(dom)) else: return R(err_code=R.Codes.ListError, err_detail="Unable to list Processes.")