Exemple #1
0
def bus():
    from pydbus import SessionBus

    bus = SessionBus()
    time.sleep(.5)
    print("\n[initalize] pydbus.SessionBus ...")
    bus.own_name(name="org.scarlett")
    # bus.dbus
    time.sleep(.5)
    yield bus
    print("\n[teardown] pydbus.SessionBus ...")
    # del bus._dbus
    print("ran: del bus._dbus")
    del bus
    print("ran: del bus")
Exemple #2
0
def bus():
    from pydbus import SessionBus

    bus = SessionBus()
    time.sleep(.5)
    print("\n[initalize] pydbus.SessionBus ...")
    bus.own_name(name="org.scarlett")
    # bus.dbus
    time.sleep(.5)
    yield bus
    print("\n[teardown] pydbus.SessionBus ...")
    # del bus._dbus
    print("ran: del bus._dbus")
    del bus
    print("ran: del bus")
Exemple #3
0
    if os.environ.get("SCARLETT_DEBUG_MODE"):
        import faulthandler

        faulthandler.register(signal.SIGUSR2, all_threads=True)

        from scarlett_os.internal.debugger import init_debugger
        from scarlett_os.internal.debugger import set_gst_grapviz_tracing

        init_debugger()
        set_gst_grapviz_tracing()
        # Example of how to use it

    from pydbus import SessionBus

    bus = SessionBus()
    # TODO: own_name() is deprecated, use request_name() instead.
    bus.own_name(name="org.scarlett")
    sl = ScarlettListener(bus=bus.con, path="/org/scarlett/Listener")
    loop.run()

    def sigint_handler(*args):
        """Exit on Ctrl+C"""

        # Unregister handler, next Ctrl-C will kill app
        # TODO: figure out if this is really needed or not
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        sl.Quit()

    signal.signal(signal.SIGINT, sigint_handler)
Exemple #4
0
        elif not type(result) is tuple:
            result = (result, )

        invocation.return_value(
            GLib.Variant(self.method_outargs[method_name], result))


class Foo(Server):
    '''
<node>
	<interface name='net.lvht.Foo1'>
		<method name='HelloWorld'>
			<arg type='s' name='a' direction='in'/>
			<arg type='i' name='b' direction='in'/>
			<arg type='s' name='response' direction='out'/>
		</method>
	</interface>
</node>
    '''
    def HelloWorld(self, a, b):
        return a + str(b)


if __name__ == '__main__':
    from pydbus import SessionBus
    bus = SessionBus()
    bus.own_name(name='net.lvht')

    foo = Foo(bus=bus.con, path='/net/lvht/Foo')
    foo.run()
                                self.result(struct['hypothesis'])
            except KeyboardInterrupt:
                pipeline.send_event(Gst.Event.new_eos())

        # Free resources
        pipeline.set_state(Gst.State.NULL)
        print "ScarlettListener stopped"


if __name__ == '__main__':
    global logger
    logger = setup_logger()

    from pydbus import SessionBus
    bus = SessionBus()
    bus.own_name(name='org.scarlett')
    sl = ScarlettListener(bus=bus.con, path='/org/scarlett/Listener')

    LANGUAGE_VERSION = 1473
    HOMEDIR = "/home/pi"
    LANGUAGE_FILE_HOME = "{}/dev/bossjones-github/scarlett-dbus-poc/tests/fixtures/lm".format(
        HOMEDIR)
    DICT_FILE_HOME = "{}/dev/bossjones-github/scarlett-dbus-poc/tests/fixtures/dict".format(
        HOMEDIR)
    LM_PATH = "{}/{}.lm".format(LANGUAGE_FILE_HOME, LANGUAGE_VERSION)
    DICT_PATH = "{}/{}.dic".format(DICT_FILE_HOME, LANGUAGE_VERSION)
    HMM_PATH = "{}/.virtualenvs/scarlett-dbus-poc/share/pocketsphinx/model/en-us/en-us".format(
        HOMEDIR)
    bestpath = 0
    PS_DEVICE = 'plughw:CARD=Device,DEV=0'
Exemple #6
0
        if type(result) is list:
            result = tuple(result)
        elif not type(result) is tuple:
            result = (result,)

        invocation.return_value(GLib.Variant(self.method_outargs[method_name], result))

class Foo(Server):
    '''
<node>
	<interface name='net.lvht.Foo1'>
		<method name='HelloWorld'>
			<arg type='s' name='a' direction='in'/>
			<arg type='i' name='b' direction='in'/>
			<arg type='s' name='response' direction='out'/>
		</method>
	</interface>
</node>
    '''
    def HelloWorld(self, a, b):
        return a + str(b)


if __name__ == '__main__':
    from pydbus import SessionBus
    bus = SessionBus()
    bus.own_name(name = 'net.lvht')

    foo = Foo(bus=bus.con, path='/net/lvht/Foo')
    foo.run()