Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run inside a docker container. #70

Open
psukys opened this issue Feb 1, 2018 · 1 comment
Open

Can't run inside a docker container. #70

psukys opened this issue Feb 1, 2018 · 1 comment

Comments

@psukys
Copy link

psukys commented Feb 1, 2018

When trying to run through dbus-session-run python dbus_endpoint.py, I get the following error:

  File "dbus_endpoint.py", line 39, in <module>
    bus.publish(dbus_path, DbusEndpoint(dbus_path))
  File "/usr/local/lib/python2.7/dist-packages/pydbus/publication.py", line 42, in publish
    return Publication(self, bus_name, *objects)
  File "/usr/local/lib/python2.7/dist-packages/pydbus/publication.py", line 32, in __init__
    self._at_exit(bus.register_object(path, object, node_info).__exit__)
  File "/usr/local/lib/python2.7/dist-packages/pydbus/registration.py", line 152, in register_object
    node_info = [Gio.DBusNodeInfo.new_for_xml(ni) for ni in node_info]
GLib.Error: g-markup-error-quark: 1:1: Error on line 1 char 1: Document must begin with an element (e.g. <book>) (2)

Contents of dbus_endpoints.py

from gi.repository import GLib
from pydbus import SessionBus


class DbusEndpoint:
    """
    <node>
        <interface name='org.matcher.keywords'>
            <method name='match_keywords'>
                <arg type='as' name='keywords' direction='in' />
                <arg type='s' name='data' direction='in' />
                <arg type='as' name='response' direction='out' />
            </method>
        </interface>
    </node>
    """

    def __init__(self, dbus_path):
        self.my_dbus_path = dbus_path

    def match_keywords(self, keywords, data):
        return [keyword for keyword in keywords if keyword in data]


if __name__ == '__main__':
    loop = GLib.MainLoop()
    bus = SessionBus()
    dbus_path = 'org.matcher.keywords'
    bus.publish(dbus_path, DbusEndpoint(dbus_path))
    loop.run()
@psukys
Copy link
Author

psukys commented Feb 1, 2018

Ah yes, I must agree with

# Python 2 sux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant