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;
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
add a comment |
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
add a comment |
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
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
lua dbus lgi
edited Mar 11 at 14:51
Piglet
8,74221123
8,74221123
asked Mar 8 at 12:13
jap japjap jap
11311
11311
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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()
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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()
add a comment |
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()
add a comment |
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()
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()
answered Mar 11 at 17:02
Uli SchlachterUli Schlachter
5,2481730
5,2481730
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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