Re: [Twisted-Python] Twisted and wxPython
from twisted.internet import wxreactor wxreactor.install() from twisted.internet import reactor . write your code here . reactor.registerWxApp(app) reactor.run() You don't need wx mainloop. The key thing here is to import wxreactor first and install it and then import reactor. 'app' in the last but one line is the instance of your wx.App . On Fri, Aug 28, 2009 at 11:05 AM, 陶艺夫 wrote: > Hi, > Anyone can give me a sample app skeleton to get two frameworks work > together well? Or just give me a link where I can figure out the technical > details. > > Thanks. > > ___ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > > -- Thanks & Regards, Godson Gera http://godson.in ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] Twisted and wxPython
Hi, Anyone can give me a sample app skeleton to get two frameworks work together well? Or just give me a link where I can figure out the technical details. Thanks. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Some way for Trial to allow selective running of tests?
Don Dwiggins wrote: > Phil Christensen wrote: > > trial takes an argument at the command-line where you can specify a > > package or test case. > > > > for example: > > > > trial twisted > > trial twisted.test > > trial twisted.test.test_explorer > > trial twisted.test.test_explorer.TestBrowser > > trial twisted.test.test_explorer.TestBrowser.test_chain > > > > lets you get more and more specific. > > > > -phil > > Sorry, I'm feeling dense. I currently run it as > "trial MyServerTestFile.py"; it's not a package or part of one. In the > file are several classes, each with several test cases. How would I > adapt the above to my needs? trial takes either a path and filename, or a Python import name (I'm not sure what the exact term here is). If you ran python in the same directory where you ran "trial" in your example, you could say: import MyServerTestFile MyServerTestFile.MyServerTestCase.test_my_server ...to refer to a particular test method, and trial will accept the same syntax: trial MyServerTestFile.MyServerTestCase.test_my_server In general though, a lot of distribution and packaging and deployment things become easier if your project is laid out in Python packages. I usually follow these rules and everything turns out pretty well: http://jcalderone.livejournal.com/39794.html signature.asc Description: PGP signature ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] A C/S Application over Internet
thank you for sharing your experience. Frankly, I do love twisted for its decent implementation of asyn call concept. 2009/8/28 Phil Christensen > On Aug 27, 2009, at 10:57 AM, 陶艺夫 wrote: > > Thank you, Phil. > > > > Pyro has many examples, so I can understand it easily. I know > > Twisted is great. I think your "switching" must mean something :) . > > So I decide to use twisted PB. > > > Great! > > I also remembered one thing that I found was extremely useful when > dealing with a GUI app that communicates over PB. Since PB assumes > every remote method call will take an arbitrary amount of time to > execute, you can delay the response from the client as long as you need. > > For example, let's say the server sends a block of text to the client > for editing. Your client-side function can create a Deferred, hold a > reference to it somewhere, and return that from the client function. > > PB won't actually send a response until you invoke the callback() > method on that Deferred, so you can pop open a GUI window, let the > user edit the text (or just sit there staring at it for an hour), and > then trigger the callback when the user hits 'Save'. > > Very useful, although I wrote some incredibly stupid code to emulate > this long before I realized how easy it was ;-) > > -phil > ___ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Telnet example
yes! 2009/8/28 Johann Borck : > Darvin nb wrote: >> Can anybody tell me, is there telnet example written with Twisted? >> > like twisted.conch.telnet ? > > hth, Johann > > ___ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Telnet example
Darvin nb wrote: > Can anybody tell me, is there telnet example written with Twisted? > like twisted.conch.telnet ? hth, Johann ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] Telnet example
Can anybody tell me, is there telnet example written with Twisted? ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Some way for Trial to allow selective running of tests?
On Aug 27, 2009, at 4:08 PM, Phil Christensen wrote: > On Aug 27, 2009, at 4:00 PM, Don Dwiggins wrote: >> I've been successfully and happily using Trial for a while now for >> development of a server. I have many tests at this point; during >> development of a new feature, I'd like to have a convenient way to >> only >> run the tests relevant to that feature. >> >> I'm hacking it at this point by prefixing the names of all unwanted >> tests with "foo" to keep them from being recognized. Naturally, I'd >> like a better way to do this. Any good words welcome. > > trial takes an argument at the command-line where you can specify a > package or test case. > > for example: > > trial twisted > trial twisted.test > trial twisted.test.test_explorer > trial twisted.test.test_explorer.TestBrowser > trial twisted.test.test_explorer.TestBrowser.test_chain > > lets you get more and more specific. Right, but, far as I can tell, you can only do one at a time. I just want to run the list of ones I know are working even though there are many more written and waiting to be pulled in and debugged (one at a time). IOW, I want to specify a list of tests to run out of many that match the file pattern. S ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Some way for Trial to allow selective running of tests?
On Aug 27, 2009, at 4:00 PM, Don Dwiggins wrote: > I've been successfully and happily using Trial for a while now for > development of a server. I have many tests at this point; during > development of a new feature, I'd like to have a convenient way to > only > run the tests relevant to that feature. > > I'm hacking it at this point by prefixing the names of all unwanted > tests with "foo" to keep them from being recognized. Naturally, I'd > like a better way to do this. Any good words welcome. I was just running into this yesterday and had actually pulled the code for the one thing I use trial for ( the emacs line @ the top of the file to specify unit tests) out to make a nose plug-in since nose allows lists of tests to be put into config files. I'd love to have another way as I will need Trial for the Twisted part of my code later. Thanks, S ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] twisted.names.error.DNSNameError on MacOsX but not on linux
Ralph Meijer wrote: > On Tue, 2009-08-11 at 18:30 +0200, Gabriel Rossetti wrote: > >> [..] >> > > Apparently you modified the original example here: > > >> [..] >> connector = XMPPClientConnector(reactor, "10.204.232.117", f) >> connector.connect() >> > > This would never work properly. XMPPClientConnector is designed to do an > SRV record look up on the /domain/ provided as its second argument. You > pass an IP address here and that will just fail. > > The original example passes client_jid.host. This extracts the domain > from the JID you want to connect with and then follows the procedure of > first trying to find xmpp-server SRV records for that domain, and if > that fails, try to connect to the host that the domain name resolves to, > using the default port (5222), as outlined in RFC 3920. Note that > XMPPClientConnector avoids the problems sketched in ticket #3456 that > was mentioned by Jean-Paul. > > If you really want to connect to a specific host instead of following > the above procedure, you can do this instead of the code quoted above: > > reactor.connectTCP("10.204.232.117", 5222, f) > > Hmmm, ok, it works on linux and windows though, but I did as you said anyways as it's still flacky on mac. Thanks, Gabriel -- Arimaz SA Ingénieur en Informatique Av. du 24 Janvier 11 Ateliers de la Ville de Renens, Atelier 5 1020 Renens, Switzerland www.arimaz.com www.mydeskfriend.com Mob: +41-(0)79-539-0069 Tel: +41-(0)21-566-7343 ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Some way for Trial to allow selective running of tests?
Phil Christensen wrote: > trial takes an argument at the command-line where you can specify a > package or test case. > > for example: > > trial twisted > trial twisted.test > trial twisted.test.test_explorer > trial twisted.test.test_explorer.TestBrowser > trial twisted.test.test_explorer.TestBrowser.test_chain > > lets you get more and more specific. > > -phil Sorry, I'm feeling dense. I currently run it as "trial MyServerTestFile.py"; it's not a package or part of one. In the file are several classes, each with several test cases. How would I adapt the above to my needs? -- Don Dwiggins Advanced Publishing Technology ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Some way for Trial to allow selective running of tests?
On Aug 27, 2009, at 4:00 PM, Don Dwiggins wrote: > I've been successfully and happily using Trial for a while now for > development of a server. I have many tests at this point; during > development of a new feature, I'd like to have a convenient way to > only > run the tests relevant to that feature. > > I'm hacking it at this point by prefixing the names of all unwanted > tests with "foo" to keep them from being recognized. Naturally, I'd > like a better way to do this. Any good words welcome. trial takes an argument at the command-line where you can specify a package or test case. for example: trial twisted trial twisted.test trial twisted.test.test_explorer trial twisted.test.test_explorer.TestBrowser trial twisted.test.test_explorer.TestBrowser.test_chain lets you get more and more specific. -phil ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] Some way for Trial to allow selective running of tests?
I've been successfully and happily using Trial for a while now for development of a server. I have many tests at this point; during development of a new feature, I'd like to have a convenient way to only run the tests relevant to that feature. I'm hacking it at this point by prefixing the names of all unwanted tests with "foo" to keep them from being recognized. Naturally, I'd like a better way to do this. Any good words welcome. -- Don Dwiggins Advanced Publishing Technology ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] How to capture output from transport of HTTPClientFactory?
On 06:30 pm, konr...@smelkovs.com wrote: >Hi, >HTTPClientFactory uses self.transport to do reads/writes. I would like >to >have a copy of all data in and out for debugging/logging purposes. >How to do that (best?)? twisted.protocols.policies.TrafficLoggingFactory may do what you want. Jean-Paul ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] How to capture output from transport of HTTPClientFactory?
Hi, HTTPClientFactory uses self.transport to do reads/writes. I would like to have a copy of all data in and out for debugging/logging purposes. How to do that (best?)? -- Konrads Smelkovs Applied IT sorcery. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] deciding to use twisted or not
Martin-Louis Bright gmail.com> writes: > > > I am using linux, and I want the daemon to be as responsive as possible to log events, so I think I would rather have it sit on the same box as where the log is produced. (Perhaps I'm wrong about this?) So I'm going to try Cary's ProcessProtocol approach, and if that doesn't work, Glyph's LoopingCall with a read() approach. > You can also use pyinotify to watch your log file changes. http://trac.dbzteam.org/pyinotify Regards, Mikhail ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] A C/S Application over Internet
On Aug 27, 2009, at 10:57 AM, 陶艺夫 wrote: > Thank you, Phil. > > Pyro has many examples, so I can understand it easily. I know > Twisted is great. I think your "switching" must mean something :) . > So I decide to use twisted PB. Great! I also remembered one thing that I found was extremely useful when dealing with a GUI app that communicates over PB. Since PB assumes every remote method call will take an arbitrary amount of time to execute, you can delay the response from the client as long as you need. For example, let's say the server sends a block of text to the client for editing. Your client-side function can create a Deferred, hold a reference to it somewhere, and return that from the client function. PB won't actually send a response until you invoke the callback() method on that Deferred, so you can pop open a GUI window, let the user edit the text (or just sit there staring at it for an hour), and then trigger the callback when the user hits 'Save'. Very useful, although I wrote some incredibly stupid code to emulate this long before I realized how easy it was ;-) -phil ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] A C/S Application over Internet
Thank you, Phil. Pyro has many examples, so I can understand it easily. I know Twisted is great. I think your "switching" must mean something :) . So I decide to use twisted PB. 2009/8/27 Phil Christensen > On Aug 27, 2009, at 9:33 AM, 陶艺夫 wrote: > > I want to develop an C/S app over internet using twisted Perspective > > Broker. The server will run as a windows service, and the clients > > will be wxPython desktop applications. > > Has anyone done the same thing or known the trick to do it? Shoud > > I use PB or Pyro or SPyro? Which is the best? > > I started with Pyro on a project years ago, and ended up switching to > PB in short order. I was less familiar with Twisted at the time, but I > still found PB to be superior. Of course, I haven't paid attention to > Pyro in years and know virtually nothing of SPyro. > > Of course, you are coming into a Twisted list and asking if you should > use Twisted or something else, so my response is naturally a little > biased. ;-) > > -phil > ___ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] A C/S Application over Internet
On Aug 27, 2009, at 9:33 AM, 陶艺夫 wrote: > I want to develop an C/S app over internet using twisted Perspective > Broker. The server will run as a windows service, and the clients > will be wxPython desktop applications. > Has anyone done the same thing or known the trick to do it? Shoud > I use PB or Pyro or SPyro? Which is the best? I started with Pyro on a project years ago, and ended up switching to PB in short order. I was less familiar with Twisted at the time, but I still found PB to be superior. Of course, I haven't paid attention to Pyro in years and know virtually nothing of SPyro. Of course, you are coming into a Twisted list and asking if you should use Twisted or something else, so my response is naturally a little biased. ;-) -phil ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Re : Telnet server using Twisted and AuthenticatingTelnetProtocol
On 24 Aug, 11:07 pm, filoufake-pyt...@yahoo.fr wrote: >Thank you Jean-Paul for replying, > >I still have some things that I don't understand: > >If I put your piece of code in my factory's protocol, I can connect to >the server but as soon as I enter the username, I got the an error >message telling that Server doesn't support "will" ('Server' object has >no attribute 'will'). That means you've hooked up a telnet protocol to a tcp transport, rather than a telnet transport. The telnet transport sits between these two things and adds features like "will" negotiation; it also is in charge of actually interpreting telnet command sequences received from the network and turning them into calls onto your telnet protocol instance. Without the telnet transport, the telnet protocol just gets raw data. >[snip] > >I understand that this has something to do with TelnetTranport but how >to implement it? >I read the telnet_echo.tac but in my case I have to manage the portal >also and that is a litle bit too complex for me. If necessary, you can pass arguments to your telnet protocol. telnet_echo.tac uses "lambda: TelnetTransport(TelnetEcho)" as its protocol. If TelnetEcho took an argument to __init__, though, you could supply it by using this as your protocol instead: "lambda: TelnetTransport(TelnetEcho, foo)". Does that help? > >You say also that AuthenticatingTelnetProtocol expects to be connected >to an ITelnetTransport, but the documentation says "When the >information is collected, it is passed to a portal and an avatar >implementing ITelnetProtocol is requested". >I'm lost. AuthenticatingTelnetProtocol is an ITelnetProtocol implementation. So, it needs to be hooked up to an ITelnetTransport implementation, as all ITelnetProtocol implementations need to. However, since the only thing it knows how to do is handle authentication, it also wants to get /another/ ITelnetProtocol implementation out of the portal you give it. After authentication succeeds, that new ITelnetProtocol implementation will be given control of the connection and the AuthenticatingTelnetProtocol will get out of the way. So you end up with one telnet transport and two telnet protocols. Jean-Paul ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] deciding to use twisted or not
I am using linux, and I want the daemon to be as responsive as possible to log events, so I think I would rather have it sit on the same box as where the log is produced. (Perhaps I'm wrong about this?) So I'm going to try Cary's ProcessProtocol approach, and if that doesn't work, Glyph's LoopingCall with a read() approach. Thanks for the link. -martin On Thu, Aug 27, 2009 at 8:11 AM, Chris Adams wrote: > If you're using a linux based system, you may have some luck setting > up syslogger to forward logging packets to the remote ip address, and > running the twisted daemon on the other box, and sending notifications > if the heartbeat from the monitored machine stops. > > I was working on a project recently to set up a monitor a RFID based > access control system for building, that runs on > twisted/openwrt/linux, we used an approach like this. > > The link below shows a sample twisted python file that runs on a > monitoring machine. > > > http://github.com/derfred/doord/blob/cd300a1cde930c07cd13d98be3e45cb89df79809/log_watcher.py > > ___ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] OT - adbapi, connection timeouts, mysql - OT
On 26 Aug, 11:08 pm, clay.gerr...@rackspace.com wrote: >The way that sqlalchemy implements pool_recycle is "irrespective of >idle time" best I can tell from looking at it. Keeping track of the >last_used_time seems like it would have been equally reasonable, >although perhaps even additional overhead. It probably wouldn't be much more overhead. The important question to consider is whether SQLAlchemy (and whoever else) had another good reason for doing it the way they do it. Is monitoring idle time not sufficient for some systems? > >I'm not sure I understand what you mean by "parameterize the reactor" - >pass it as an argument when you initialize the (Re)ConnectionPool? Can >you point me to a twisted class that does this as an example? Yep, that's what I meant. You can find examples of this in some of the newer code in Twisted (as we only started to encourage it relatively recently). One example is twisted.web.wsgi.WSGIResource; another is twisted.internet.task.deferLater. > >I agree it would be very cool "to do the reconnecting more proactively >in idle threads" - I'll have to think on that, do you know off-hand of >any analogs? Hm. I can't think of any analogs, no. I hope the implementation would be straightforward, though. The connection pool can use reactor.callLater in the main thread to force old connections to be re- established, and it can take those connections out of the lineup while it's doing that, to make sure no queries are dispatched to them. One tricky part, though, may be ensuring that a connection isn't actively servicing a query when time comes to recycle it. The thread pool used by the connection pool may not currently have the features required for this (it doesn't allow messages to be directed at specific threads, for example). This feature may also not be terribly important. I don't know what the reconnect overhead actually is. Jean-Paul ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] twisted.positioning progress report
Time for a little show and tell :-) Watch as line noise gets transformed into beautiful Python structures: http://paste.pocoo.org/show/136539/ Yay. Still to do: - A bit of documentation here and there, some of this NMEA stuff is far too arcane to be docstringless - A few methods need removing, PositioningError should contain all of the PositioningErrors really - Writing the lore docs (man, I hate that) - A bit of the stateful updates need to be moved around a bit - A factory for creating these The advantage is that all except the second point will not significantly change the API anymore. Yay! (if you see something in that output you really dont like now would be a good time to tell me) The code, as always, is available in the usual places (launchpad branch: https://code.launchpad.net/~lvh/twisted/positioning) enjoy Laurens ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] A C/S Application over Internet
Hi, I want to develop an C/S app over internet using twisted Perspective Broker. The server will run as a windows service, and the clients will be wxPython desktop applications. Has anyone done the same thing or known the trick to do it? Shoud I use PB or Pyro or SPyro? Which is the best? Thanks. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] deciding to use twisted or not
If you're using a linux based system, you may have some luck setting up syslogger to forward logging packets to the remote ip address, and running the twisted daemon on the other box, and sending notifications if the heartbeat from the monitored machine stops. I was working on a project recently to set up a monitor a RFID based access control system for building, that runs on twisted/openwrt/linux, we used an approach like this. The link below shows a sample twisted python file that runs on a monitoring machine. http://github.com/derfred/doord/blob/cd300a1cde930c07cd13d98be3e45cb89df79809/log_watcher.py ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python