Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed Nov 3, 2023
1 parent d960b41 commit b9dca9d
Show file tree
Hide file tree
Showing 27 changed files with 56 additions and 95 deletions.
16 changes: 11 additions & 5 deletions src/tools/interop/idt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,15 @@ Collect contextually relevant networking info from the local environment and pro
- The entry point is in `idt.py` which contains simple CLI parsing with
`argparse`.
- `log` contains logging utilities used by everything in the project.
### `capture`
- `base` contains the base classes for ecosystems and platforms.
- `factory` contains the ecosystem and platform producer and controller
- `controller` contains the ecosystem and platform producer and controller
- `loader` is a generic class loader that dynamically imports classes
matching a given super class from a given directory.
- `utils/shell` contains a simple helper class for background and foreground
Bash commands.
- `utils/artifact` contains helper functions for managing artifacts.
- `/platform` and `/ecosystem` contain one package for each platform and ecosystem, which should each contain
one implementation of the respective base classs.
Expand All @@ -289,6 +287,14 @@ Collect contextually relevant networking info from the local environment and pro
- `linux` and `mac` contain `probe` implementations for each host platform.
- - The package contains a simple dataclass to represent probe targets.
### `utils`
- `log` contains logging utilities used by everything in the project.
- `artifact` contains helper functions for managing artifacts.
- `shell` contains a simple helper class for background and foreground
Bash commands.
- `host_platform` contains helpfer functions for the host running `idt`.
### Conventions
- `config.py` should be used to hold development configs within the directory
Expand Down
2 changes: 1 addition & 1 deletion src/tools/interop/idt/capture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from capture import ecosystem, platform

from .factory import EcosystemCapture, EcosystemController, EcosystemFactory, PlatformFactory, PlatformLogStreamer
from .controller import EcosystemCapture, EcosystemController, EcosystemFactory, PlatformFactory, PlatformLogStreamer
from .pcap import PacketCaptureRunner

__all__ = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
import typing

import capture
import log
from capture.base import EcosystemCapture, PlatformLogStreamer, UnsupportedCapturePlatformException
from capture.utils.artifact import create_standard_log_name, safe_mkdir
from capture.utils.async_control import get_timeout
from log import border_print
from utils.artifact import create_standard_log_name, safe_mkdir, log
from utils.log import border_print
from . import config

_PLATFORM_MAP: typing.Dict[str, PlatformLogStreamer] = {}
_ECOSYSTEM_MAP: typing.Dict[str, PlatformLogStreamer] = {}
Expand All @@ -36,6 +35,10 @@
logger = log.get_logger(__file__)


def get_timeout():
return asyncio.get_running_loop().time() + config.async_timeout


class PlatformFactory:

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
import os
from typing import Dict

import log
from capture.base import EcosystemCapture, UnsupportedCapturePlatformException
from capture.platform.android import Android
from capture.utils.artifact import create_standard_log_name
from utils.artifact import create_standard_log_name, log

from . import config
from .play_services_analysis import PlayServicesAnalysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@

import os

import log
from capture.platform.android import Android
from capture.utils.artifact import create_standard_log_name
from log import add_border, print_and_write
from utils.artifact import create_standard_log_name, log
from utils.log import add_border, print_and_write

