Lua: translate a Python code that emits a message using a XML dbus definition into Lua The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceChildren of a DBus ObjectHow do I extract the returned data from QDBusMessage in a Qt DBus call?DBus, failed to obtain systemwide nameHow to display the interfaces of a particular dbus bus name (/org/bluez) in python?How to define a new d-bus interface that can be introspected?dbus call in C from shell dbus-sendPyQt 5.6: connecting to a DBus signal hangsAdd QObject to QT main loop in order to recieve dbus messagesHow to send unsigned values to dBus from Pythonlua lgi subscribe to DBus signal

Simulating Exploding Dice

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

Are spiders unable to hurt humans, especially very small spiders?

Does Parliament need to approve the new Brexit delay to 31 October 2019?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

Does Parliament hold absolute power in the UK?

One-dimensional Japanese puzzle

Presidential Pardon

What can I do if neighbor is blocking my solar panels intentionally?

Example of compact Riemannian manifold with only one geodesic.

Keeping a retro style to sci-fi spaceships?

Why are PDP-7-style microprogrammed instructions out of vogue?

Do warforged have souls?

How do spell lists change if the party levels up without taking a long rest?

"... to apply for a visa" or "... and applied for a visa"?

Homework question about an engine pulling a train

Is there a writing software that you can sort scenes like slides in PowerPoint?

Can the DM override racial traits?

What is the role of 'For' here?

Why doesn't a hydraulic lever violate conservation of energy?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

How to support a colleague who finds meetings extremely tiring?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?



Lua: translate a Python code that emits a message using a XML dbus definition into Lua



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceChildren of a DBus ObjectHow do I extract the returned data from QDBusMessage in a Qt DBus call?DBus, failed to obtain systemwide nameHow to display the interfaces of a particular dbus bus name (/org/bluez) in python?How to define a new d-bus interface that can be introspected?dbus call in C from shell dbus-sendPyQt 5.6: connecting to a DBus signal hangsAdd QObject to QT main loop in order to recieve dbus messagesHow to send unsigned values to dBus from Pythonlua lgi subscribe to DBus signal



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I asked this in a comment of a previous question but I think it is better to move it here as a new independent question.



I am trying to figure out how to translate this Python code to emit a dbus signal into Lua using lgi DBus:



class DBUSTestInterface(object):
"""
Server_XML definition.
Emit / Publish a signal that is a random integer every second
type='i' for integer.
"""
dbus = """
<node>
<interface name="com.test.device.aaa">
<signal name="get">
<arg type='s'/>
<arg type='s'/>
<arg type='s'/>
<arg type='s'/>
<arg type='s'/>
<arg type='s'/>
<arg type='s'/>
<arg type='i'/>
</signal>
</interface>
</node>
"""
get = signal()

emit = DBUSTestInterface()
bus.publish("com.test.device.get", emit)


I suspect (not sure at all) that it has to be made sending a message to the introspectable interface, something similar to this:



local object = "/org/freedesktop/DBus"
local interface = "org.freedesktop.DBus.Introspectable"
local method = "Introspect"
local message = Gio.DBusMessage.new_method_call(name, object, interface, method)
message:set_body(GLib.Variant("(aoo)", location,session)) -- How do I set the same message as above?


But I am not sure, and I have no idea of how to set the message body with the XML that is working in Python.



If you can provide some example or point out where I can find it I would appreciate it!



Thanks!










