Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 764d3b76 authored by Zach Johnson's avatar Zach Johnson
Browse files

Format python files with extended line length now allowed

Bug: 156858180
Test: cert/run --host
Tag: #gd-refactor
Change-Id: I45ab86f366316246f14b24dd83f66684badf22e0
parent 5ff3191f
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -18,8 +18,7 @@ clang_version_major = 0
clang_version_minor = 0

if clang_path:
    clang_version_out = subprocess.Popen(
        [clang_path, "--version"], stdout=subprocess.PIPE).communicate()[0]
    clang_version_out = subprocess.Popen([clang_path, "--version"], stdout=subprocess.PIPE).communicate()[0]
    clang_version_match = re.search(CLANG_VERSION_REGEX, clang_version_out)
    clang_version_str = clang_version_match.group(1)
    clang_version_array = clang_version_str.split('.')
+4 −11
Original line number Diff line number Diff line
@@ -66,26 +66,19 @@ class AsyncSubprocessLogger:
        try:
            result = self.future.result(timeout=self.WAIT_TIMEOUT_SECONDS)
            if result:
                logging.error(
                    "logging thread %s produced an error when executing: %s" %
                    (self.tag, str(result)))
                logging.error("logging thread %s produced an error when executing: %s" % (self.tag, str(result)))
        except concurrent.futures.TimeoutError:
            logging.error("logging thread %s failed to finish after %d seconds"
                          % (self.tag, self.WAIT_TIMEOUT_SECONDS))
            logging.error("logging thread %s failed to finish after %d seconds" % (self.tag, self.WAIT_TIMEOUT_SECONDS))
        self.executor.shutdown(wait=False)

    def __logging_loop(self):
        with ExitStack() as stack:
            log_files = [
                stack.enter_context(open(file_path, 'w'))
                for file_path in self.log_file_paths
            ]
            log_files = [stack.enter_context(open(file_path, 'w')) for file_path in self.log_file_paths]
            for line in self.process.stdout:
                for log_file in log_files:
                    log_file.write(line)
                if self.log_to_stdout:
                    if self.color:
                        print("[%s%s%s] %s" % (self.color, self.tag,
                                               TerminalColor.END, line.strip()))
                        print("[%s%s%s] %s" % (self.color, self.tag, TerminalColor.END, line.strip()))
                    else:
                        print("[%s] %s" % (self.tag, line.strip()))
+3 −6
Original line number Diff line number Diff line
@@ -79,8 +79,7 @@ class SingleArgumentBehavior(object):
            self.__obj_invoked(obj)
        else:
            raise signals.TestFailure(
                "%s: behavior for %s went unhandled" %
                (self._reply_stage_factory().__class__.__name__, obj),
                "%s: behavior for %s went unhandled" % (self._reply_stage_factory().__class__.__name__, obj),
                extras=None)

    def __obj_invoked(self, obj):
@@ -125,8 +124,7 @@ class ReplyStage(object):
        self._persistence = persistence

    def _commit(self, fn):
        self._behavior.append(
            BehaviorInstance(self._matcher, self._persistence, fn))
        self._behavior.append(BehaviorInstance(self._matcher, self._persistence, fn))


class BehaviorInstance(object):
@@ -156,8 +154,7 @@ class BoundVerificationStage(object):
        self._timeout = timeout

    def times(self, times=1):
        return self._behavior.wait_until_invoked(self._matcher, times,
                                                 self._timeout)
        return self._behavior.wait_until_invoked(self._matcher, times, self._timeout)


class WaitForBehaviorSubject(object):
+6 −12
Original line number Diff line number Diff line
@@ -29,16 +29,12 @@ import glob
from setuptools import setup, Extension

ANDROID_BUILD_TOP = os.getenv("ANDROID_BUILD_TOP")
PYBIND11_INCLUDE_DIR = os.path.join(ANDROID_BUILD_TOP,
                                    "external/python/pybind11/include")
