Ejemplo n.º 1
0
def parseResult(result):
    l = result.split()
    rep = reply()
    try:
        rep.status = l[0]
        rep.updatedIp = l[1]
        rep.updatedHostname = l[2]
        rep.updatedService = l[3]
    except:
        pass
    return(rep)
Ejemplo n.º 2
0
def load():
    p = Popen(const.LOG_LOAD_CMD, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
    stdout, stderr = p.communicate()
    result = []
    for line in stdout.splitlines():
        record = reply()
        tline = line.replace("  ", " ")
        record.time = "%s %s %s" % (tline.split(" ")[0], tline.split(" ")[1], tline.split(" ")[2])
        at = line.split("[")[1].split("]")[0].split(",")
        record.status = at[0].split(":")[1]
        record.updatedIp = at[1].split(":")[1]
        record.updatedHostname = at[2].split(":")[1]
        record.updatedService = at[3].split(":")[1]
        result.append(record)
    result.reverse()
    return result