Exemple #1
0
def test_without_logging(capsys):
    logger = AdbLogging.get_logger("ppadb.test")
    logger.addHandler(logging.StreamHandler())

    logger.info("INFO message")
    captured = capsys.readouterr()
    assert not captured.out
    assert not captured.err

    logger.warning("WARNING message")
    captured = capsys.readouterr()
    assert not captured.out
    assert not captured.err

    logger.debug("DEBUG message")
    assert not captured.out
    assert not captured.err
Exemple #2
0
def test_enable_log_message(capsys):
    logging.basicConfig()
    logger = AdbLogging.get_logger("ppadb.test")
    logger.addHandler(logging.StreamHandler())
    logging.getLogger("ppadb").setLevel(logging.DEBUG)

    logger.info("INFO message")
    captured = capsys.readouterr()
    assert not captured.out
    assert captured.err

    logger.warning("WARNING message")
    captured = capsys.readouterr()
    assert not captured.out
    assert captured.err

    logger.debug("DEBUG message")
    assert not captured.out
    assert captured.err
Exemple #3
0
import re
import time

from ppadb import ClearError
from ppadb.command import Command

from ppadb.utils.logger import AdbLogging

logger = AdbLogging.get_logger(__name__)


class Transport(Command):
    def transport(self, connection):
        cmd = "host:transport:{}".format(self.serial)
        connection.send(cmd)

        return connection

    def shell(self, cmd, handler=None, timeout=None):
        conn = self.create_connection(timeout=timeout)

        cmd = "shell:{}".format(cmd)
        conn.send(cmd)

        if handler:
            handler(conn)
        else:
            result = conn.read_all()
            conn.close()
            return result.decode('utf-8')