PYBIND11_INCLUDE_DIR = os.path.join(ANDROID_BUILD_TOP, "external/python/pybind11/include")
GD_DIR = os.path.join(ANDROID_BUILD_TOP, "packages/modules/Bluetooth/system/gd")
BT_PACKETS_GEN_DIR = os.path.join(
    ANDROID_BUILD_TOP,
BT_PACKETS_GEN_DIR = os.path.join(ANDROID_BUILD_TOP,
                                  "out/soong/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothGeneratedPackets_h/gen")
BT_PACKETS_PY3_GEN_DIR = os.path.join(
    ANDROID_BUILD_TOP,
    "out/soong/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothGeneratedPackets_python3_cc/gen"
)
BT_PACKETS_PY3_GEN_DIR = os.path.join(ANDROID_BUILD_TOP,
                                      "out/soong/.intermediates/packages/modules/Bluetooth/system/gd/BluetoothGeneratedPackets_python3_cc/gen")

BT_PACKETS_BASE_SRCS = [
    os.path.join(GD_DIR, "l2cap/fcs.cc"),
@@ -61,9 +57,7 @@ BT_PACKETS_PY3_SRCs = \
bluetooth_packets_python3_module = Extension(
    'bluetooth_packets_python3',
    sources=BT_PACKETS_BASE_SRCS + BT_PACKETS_PY3_SRCs,
    include_dirs=[
        GD_DIR, BT_PACKETS_GEN_DIR, BT_PACKETS_PY3_GEN_DIR, PYBIND11_INCLUDE_DIR
    ],
    include_dirs=[GD_DIR, BT_PACKETS_GEN_DIR, BT_PACKETS_PY3_GEN_DIR, PYBIND11_INCLUDE_DIR],
    extra_compile_args=['-std=c++17'])

setup(
+37 −65
Original line number Diff line number Diff line
@@ -26,126 +26,99 @@ class HalCaptures(object):

    @staticmethod
    def ReadBdAddrCompleteCapture():
        return Capture(lambda packet: b'\x0e\x0a\x01\x09\x10' in packet.payload,
                       lambda packet: hci_packets.ReadBdAddrCompleteView(
        return Capture(
            lambda packet: b'\x0e\x0a\x01\x09\x10' in packet.payload, lambda packet: hci_packets.ReadBdAddrCompleteView(
                hci_packets.CommandCompleteView(
                               hci_packets.EventPacketView(
                                   bt_packets.PacketViewLittleEndian(
                                       list(packet.payload))))))
                    hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload))))))

    @staticmethod
    def ConnectionRequestCapture():
        return Capture(lambda packet: b'\x04\x0a' in packet.payload,
                       lambda packet: hci_packets.ConnectionRequestView(
                           hci_packets.EventPacketView(
                               bt_packets.PacketViewLittleEndian(
                                   list(packet.payload)))))
        return Capture(
            lambda packet: b'\x04\x0a' in packet.payload, lambda packet: hci_packets.ConnectionRequestView(
                hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))

    @staticmethod
    def ConnectionCompleteCapture():
        return Capture(lambda packet: b'\x03\x0b\x00' in packet.payload,
                       lambda packet: hci_packets.ConnectionCompleteView(
                           hci_packets.EventPacketView(
                               bt_packets.PacketViewLittleEndian(
                                   list(packet.payload)))))
        return Capture(
            lambda packet: b'\x03\x0b\x00' in packet.payload, lambda packet: hci_packets.ConnectionCompleteView(
                hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))

    @staticmethod
    def LeConnectionCompleteCapture():
        return Capture(lambda packet: packet.payload[0] == 0x3e
                                      and (packet.payload[2] == 0x01 or packet.payload[2] == 0x0a),
        return Capture(
            lambda packet: packet.payload[0] == 0x3e and (packet.payload[2] == 0x01 or packet.payload[2] == 0x0a),
            lambda packet: hci_packets.LeConnectionCompleteView(
                hci_packets.LeMetaEventView(
                               hci_packets.EventPacketView(
                                   bt_packets.PacketViewLittleEndian(
                                       list(packet.payload))))))
                    hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload))))))


