"""Utility functions for DBus use within Bluezero.""" # Standard libraries import re import subprocess # D-Bus import import dbus # python-bluezero constants import from bluezero import constants from bluezero import tools logger = tools.create_module_logger(__name__) def bluez_version(): """ get the version of the BlueZ daemon being used on the system :return: String of BlueZ version """ cmd = ['bluetoothctl', '-v'] cmd_output = subprocess.run(cmd, capture_output=True, check=True) version = cmd_output.stdout.decode('utf-8').split() return version[1] def bluez_experimental_mode(): """ Return True if the BlueZ daemon service is in experimental mode
import collections import logging from pathlib import Path import re from bluezero.tools import create_module_logger logger = create_module_logger(__file__) here = Path(__file__).parent.parent file_of_tests = here.joinpath('tests') git_workflow = here.joinpath('.github', 'workflows', 'python-app.yml') run_local_file = here.joinpath('run_local_tests.sh') def find_test_files(tests_dir): test_entries = [] for test_file in tests_dir.glob('test_*.py'): test_entries.append(f'tests.{test_file.stem}') return test_entries def find_run_files(run_file): file_content = run_file.read_text() result = re.findall(r'tests\.test_\w+', file_content) return result def two_lists_match(ref_list, test_list): match_lengths = len(ref_list) == len(test_list) match_content = len(list(set(test_list) - set(ref_list))) == 0