share|improve this question






























    1















    I asked this in a comment of a previous question but I think it is better to move it here as a new independent question.



    I am trying to figure out how to translate this Python code to emit a dbus signal into Lua using lgi DBus:



    class DBUSTestInterface(object):
    """
    Server_XML definition.
    Emit / Publish a signal that is a random integer every second
    type='i' for integer.
    """
    dbus = """
    <node>
    <interface name="com.test.device.aaa">
    <signal name="get">
    <arg type='s'/>
    <arg type='s'/>
    <arg type='s'/>
    <arg type='s'/>
    <arg type='s'/>
    <arg type='s'/>
    <arg type='s'/>
    <arg type='i'/>
    </signal>
    </interface>
    </node>
    """
    get = signal()

    emit = DBUSTestInterface()
    bus.publish("com.test.device.get", emit)


    I suspect (not sure at all) that it has to be made sending a message to the introspectable interface, something similar to this:



    local object = "/org/freedesktop/DBus"
    local interface = "org.freedesktop.DBus.Introspectable"
    local method = "Introspect"
    local message = Gio.DBusMessage.new_method_call(name, object, interface, method)
    message:set_body(GLib.Variant("(aoo)", location,session)) -- How do I set the same message as above?


    But I am not sure, and I have no idea of how to set the message body with the XML that is working in Python.



    If you can provide some example or point out where I can find it I would appreciate it!



    Thanks!










    share|improve this question


























      1












      1








      1








      I asked this in a comment of a previous question but I think it is better to move it here as a new independent question.



      I am trying to figure out how to translate this Python code to emit a dbus signal into Lua using lgi DBus:



      class DBUSTestInterface(object):
      """
      Server_XML definition.
      Emit / Publish a signal that is a random integer every second
      type='i' for integer.
      """
      dbus = """
      <node>
      <interface name="com.test.device.aaa">
      <signal name="get">
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='i'/>
      </signal>
      </interface>
      </node>
      """
      get = signal()

      emit = DBUSTestInterface()
      bus.publish("com.test.device.get", emit)


      I suspect (not sure at all) that it has to be made sending a message to the introspectable interface, something similar to this:



      local object = "/org/freedesktop/DBus"
      local interface = "org.freedesktop.DBus.Introspectable"
      local method = "Introspect"
      local message = Gio.DBusMessage.new_method_call(name, object, interface, method)
      message:set_body(GLib.Variant("(aoo)", location,session)) -- How do I set the same message as above?


      But I am not sure, and I have no idea of how to set the message body with the XML that is working in Python.



      If you can provide some example or point out where I can find it I would appreciate it!



      Thanks!










      share|improve this question
















      I asked this in a comment of a previous question but I think it is better to move it here as a new independent question.



      I am trying to figure out how to translate this Python code to emit a dbus signal into Lua using lgi DBus:



      class DBUSTestInterface(object):
      """
      Server_XML definition.
      Emit / Publish a signal that is a random integer every second
      type='i' for integer.
      """
      dbus = """
      <node>
      <interface name="com.test.device.aaa">
      <signal name="get">
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='s'/>
      <arg type='i'/>
      </signal>
      </interface>
      </node>
      """
      get = signal()

      emit = DBUSTestInterface()
      bus.publish("com.test.device.get", emit)


      I suspect (not sure at all) that it has to be made sending a message to the introspectable interface, something similar to this:



      local object = "/org/freedesktop/DBus"
      local interface = "org.freedesktop.DBus.Introspectable"
      local method = "Introspect"
      local message = Gio.DBusMessage.new_method_call(name, object, interface, method)
      message:set_body(GLib.Variant("(aoo)", location,session)) -- How do I set the same message as above?


      But I am not sure, and I have no idea of how to set the message body with the XML that is working in Python.



      If you can provide some example or point out where I can find it I would appreciate it!



      Thanks!







      lua dbus lgi






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 11 at 14:51









      Piglet

      8,74221123




      8,74221123










      asked Mar 8 at 12:13









      jap japjap jap

      11311




      11311






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Heh, Google just lead me here while looking at https://github.com/pavouk/lgi/issues/220.



          Somehow I feel like your code example cannot work as-is / is not some self-contained python code. Hence, I will go with the comment in the text:




          Emit / Publish a signal that is a random integer every second




          Lua code doing this (well, except for "random integer", unless you consider 42 to be random):



          local lgi = require("lgi")
          local Gio, GLib, GObject = lgi.Gio, lgi.GLib, lgi.GObject

          local conn

          GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, function()
          if conn then
          conn:emit_signal(nil, "/your/example/has/no/path",
          "com.test.device.aaa", "get",
          GLib.Variant("(sssssssi)", "what", "are", "all",
          "these", "strings", "for", "?", 42 ))
          end
          return true
          end)

          local function on_bus_acquire(con)
          conn = con

          local function arg(name, signature)
          return Gio.DBusArgInfo name = name, signature = signature
          end
          local interface_info = Gio.DBusInterfaceInfo
          name = "com.test.device.aaa",
          signals =
          Gio.DBusSignalInfo
          name = "get",
          args =
          arg("no_name?!?", "s"),
          arg("no_name?!?", "s"),
          arg("no_name?!?", "s"),
          arg("no_name?!?", "s"),
          arg("no_name?!?", "s"),
          arg("no_name?!?", "s"),
          arg("no_name?!?", "s"),
          arg("no_name?!?", "i")




          conn:register_object("/your/example/has/no/path", interface_info, nil)
          end

          Gio.bus_own_name(Gio.BusType.SESSION, "com.test.device.get", Gio.BusNameOwnerFlags.NONE,
          GObject.Closure(on_bus_acquire), nil, nil)

          GLib.MainLoop.new():run()





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063015%2flua-translate-a-python-code-that-emits-a-message-using-a-xml-dbus-definition-in%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Heh, Google just lead me here while looking at https://github.com/pavouk/lgi/issues/220.



            Somehow I feel like your code example cannot work as-is / is not some self-contained python code. Hence, I will go with the comment in the text:




            Emit / Publish a signal that is a random integer every second




            Lua code doing this (well, except for "random integer", unless you consider 42 to be random):



            local lgi = require("lgi")
            local Gio, GLib, GObject = lgi.Gio, lgi.GLib, lgi.GObject

            local conn

            GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, function()
            if conn then
            conn:emit_signal(nil, "/your/example/has/no/path",
            "com.test.device.aaa", "get",
            GLib.Variant("(sssssssi)", "what", "are", "all",
            "these", "strings", "for", "?", 42 ))
            end
            return true
            end)

            local function on_bus_acquire(con)
            conn = con

            local function arg(name, signature)
            return Gio.DBusArgInfo name = name, signature = signature
            end
            local interface_info = Gio.DBusInterfaceInfo
            name = "com.test.device.aaa",
            signals =
            Gio.DBusSignalInfo
            name = "get",
            args =
            arg("no_name?!?", "s"),
            arg("no_name?!?", "s"),
            arg("no_name?!?", "s"),
            arg("no_name?!?", "s"),
            arg("no_name?!?", "s"),
            arg("no_name?!?", "s"),
            arg("no_name?!?", "s"),
            arg("no_name?!?", "i")




            conn:register_object("/your/example/has/no/path", interface_info, nil)
            end

            Gio.bus_own_name(Gio.BusType.SESSION, "com.test.device.get", Gio.BusNameOwnerFlags.NONE,
            GObject.Closure(on_bus_acquire), nil, nil)

            GLib.MainLoop.new():run()





            share|improve this answer



























              1














              Heh, Google just lead me here while looking at https://github.com/pavouk/lgi/issues/220.



              Somehow I feel like your code example cannot work as-is / is not some self-contained python code. Hence, I will go with the comment in the text:




              Emit / Publish a signal that is a random integer every second




              Lua code doing this (well, except for "random integer", unless you consider 42 to be random):



              local lgi = require("lgi")
              local Gio, GLib, GObject = lgi.Gio, lgi.GLib, lgi.GObject

              local conn

              GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, function()
              if conn then
              conn:emit_signal(nil, "/your/example/has/no/path",
              "com.test.device.aaa", "get",
              GLib.Variant("(sssssssi)", "what", "are", "all",
              "these", "strings", "for", "?", 42 ))
              end
              return true
              end)

              local function on_bus_acquire(con)
              conn = con

              local function arg(name, signature)
              return Gio.DBusArgInfo name = name, signature = signature
              end
              local interface_info = Gio.DBusInterfaceInfo
              name = "com.test.device.aaa",
              signals =
              Gio.DBusSignalInfo
              name = "get",
              args =
              arg("no_name?!?", "s"),
              arg("no_name?!?", "s"),
              arg("no_name?!?", "s"),
              arg("no_name?!?", "s"),
              arg("no_name?!?", "s"),
              arg("no_name?!?", "s"),
              arg("no_name?!?", "s"),
              arg("no_name?!?", "i")




              conn:register_object("/your/example/has/no/path", interface_info, nil)
              end

              Gio.bus_own_name(Gio.BusType.SESSION, "com.test.device.get", Gio.BusNameOwnerFlags.NONE,
              GObject.Closure(on_bus_acquire), nil, nil)

              GLib.MainLoop.new():run()





              share|improve this answer

























                1












                1








                1







                Heh, Google just lead me here while looking at https://github.com/pavouk/lgi/issues/220.



                Somehow I feel like your code example cannot work as-is / is not some self-contained python code. Hence, I will go with the comment in the text:




                Emit / Publish a signal that is a random integer every second




                Lua code doing this (well, except for "random integer", unless you consider 42 to be random):



                local lgi = require("lgi")
                local Gio, GLib, GObject = lgi.Gio, lgi.GLib, lgi.GObject

                local conn

                GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, function()
                if conn then
                conn:emit_signal(nil, "/your/example/has/no/path",
                "com.test.device.aaa", "get",
                GLib.Variant("(sssssssi)", "what", "are", "all",
                "these", "strings", "for", "?", 42 ))
                end
                return true
                end)

                local function on_bus_acquire(con)
                conn = con

                local function arg(name, signature)
                return Gio.DBusArgInfo name = name, signature = signature
                end
                local interface_info = Gio.DBusInterfaceInfo
                name = "com.test.device.aaa",
                signals =
                Gio.DBusSignalInfo
                name = "get",
                args =
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "i")




                conn:register_object("/your/example/has/no/path", interface_info, nil)
                end

                Gio.bus_own_name(Gio.BusType.SESSION, "com.test.device.get", Gio.BusNameOwnerFlags.NONE,
                GObject.Closure(on_bus_acquire), nil, nil)

                GLib.MainLoop.new():run()





                share|improve this answer













                Heh, Google just lead me here while looking at https://github.com/pavouk/lgi/issues/220.



                Somehow I feel like your code example cannot work as-is / is not some self-contained python code. Hence, I will go with the comment in the text:




                Emit / Publish a signal that is a random integer every second




                Lua code doing this (well, except for "random integer", unless you consider 42 to be random):



                local lgi = require("lgi")
                local Gio, GLib, GObject = lgi.Gio, lgi.GLib, lgi.GObject

                local conn

                GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, function()
                if conn then
                conn:emit_signal(nil, "/your/example/has/no/path",
                "com.test.device.aaa", "get",
                GLib.Variant("(sssssssi)", "what", "are", "all",
                "these", "strings", "for", "?", 42 ))
                end
                return true
                end)

                local function on_bus_acquire(con)
                conn = con

                local function arg(name, signature)
                return Gio.DBusArgInfo name = name, signature = signature
                end
                local interface_info = Gio.DBusInterfaceInfo
                name = "com.test.device.aaa",
                signals =
                Gio.DBusSignalInfo
                name = "get",
                args =
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "s"),
                arg("no_name?!?", "i")




                conn:register_object("/your/example/has/no/path", interface_info, nil)
                end

                Gio.bus_own_name(Gio.BusType.SESSION, "com.test.device.get", Gio.BusNameOwnerFlags.NONE,
                GObject.Closure(on_bus_acquire), nil, nil)

                GLib.MainLoop.new():run()






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 11 at 17:02









                Uli SchlachterUli Schlachter

                5,2481730




                5,2481730





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063015%2flua-translate-a-python-code-that-emits-a-message-using-a-xml-dbus-definition-in%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved