How to use the coloredlogs.CHROOT_FILES function in coloredlogs

To help you get started, weā€™ve selected a few coloredlogs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ph4r05 / monero-agent / trezor_monero_test / test_trezor.py View on Github external
import time
import logging
import coloredlogs
from monero_glue.messages.DebugMoneroDiagRequest import DebugMoneroDiagRequest

from trezorlib import debuglink, device

from monero_glue.agent import agent_lite
from monero_glue.xmr import crypto, monero, wallet
from monero_glue.xmr import bulletproof as bp
from monero_glue.xmr import bulletproof_cl as bpcl
from monero_glue_test.base_agent_test import BaseAgentTest
from monero_glue.trezor import manager as tmanager

logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.INFO, use_chroot=False)


class TrezorTest(BaseAgentTest):
    def __init__(self, *args, **kwargs):
        super(TrezorTest, self).__init__(*args, **kwargs)
        self.trezor_proxy = None  # type: tmanager.Trezor
        self.agent = None  # type: agent_lite.Agent
        self.creds = None
        self.test_only_tsx = False
        self.is_debug = True
        self.do_timing = int(os.getenv('TREZOR_TEST_TIMING', '1'))
        self.do_bp_off = int(os.getenv('TREZOR_TEST_BP_OFF', '0'))
        self.time_start = None
        self.timing_bins = {}
github xolox / python-coloredlogs / coloredlogs / tests.py View on Github external
def test_find_hostname(self):
        """Make sure :func:`~find_hostname()` works correctly."""
        assert find_hostname()
        # Create a temporary file as a placeholder for e.g. /etc/debian_chroot.
        fd, temporary_file = tempfile.mkstemp()
        try:
            with open(temporary_file, 'w') as handle:
                handle.write('first line\n')
                handle.write('second line\n')
            CHROOT_FILES.insert(0, temporary_file)
            # Make sure the chroot file is being read.
            assert find_hostname() == 'first line'
        finally:
            # Clean up.
            CHROOT_FILES.pop(0)
            os.unlink(temporary_file)
        # Test that unreadable chroot files don't break coloredlogs.
        try:
            CHROOT_FILES.insert(0, temporary_file)
            # Make sure that a usable value is still produced.
            assert find_hostname()
        finally:
            # Clean up.
            CHROOT_FILES.pop(0)
github xolox / python-coloredlogs / coloredlogs / tests.py View on Github external
def test_find_hostname(self):
        """Make sure :func:`~find_hostname()` works correctly."""
        assert find_hostname()
        # Create a temporary file as a placeholder for e.g. /etc/debian_chroot.
        fd, temporary_file = tempfile.mkstemp()
        try:
            with open(temporary_file, 'w') as handle:
                handle.write('first line\n')
                handle.write('second line\n')
            CHROOT_FILES.insert(0, temporary_file)
            # Make sure the chroot file is being read.
            assert find_hostname() == 'first line'
        finally:
            # Clean up.
            CHROOT_FILES.pop(0)
            os.unlink(temporary_file)
        # Test that unreadable chroot files don't break coloredlogs.
        try:
            CHROOT_FILES.insert(0, temporary_file)
            # Make sure that a usable value is still produced.
            assert find_hostname()
        finally:
            # Clean up.
            CHROOT_FILES.pop(0)
github ph4r05 / monero-agent / monero_poc / tools / log_aux_qemu.py View on Github external
import argparse
import fileinput
import io
import json
import logging
import os
import re
import time
import copy
import collections

import coloredlogs

logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.INFO, use_chroot=False)


def remove_ctl(line):
    return re.sub(r"\x1b\[\d+m", "", line.rstrip("\n"))


def avg(iterable):
    return sum(iterable) / float(len(iterable))


def count_elements(seq) -> dict:
    hist = {}
    for i in seq:
        hist[i] = hist.get(i, 0) + 1
    return hist
github ph4r05 / monero-agent / monero_poc / agent.py View on Github external
from monero_glue.messages import DebugMoneroDiagRequest, Entropy, GetEntropy
from monero_glue.xmr import common, crypto, daemon_rpc, monero, wallet, wallet_rpc
from monero_glue.xmr.common import try_fnc
from monero_glue.xmr.enc import chacha, chacha_poly
from monero_glue.xmr.sub import addr as xmr_addr
from monero_poc.utils import cli, misc, trace_logger
from monero_poc.utils.misc import TrezorAddressMismatchError
from monero_poc.utils.trezor_server_proxy import TokenProxy
from monero_serialize import xmrboost, xmrserialize, xmrtypes
from trezorlib import debuglink, device

