[Twisted-Python] question : dbus for twistd application framework
Dear all ... I need my twistd script to also 'listen' to dbus. The only example that I found so far is : http://twistedmatrix.com/trac/attachment/ticket/1352/dbus-twisted.py Buit that example not using some thing like : application = service.Application("MyApp") Is there any example of dbus implementation on twistd that use service.Application ? Sincerely -bino-
All you should need to do is install the glib reactor. Note that dbus-python (and libdbus-1, and libdbus-glib) is deprecated. The recommended solution is to use GDBus. See http://developer.gnome.org/gio/stable/ch30.html On Mon, May 28, 2012 at 11:03 PM, bino oetomo <bino@indoakses-online.com> wrote:
Dear all ...
I need my twistd script to also 'listen' to dbus. The only example that I found so far is : http://twistedmatrix.com/trac/attachment/ticket/1352/dbus-twisted.py Buit that example not using some thing like : application = service.Application("MyApp")
Is there any example of dbus implementation on twistd that use service.Application ?
Sincerely -bino-
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Jasper
On May 28, 2012, at 11:22 PM, Jasper St. Pierre wrote:
Note that dbus-python (and libdbus-1, and libdbus-glib) is deprecated. The recommended solution is to use GDBus.
Is it? dbus-python seems like a healthy project, getting new releases fairly regularly. For example, as of 1.0, dbus-python supports Python 3. There are also legitimate reasons not to want to use GDBus. Cheers, -Barry
On Wed, May 30, 2012 at 5:24 PM, Barry Warsaw <barry@python.org> wrote:
On May 28, 2012, at 11:22 PM, Jasper St. Pierre wrote:
Note that dbus-python (and libdbus-1, and libdbus-glib) is deprecated. The recommended solution is to use GDBus.
Is it? dbus-python seems like a healthy project, getting new releases fairly regularly. For example, as of 1.0, dbus-python supports Python 3. There are also legitimate reasons not to want to use GDBus.
What would those be?
Cheers, -Barry
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Jasper
On May 30, 2012, at 05:35 PM, Jasper St. Pierre wrote:
regularly. For example, as of 1.0, dbus-python supports Python 3. There are also legitimate reasons not to want to use GDBus.
What would those be?
A simple, pure-Python server for example. You can do that with dbus-python and minimal other dependencies. Cheers, -Barry
On 05/28/2012 11:03 PM, bino oetomo wrote:
Dear all ...
I need my twistd script to also 'listen' to dbus. The only example that I found so far is : http://twistedmatrix.com/trac/attachment/ticket/1352/dbus-twisted.py Buit that example not using some thing like : application = service.Application("MyApp")
Is there any example of dbus implementation on twistd that use service.Application ?
Applications are just a *deployment* method, providing startup and shutdown notification; they're not really relevant to how you interact with dbus. See http://twistedmatrix.com/documents/current/core/howto/application.html - converting code from reactor.run() to Application/twistd usage just involves creating a Service.
Dear All c/q Itamar, I really appreciate your enlightment On 05/29/2012 09:14 PM, Itamar Turner-Trauring wrote:
Applications are just a *deployment* method, providing startup and shutdown notification; they're not really relevant to how you interact with dbus. See http://twistedmatrix.com/documents/current/core/howto/application.html - converting code from reactor.run() to Application/twistd usage just involves creating a Service.
Kindly please give me example of realy simple reactor.run() type script ... and how to turn it to a service and join to a MultiService ? Sincerely -bino-
Here's an example based on an application that I have in production. It's a bit amateurish - and I'm going to mangle the language - but you should get the idea. This is an extract from the main script: === Class Handler(Resource): pass # application code goes here - HTTP request handling, etc. def get_handler(): handler = Handler() factory = server.Site(handler) return factory if __name__ == '__main__': from twisted.internet import reactor factory = get_handler() reactor.addSystemEventTrigger('before', 'shutdown', cleanup) reactor.listenTCP(8080, factory) reactor.run() === If you run the above script, it will run Twisted from a trapped terminal. For deployment, I've built a server.tac file in the same directory: === import twisted.application.service as Service from twisted.application.service import IProcess from twisted.application.internet import TCPServer # append the working directory to sys.path so that we can import the handler module import sys import os sys.path.append(os.path.dirname(__file__)) import handler factory = handler.get_handler() application = Service.Application('Data Collector') IProcess(application).processName = 'data-collector' TCPServer(8080, factory).setServiceParent(application) === I can then run this command: === twistd -y server.tac === And it'll start up the server and daemonise the process, running it as a service. You can import any code you one in your server.tac script and keep it in your service. It's really just a very simple abstraction of the kind of plumbing you need to do to get a process to detach from the terminal you run it in. On Thu, May 31, 2012 at 12:27 PM, bino oetomo <bino@indoakses-online.com> wrote:
Dear All
c/q Itamar, I really appreciate your enlightment On 05/29/2012 09:14 PM, Itamar Turner-Trauring wrote:
Applications are just a *deployment* method, providing startup and shutdown notification; they're not really relevant to how you interact with dbus. See http://twistedmatrix.com/documents/current/core/howto/application.html - converting code from reactor.run() to Application/twistd usage just involves creating a Service.
Kindly please give me example of realy simple reactor.run() type script ... and how to turn it to a service and join to a MultiService ?
Sincerely -bino-
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On 05/31/2012 09:43 AM, Daniel Bryan wrote:
Here's an example based on an application that I have in production. It's a bit amateurish - and I'm going to mangle the language - but you should get the idea.
This is an extract from the main script:
=== Class Handler(Resource): pass # application code goes here - HTTP request handling, etc.
...
If you run the above script, it will run Twisted from a trapped terminal.
For deployment, I've built a server.tac file in the same directory:
=== import twisted.application.service as Service from twisted.application.service import IProcess from twisted.application.internet import TCPServer # append the working directory to sys.path so that we can import the handler module import sys import os sys.path.append(os.path.dirname(__file__))
import handler
factory = handler.get_handler() application = Service.Application('Data Collector') IProcess(application).processName = 'data-collector' TCPServer(8080, factory).setServiceParent(application) ===
I can then run this command:
=== twistd -y server.tac ===
And it'll start up the server and daemonise the process, running it as a service.
Shame on my lame brain !! So ... if currently my 'core' script is a tac file ... and the 'additional' script come in reactor.run style ... basically ... all I need is to 'import' the 'additional' to my current tac file. Right ? Sincerely -bino-
participants (5)
-
Barry Warsaw -
bino oetomo -
Daniel Bryan -
Itamar Turner-Trauring -
Jasper St. Pierre