eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

ofono.py (1492B)


      1 import dbus
      2 import time
      3 from gi.repository import GLib
      4 from config import ctx
      5 
      6 SIM_AUTH_IFACE = 'org.ofono.SimAuthentication'
      7 
      8 class Ofono(dbus.service.Object):
      9     def __init__(self, namespace=ctx):
     10         self._bus = namespace.get_bus()
     11 
     12         ctx.non_block_wait(self._bus.name_has_owner, 10, 'org.ofono',
     13                             exception=TimeoutError('Waiting for org.ofono service timed out'))
     14 
     15     def enable_modem(self, path):
     16         self._modem_path = path
     17         self._modem_iface = dbus.Interface(
     18                                         self._bus.get_object('org.ofono', path),
     19                                         'org.ofono.Modem')
     20         self._modem_iface.SetProperty("Powered", dbus.Boolean(1),
     21                                        timeout = 120)
     22 
     23     def _modem_prop_changed(self, property, changed):
     24         if property == 'Interfaces':
     25             if SIM_AUTH_IFACE in changed:
     26                 self._sim_auth_up = True
     27 
     28     def wait_for_sim_auth(self, max_wait = 15):
     29         self._sim_auth_up = False
     30 
     31         props = self._modem_iface.GetProperties()
     32         if SIM_AUTH_IFACE in props['Interfaces']:
     33             self._sim_auth_up = True
     34             return
     35 
     36         self._modem_iface.connect_to_signal('PropertyChanged',
     37                                              self._modem_prop_changed)
     38 
     39         ctx.non_block_wait(lambda s : s._sim_auth_up, max_wait, self,
     40                             exception=TimeoutError('waiting for SimAuthetication timed out'))