#!/usr/bin/python3 # SPDX-License-Identifier: Apache-2.0 # Copyright 2020 Intel Corp. import argparse import subprocess from flask import Flask REPLACE_CHAR = "~" app = Flask(__name__) parser = argparse.ArgumentParser(description="Remote DBus Viewer") parser.add_argument("-u", "--username", default="root") parser.add_argument("-p", "--password", default="0penBmc") parser.add_argument("-a", "--address", required=True) parser.add_argument("-x", "--port", required=True) args = parser.parse_args() busctl = "sshpass -p {} busctl -H {}@{} ".format( args.password, args.username, args.address ) AVATAR_URL = "https://avatars1.githubusercontent.com/u/13670043?s=200&v=4" header = f'
' def getBusNames(): out = subprocess.check_output(busctl + "list --acquired", shell=True) out = out.split(b"\n") out = out[1:] names = [] for line in out: name = line.split(b" ")[0] if name: names.append(name.decode()) return names def doTree(busname): out = subprocess.check_output(busctl + "tree " + busname, shell=True) out = out.split(b"\n") tree = [] for line in out: path = line.split(b"/", 1)[-1].decode() path = "/" + path tree.append(path) return tree def doIntrospect(busname, path): out = subprocess.check_output( busctl + "introspect {} {}".format(busname, path), shell=True ) return out.decode().split("\n") @app.route("/") def root(): out = header out += "{}".format(line) out += "