tools: use the dbus client bindings from tuhi-live too
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>pull/208/head
parent
cd84de4f32
commit
08afa02690
|
@ -39,9 +39,6 @@ except ModuleNotFoundError:
|
||||||
from tuhi.svg import JsonSvg
|
from tuhi.svg import JsonSvg
|
||||||
import tuhi.dbusclient
|
import tuhi.dbusclient
|
||||||
|
|
||||||
# get those into our namespace for tuhi-live's beneft
|
|
||||||
from tuhi.dbusclient import TUHI_DBUS_NAME, ROOT_PATH, ORG_FREEDESKTOP_TUHI1_MANAGER
|
|
||||||
|
|
||||||
|
|
||||||
CONFIG_PATH = Path(xdg.BaseDirectory.xdg_data_home, 'tuhi-kete')
|
CONFIG_PATH = Path(xdg.BaseDirectory.xdg_data_home, 'tuhi-kete')
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,16 @@ import sys
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from multiprocessing import reduction
|
from multiprocessing import reduction
|
||||||
|
|
||||||
|
try:
|
||||||
|
import tuhi.dbusclient
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
# If PYTHONPATH isn't set up or we never installed Tuhi, the module
|
||||||
|
# isn't available. And since we don't install tuhi-live, we can assume that
|
||||||
|
# we're still in the git repo, so messing with the path is "fine".
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/..') # noqa
|
||||||
|
import tuhi.dbusclient
|
||||||
|
|
||||||
|
|
||||||
manager = None
|
manager = None
|
||||||
logger = None
|
logger = None
|
||||||
|
|
||||||
|
@ -84,7 +94,7 @@ def start_tuhi_server(args):
|
||||||
except GLib.Error as e:
|
except GLib.Error as e:
|
||||||
if (e.domain == 'g-io-error-quark' and
|
if (e.domain == 'g-io-error-quark' and
|
||||||
e.code == Gio.IOErrorEnum.DBUS_ERROR):
|
e.code == Gio.IOErrorEnum.DBUS_ERROR):
|
||||||
raise kete.DBusError(e.message)
|
raise tuhi.dbusclient.DBusError(e.message)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -93,33 +103,32 @@ def start_tuhi_server(args):
|
||||||
try:
|
try:
|
||||||
proxy = Gio.DBusProxy.new_sync(connection,
|
proxy = Gio.DBusProxy.new_sync(connection,
|
||||||
Gio.DBusProxyFlags.NONE, None,
|
Gio.DBusProxyFlags.NONE, None,
|
||||||
kete.TUHI_DBUS_NAME,
|
tuhi.dbusclient.TUHI_DBUS_NAME,
|
||||||
kete.ROOT_PATH,
|
tuhi.dbusclient.ROOT_PATH,
|
||||||
kete.ORG_FREEDESKTOP_TUHI1_MANAGER,
|
tuhi.dbusclient.ORG_FREEDESKTOP_TUHI1_MANAGER,
|
||||||
None)
|
None)
|
||||||
except GLib.Error as e:
|
except GLib.Error as e:
|
||||||
if (e.domain == 'g-io-error-quark' and
|
if (e.domain == 'g-io-error-quark' and
|
||||||
e.code == Gio.IOErrorEnum.DBUS_ERROR):
|
e.code == Gio.IOErrorEnum.DBUS_ERROR):
|
||||||
raise kete.DBusError(e.message)
|
raise tuhi.dbusclient.DBusError(e.message)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
started = proxy.get_name_owner() is not None
|
started = proxy.get_name_owner() is not None
|
||||||
|
|
||||||
if not started:
|
if not started:
|
||||||
print(f'No-one is handling {kete.TUHI_DBUS_NAME}, attempting to start a daemon')
|
print(f'No-one is handling {tuhi.dbusclient.TUHI_DBUS_NAME}, attempting to start a daemon')
|
||||||
|
|
||||||
queue.put((not started, args.verbose))
|
queue.put((not started, args.verbose))
|
||||||
|
|
||||||
|
|
||||||
def run_live(request_fd_queue, conn_fd):
|
def run_live(request_fd_queue, conn_fd):
|
||||||
import kete
|
|
||||||
from gi.repository import Gio, GLib
|
from gi.repository import Gio, GLib
|
||||||
|
|
||||||
def on_name_appeared(connection, name, client):
|
def on_name_appeared(connection, name, client):
|
||||||
global manager
|
global manager
|
||||||
logger.info('Connected to the Tuhi daemon')
|
logger.info('Connected to the Tuhi daemon')
|
||||||
manager = kete.TuhiKeteManager()
|
manager = tuhi.dbusclient.TuhiDBusClientManager()
|
||||||
|
|
||||||
for device in manager.devices:
|
for device in manager.devices:
|
||||||
logger.info(f'starting live on {device}, please press button on the device')
|
logger.info(f'starting live on {device}, please press button on the device')
|
||||||
|
@ -128,7 +137,7 @@ def run_live(request_fd_queue, conn_fd):
|
||||||
device.start_live(fd)
|
device.start_live(fd)
|
||||||
|
|
||||||
Gio.bus_watch_name(Gio.BusType.SESSION,
|
Gio.bus_watch_name(Gio.BusType.SESSION,
|
||||||
kete.TUHI_DBUS_NAME,
|
tuhi.dbusclient.TUHI_DBUS_NAME,
|
||||||
Gio.BusNameWatcherFlags.NONE,
|
Gio.BusNameWatcherFlags.NONE,
|
||||||
on_name_appeared,
|
on_name_appeared,
|
||||||
None)
|
None)
|
||||||
|
|
Loading…
Reference in New Issue