logger = log.get_logger(__file__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

import os

import log
from capture.utils.shell import Bash
from utils.shell import Bash, log

logger = log.get_logger(__file__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

from capture.base import EcosystemCapture, UnsupportedCapturePlatformException
from capture.platform.android.android import Android
from capture.utils.artifact import create_standard_log_name
from log import print_and_write
from utils.artifact import create_standard_log_name
from utils.log import print_and_write

from log import get_logger
from utils.log import get_logger

logger = get_logger(__file__)

Expand Down
2 changes: 1 addition & 1 deletion src/tools/interop/idt/capture/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import traceback
from typing import Any

import log
from utils import log

logger = log.get_logger(__file__)

Expand Down
5 changes: 2 additions & 3 deletions src/tools/interop/idt/capture/pcap/pcap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import os
import time

import log
from capture.utils.artifact import create_standard_log_name
from capture.utils.shell import Bash
from utils.artifact import create_standard_log_name, log
from utils.shell import Bash

logger = log.get_logger(__file__)

Expand Down
3 changes: 1 addition & 2 deletions src/tools/interop/idt/capture/platform/android/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
import traceback
import typing

import log
from capture.base import PlatformLogStreamer
from capture.utils.shell import Bash
from utils.shell import Bash, log

from . import config, streams
from .capabilities import Capabilities
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import TYPE_CHECKING

from capture.utils.artifact import create_standard_log_name
from capture.utils.shell import Bash
from utils.artifact import create_standard_log_name, log
from utils.shell import Bash

if TYPE_CHECKING:
from capture.platform.android import Android

import log

from . import config

logger = log.get_logger(__file__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import os
from typing import TYPE_CHECKING

import log
from capture.utils.artifact import create_standard_log_name
from utils.artifact import create_standard_log_name, log

from ..base import AndroidStream

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@
import os
from typing import TYPE_CHECKING

from capture.utils.artifact import create_standard_log_name, safe_mkdir
from capture.utils.shell import Bash
from capture.utils.host_platform import is_mac
from utils.artifact import create_standard_log_name, safe_mkdir, log
from utils.shell import Bash
from utils.host_platform import is_mac

from ... import config
from ..base import AndroidStream

if TYPE_CHECKING:
from capture.platform.android import Android

import log

logger = log.get_logger(__file__)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
import os
from typing import TYPE_CHECKING

from capture.utils.artifact import create_standard_log_name
from utils.artifact import create_standard_log_name, log

from ..base import AndroidStream

if TYPE_CHECKING:
from capture.platform.android import Android

import log

logger = log.get_logger(__file__)


Expand Down
24 changes: 0 additions & 24 deletions src/tools/interop/idt/capture/utils/async_control.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/tools/interop/idt/discovery/ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import sys
import time

import log
from utils import log
from bleak import AdvertisementData, BleakScanner, BLEDevice
from bleak.exc import BleakDBusError

Expand Down
4 changes: 1 addition & 3 deletions src/tools/interop/idt/discovery/dnssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
import asyncio
import os

import log
from zeroconf import ServiceBrowser, ServiceInfo, ServiceListener, Zeroconf
from capture.utils.artifact import create_standard_log_name

from utils.artifact import create_standard_log_name, log

logger = log.get_logger(__file__)

Expand Down
6 changes: 3 additions & 3 deletions src/tools/interop/idt/idt.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from pathlib import Path

from capture import EcosystemController, EcosystemFactory, PacketCaptureRunner, PlatformFactory
from capture.utils.artifact import create_file_timestamp, safe_mkdir
from capture.utils.shell import Bash
from utils.artifact import create_file_timestamp, safe_mkdir
from utils.shell import Bash
from discovery import MatterBleScanner, MatterDnssdListener
from log import border_print
from utils.log import border_print

import config

Expand Down
4 changes: 2 additions & 2 deletions src/tools/interop/idt/probe/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#

import probe.probe as p
from capture.utils.host_platform import get_ll_interface
from utils.host_platform import get_ll_interface
from . import config
from log import get_logger
from utils.log import get_logger

logger = get_logger(__file__)

Expand Down
4 changes: 2 additions & 2 deletions src/tools/interop/idt/probe/mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#

import probe.probe as p
from capture.utils.host_platform import get_ll_interface
from log import get_logger
from utils.host_platform import get_ll_interface
from utils.log import get_logger
from . import config, ProbeTarget

logger = get_logger(__file__)
Expand Down
10 changes: 3 additions & 7 deletions src/tools/interop/idt/probe/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import os.path
from abc import ABC, abstractmethod

from capture.utils.artifact import create_standard_log_name
from capture.utils.shell import Bash
from utils.artifact import create_standard_log_name
from utils.shell import Bash
from discovery import MatterDnssdListener
from discovery.dnssd import ServiceInfo
from log import get_logger
from utils.log import get_logger
from . import config, ProbeTarget

logger = get_logger(__file__)
Expand All @@ -33,10 +33,6 @@
class GenericMatterProber(ABC):

def __init__(self, artifact_dir: str, dnssd_artifact_dir: str) -> None:
"""
Class that probes the local environment for all matter devices
Platform and ecosystem agnostic
"""
self.artifact_dir = artifact_dir
self.dnssd_artifact_dir = dnssd_artifact_dir
self.logger = logger
Expand Down
2 changes: 1 addition & 1 deletion src/tools/interop/idt/probe/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.
#

from capture.utils.host_platform import is_mac
from utils.host_platform import is_mac
from .mac import ProberMacHost
from .linux import ProberLinuxHost

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
# limitations under the License.
#

from . import artifact, async_control, shell
from . import artifact, host_platform, log, shell

__all__ = [
'artifact',
'async_control',
'host_platform',
'log',
'shell',
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
# limitations under the License.
#

import multiprocessing
import os
import time
from multiprocessing import Process
from pathlib import Path

import log
from . import log

logger = log.get_logger(__file__)

Expand Down
File renamed without changes.
Loading

0 comments on commit b9dca9d

Please sign in to comment.