class HciCaptures(object):

    @staticmethod
    def ReadBdAddrCompleteCapture():
        return Capture(lambda packet: b'\x0e\x0a\x01\x09\x10' in packet.event,
          lambda packet: hci_packets.ReadBdAddrCompleteView(
        return Capture(
            lambda packet: b'\x0e\x0a\x01\x09\x10' in packet.event, lambda packet: hci_packets.ReadBdAddrCompleteView(
                hci_packets.CommandCompleteView(
                                hci_packets.EventPacketView(
                                    bt_packets.PacketViewLittleEndian(
                                        list(packet.event))))))
                    hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.event))))))

    @staticmethod
    def ConnectionRequestCapture():
        return Capture(lambda packet: b'\x04\x0a' in packet.event,
          lambda packet: hci_packets.ConnectionRequestView(
                                hci_packets.EventPacketView(
                                    bt_packets.PacketViewLittleEndian(
                                        list(packet.event)))))
        return Capture(
            lambda packet: b'\x04\x0a' in packet.event, lambda packet: hci_packets.ConnectionRequestView(
                hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.event)))))

    @staticmethod
    def ConnectionCompleteCapture():
        return Capture(lambda packet: b'\x03\x0b\x00' in packet.event,
          lambda packet: hci_packets.ConnectionCompleteView(
                                hci_packets.EventPacketView(
                                    bt_packets.PacketViewLittleEndian(
                                        list(packet.event)))))
        return Capture(
            lambda packet: b'\x03\x0b\x00' in packet.event, lambda packet: hci_packets.ConnectionCompleteView(
                hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.event)))))

    @staticmethod
    def LeConnectionCompleteCapture():
        return Capture(lambda packet: packet.event[0] == 0x3e
                       and (packet.event[2] == 0x01 or packet.event[2] == 0x0a),
        return Capture(
            lambda packet: packet.event[0] == 0x3e and (packet.event[2] == 0x01 or packet.event[2] == 0x0a),
            lambda packet: hci_packets.LeConnectionCompleteView(
                hci_packets.LeMetaEventView(
                                hci_packets.EventPacketView(
                                    bt_packets.PacketViewLittleEndian(
                                        list(packet.event))))))
                    hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.event))))))


class L2capCaptures(object):

    @staticmethod
    def ConnectionRequest(psm):
        return Capture(
            L2capMatchers.ConnectionRequest(psm),
            L2capCaptures._extract_connection_request)
        return Capture(L2capMatchers.ConnectionRequest(psm), L2capCaptures._extract_connection_request)

    @staticmethod
    def _extract_connection_request(packet):
        frame = L2capMatchers.control_frame_with_code(
            packet, CommandCode.CONNECTION_REQUEST)
        frame = L2capMatchers.control_frame_with_code(packet, CommandCode.CONNECTION_REQUEST)
        return l2cap_packets.ConnectionRequestView(frame)

    @staticmethod
    def ConnectionResponse(scid):
        return Capture(
            L2capMatchers.ConnectionResponse(scid),
            L2capCaptures._extract_connection_response)
        return Capture(L2capMatchers.ConnectionResponse(scid), L2capCaptures._extract_connection_response)

    @staticmethod
    def _extract_connection_response(packet):
        frame = L2capMatchers.control_frame_with_code(
            packet, CommandCode.CONNECTION_RESPONSE)
        frame = L2capMatchers.control_frame_with_code(packet, CommandCode.CONNECTION_RESPONSE)
        return l2cap_packets.ConnectionResponseView(frame)

    @staticmethod
    def ConfigurationRequest(cid=None):
        return Capture(
            L2capMatchers.ConfigurationRequest(cid),
            L2capCaptures._extract_configuration_request)
        return Capture(L2capMatchers.ConfigurationRequest(cid), L2capCaptures._extract_configuration_request)

    @staticmethod
    def _extract_configuration_request(packet):
        frame = L2capMatchers.control_frame_with_code(
            packet, CommandCode.CONFIGURATION_REQUEST)
        frame = L2capMatchers.control_frame_with_code(packet, CommandCode.CONFIGURATION_REQUEST)
        return l2cap_packets.ConfigurationRequestView(frame)

    @staticmethod
    def CreditBasedConnectionRequest(psm):
        return Capture(
            L2capMatchers.CreditBasedConnectionRequest(psm),
            L2capCaptures._extract_credit_based_connection_request)
            L2capMatchers.CreditBasedConnectionRequest(psm), L2capCaptures._extract_credit_based_connection_request)

    @staticmethod
    def _extract_credit_based_connection_request(packet):
        frame = L2capMatchers.le_control_frame_with_code(
            packet, LeCommandCode.LE_CREDIT_BASED_CONNECTION_REQUEST)
        frame = L2capMatchers.le_control_frame_with_code(packet, LeCommandCode.LE_CREDIT_BASED_CONNECTION_REQUEST)
        return l2cap_packets.LeCreditBasedConnectionRequestView(frame)

    @staticmethod
@@ -155,6 +128,5 @@ class L2capCaptures(object):

    @staticmethod
    def _extract_credit_based_connection_response(packet):
        frame = L2capMatchers.le_control_frame_with_code(
            packet, LeCommandCode.LE_CREDIT_BASED_CONNECTION_RESPONSE)
        frame = L2capMatchers.le_control_frame_with_code(packet, LeCommandCode.LE_CREDIT_BASED_CONNECTION_RESPONSE)
        return l2cap_packets.LeCreditBasedConnectionResponseView(frame)
Loading