import coloredlogs
from cmd2 import Cmd

logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.WARNING, use_chroot=False)


class HostAgent(cli.BaseCli):
    """
    Host agent wrapper
    """

    prompt = "$> "

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.args = None

        self.network_type = None
        self.address = None
github ph4r05 / monero-agent / monero_poc / tools / package_dump.py View on Github external
import re
import itertools
import threading
import coloredlogs

import networkx as nx

import matplotlib
matplotlib.use('PS')  # https://github.com/scikit-optimize/scikit-optimize/issues/637
import matplotlib.pyplot as plt

from monero_glue.messages import DebugMoneroDiagRequest


logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.DEBUG, use_chroot=False)


# System-provided packages
PACKAGES = [
    "array",
    "cmath",
    "collections",
    "gc",
    "json",
    "logging",
    "machine",
    "math",
    "re",
    "struct",
    "sys",
github ph4r05 / monero-agent / monero_poc / tools / mem_proc.py View on Github external
# Log processor, extracts timings and memory consumption stats
#
#

import argparse
import logging
import re
import json
import collections

import coloredlogs

logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.INFO, use_chroot=False)

# Data collected by calling diag() on a real device - benchmarking
perfs = [
    {'random_scalar': 0.211 / 512.},
    {'encodeint_into': 4.5150 / 131072.},
    {'encodeint': 4.5150 / 131072.},
    {'decodeint_into': 7.3500 / 131072.},
    {'decodeint': 7.3500 / 131072.},
    {'decodeint_into_noreduce': 4.6370 / 131072.},
    {'sc_copy': 3.2540 / 131072.},

    {'scalarmult_base': 2.0880 / 256.},
    {'encodepoint_into': 144.4460 / 131072.},
    {'decodepoint_into': 154.7630 / 131072.},
github ph4r05 / monero-agent / monero_poc / trezor.py View on Github external
from monero_glue.hwtoken import iface, token
from monero_glue.messages import MoneroWatchKey
from monero_glue.misc.bip import bip32
from monero_glue.protocol_base import messages
from monero_glue.xmr import crypto, monero, wallet
from monero_glue.xmr.core import mnemonic
from monero_poc.utils import cli, misc
from monero_serialize import xmrserialize

import coloredlogs
import eventlet
from eventlet import wsgi
from flask import Flask, abort, jsonify, request

logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.WARNING, use_chroot=False)
eventlet.monkey_patch(socket=True)


class TokenInterface(iface.TokenInterface):
    def __init__(self, server=None):
        self.server = server
        self.tsx_waiter = misc.CliPrompt(pre_wait_hook=server.update_prompt)
        self.ki_sync_waiter = misc.CliPrompt(pre_wait_hook=server.update_prompt)
        self.tsx_data = None
        self.confirmed_result = False

    def get_tx_data(self):
        return self.tsx_data

    @property
github ph4r05 / monero-agent / monero_poc / log_aux.py View on Github external
import argparse
import fileinput
import io
import json
import logging
import math
import os
import re
import time

from monero_poc.tools.mem_cmp import MemReader

import coloredlogs

logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.INFO, use_chroot=False)


TICKS_PER_SECOND = 1000000.0
MAX_TICKS = 1073741824  # 2**30


def tic2sec(tic):
    return tic / TICKS_PER_SECOND


def remove_ctl(line):
    return re.sub(r"\x1b\[\d+m", "", line.rstrip("\n"))


def avg(iterable):
github ph4r05 / monero-agent / monero_poc / tools / remove_ctl.py View on Github external
import argparse
import fileinput
import logging
import re

import coloredlogs

logger = logging.getLogger(__name__)
coloredlogs.CHROOT_FILES = []
coloredlogs.install(level=logging.INFO, use_chroot=False)


def remove_ctl(line):
    return re.sub(r"\x1b\[\d+m", "", line.rstrip("\n"))


class CtlRemover(object):
    def __init__(self):
        pass

    def process(self, line):
        return remove_ctl(line)

    def read_files(self, files):
        for idx, line in enumerate(fileinput.input(files)):