view flatpak/sat_wrapper.py @ 139:d36a68e396d5

flatpak: set appdata release version for dev version: appdata file can now use a template (which has the same name with "_tpl_" prefix), which is used in dev version to automatically set the release with the right Mercurial revision/date. Comment from org.salutatoi.Cagou.appdata.xml has been moved as first child of <component>, so it is not lost while parsing the file.
author Goffi <goffi@goffi.org>
date Sun, 23 Jun 2019 17:34:10 +0200
parents 274af514a5cf
children 2602c690806b
line wrap: on
line source

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""This script launch SàT backend if it's not before running command"""

import os
import sys
import dbus
import subprocess

command = "##COMMAND##"
const_INT_PREFIX = "org.salutatoi.SAT"
const_OBJ_PATH = '/org/salutatoi/SAT/bridge'


try:
    sessions_bus = dbus.SessionBus()
    db_object = sessions_bus.get_object(const_INT_PREFIX,
                                        const_OBJ_PATH)
except dbus.exceptions.DBusException as e:
    if e._dbus_error_name != 'org.freedesktop.DBus.Error.ServiceUnknown':
        raise e
    # backend not found, we need to launch it
    print("Launching SàT backend")
    subprocess.check_call("sat")

os.execlp(command, command, *sys.argv[1:])