mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-03 20:42:09 +08:00
hardware: only create dbus objects when needed (#21576)
* only create dbus objects when needed * fix typo * use cached_property old-commit-hash: 45d4f8301be7f686c359fad00dc837066c325ca0
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
from functools import cached_property
|
||||
from enum import IntEnum
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
@@ -51,13 +52,20 @@ def write_amplifier_reg(reg, val, offset, mask):
|
||||
v = (v & (~mask)) | ((val << offset) & mask)
|
||||
bus.write_byte_data(AMP_ADDRESS, reg, v, force=True)
|
||||
|
||||
class Tici(HardwareBase):
|
||||
def __init__(self):
|
||||
import dbus # pylint: disable=import-error
|
||||
|
||||
self.bus = dbus.SystemBus()
|
||||
self.nm = self.bus.get_object(NM, '/org/freedesktop/NetworkManager')
|
||||
self.mm = self.bus.get_object(MM, '/org/freedesktop/ModemManager1')
|
||||
class Tici(HardwareBase):
|
||||
@cached_property
|
||||
def bus(self):
|
||||
import dbus # pylint: disable=import-error
|
||||
return dbus.SystemBus()
|
||||
|
||||
@cached_property
|
||||
def nm(self):
|
||||
return self.bus.get_object(NM, '/org/freedesktop/NetworkManager')
|
||||
|
||||
@cached_property
|
||||
def mm(self):
|
||||
return self.bus.get_object(MM, '/org/freedesktop/ModemManager1')
|
||||
|
||||
def get_os_version(self):
|
||||
with open("/VERSION") as f:
|
||||
|
||||
Reference in New Issue
Block a user