コード例 #1
0
def get_dojo_tracker_status():
    try:
        tracker_log = subprocess.check_output("docker logs --tail 100 nodejs", shell=True)
    except:
        return "error"

    lines = tracker_log.splitlines()
    lines.reverse()
    tracker_status = "unknown"

    for line in lines:
        if "Added block header" in line:
            m = re.search("block header ([0-9]+)", line)
            dojo_height = m.group(1)
            bitcoin_height = get_mynode_block_height()
            tracker_status = "Syncing... {} of {}".format(dojo_height, bitcoin_height)
            break
        elif "Finished block" in line:
            m = re.search("Finished block ([0-9]+)", line)
            dojo_height = m.group(1)
            bitcoin_height = get_mynode_block_height()
            tracker_status = "Syncing... {} of {}".format(dojo_height, bitcoin_height)
        elif "Processing active Mempool" in line:
            tracker_status = "Active"
            break
        elif "ER_ACCESS_DENIED_ERROR" in line:
            tracker_status = "MYSQL Connection Error"
            break
    return tracker_status
コード例 #2
0
def get_dojo_tracker_status():
    try:
        tracker_log = subprocess.check_output(
            "docker exec nodejs tail -n 50 /data/logs/tracker-output.log",
            shell=True)
    except:
        return "error"

    lines = tracker_log.splitlines()
    lines.reverse()
    tracker_status = "unknown"

    for line in lines:
        if "Added block header" in line:
            m = re.search("block header ([0-9]+)", line)
            dojo_height = m.group(1)
            bitcoin_height = get_mynode_block_height()
            tracker_status = "Syncing... {} of {}".format(
                dojo_height, bitcoin_height)
            break
        elif "Processing active Mempool" in line:
            tracker_status = "Active"
            break

    return tracker_status