Re: [Twisted-Python] Twisted as a House for Sale
On Aug 27, 2013, at 4:40 PM, Matt Haggard wrote: > Up to six articles now: http://iffy.github.io/twistedftw/ This now says "#{{ index+1 }} With Twisted you can {{ showing.ability }}" for me. -glyph ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Encouraging New Reviewers (was: Re: something about Github, as all threads about fostering community now start on that subject)
On Aug 27, 2013, at 2:44 AM, Laurens Van Houtven <_...@lvh.io> wrote: > On Tue, Aug 27, 2013 at 6:07 AM, Glyph wrote: > I think that's a fine rule, but it has one gigantic problem: we don't have a > list of committers anywhere. Making this list - and, critically, associating > VCS handle (svn.twistedmatrix.com login) with Trac handle, for those cases > where it differs - would really help new contributors figure out whether > there's > > You got cut off here. ... whether there's a ticket they can review or not. > I feel like if someone could hack up a Trac report, or an extension to the > high scores page, that addressed the first point, it would be a lot easier to > deal with the second and third ones. So, if anyone reading this would like > to do that, I would be forever in your debt. > > What would be the extension to the score board? A list of committers. Perhaps a badge next to someone's name in the score list indicating whether they're a committer. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Advice on porting Python application to Twisted
(Reply to Matt Haggard) Matt - I was getting the emails delivered in digest form, so I am having to reply to my original email instead of to your reply. I have added your email directly to make sure you get it. > I am not familiar with how you communicate with hardware on a > Raspberry PI. Can you link to your existing code? In my brief > reading this morning, I'm guessing you might be using the RPi.GPIO > library? If so, I'm looking at > https://code.google.com/p/raspberry-gpio-python/wiki/Inputs which > indicates that wait_for_edge() or event_detected() might be useful > (instead of a "continuously called a 'timeTick' event"). But I'm not > sure what thread the callbacks to those functions are called in. > I've also come across > https://www.kernel.org/doc/Documentation/gpio.txt which makes me think > it would be possible to register the GPIO events with the Twisted > reactor (but I've never done that and don't have a Pi to test with). I wrote a small Python wrapper over the user-space GPIO driver. This uses some special files under /sys/class/gpio. It is possible to configure a GPIO input to be interrupt driven, and then using select() or poll() get an asynchronous event when the configured condition occurs. I tested this out manually from the Python console, however, my little wrapper class doesn't support it currently. The other issue is that the simplest way to do button debounce is to just poll the button once it's pressed and make sure it stays pressed before some time before treating it as a "button pressed" event. In my case, I also monitor the button to see if it is held down for two seconds, as I treat that as an indicator to trigger the machine to dispense the cat food. I suspect all that behavior could be duplicated in a Twisted-friendly way, but I am not sure how to do that. > Perhaps it's time to buy one. They are a lot of fun for $35-$40. >> 3) A thread that runs continuously capturing images from a webcam. This >> ...(snip) > Someone with more intelligence than me should answer this, but here's > my attempt: > You can do this without threads since you're just spawning processes > for the image captures. I'm assuming you only want to capture as many > low res images as you can process. Here's one way to do it: > from twisted.internet import reactor, task, defer > (snip) Thanks, I see the docs on spawning processes now that your example pointed out their existance. I think I can also emulate the behavior of my polling loop by using the scheduled callback feature. I will play around with it a bit and check back if I can't figure it out. Thanks much for your reply. On Mon, Aug 26, 2013 at 8:06 PM, Matthew Humphrey wrote: > I recently created a small automated, remote (via web) controlled pet > feeder using a Raspberry Pi single-board computer. The software is all in > Python, and uses the simple HTTP server that is part of the Python > libraries. I discovered Twisted about 2/3 of the way through the project, > and now that I am done I would like to port it to use Twisted. After > reading much of the documentation the Twisted web site, some aspects of > this are fairly obvious to me, while others are not. I could use some > advice on how best to design my app to fit in with the Twisted framework. > > Here are the major components of the application: > > 1) A web site that hosts a combination of static content and some REST > APIs. REST apis are called from Javascript Ajax, and do things like > enable/disable the webcam, dispense a treat, etc. The static content > consists of a single HTML page, some javascript scripts, and a JPG that is > captured by #3 below. > > 2) A thread that runs a loop which manages the hardware. It does this with > a simple state machine composed of a base class and subclasses for all the > states that the hardware can be in (starting, idle, displaying status on > the lcd, dispensing a treat, recovering from treat dispense cycle, shutting > down). After initializing the hardware and the initial state, the thread > loops continuously calling a "timeTick" event to the current state. WIthin > the states, the code looks at various hardware status (like whether a > button is pressed) and decides to take action or to trigger transition to > another state. > > 3) A thread that runs continuously capturing images from a webcam. This > thread captures low resolution images continuously, and compares sucessive > frames to see if there is significant number of different pixels (motion > detect). If so, it captures a higher resolution image, updates a symbolic > link to point to the most recent image captured, and deletes any excessive > files from previous captures. The images captured for the motion detect are > handled by executing a process and capturing the stdout. The higher res > images captured by executing a process that writes directly to a file. > > Porting #1 is very straightforward after going through the tutorial on > Twisted web. However, I am n
[Twisted-Python] The tcp connection can't stop
I'm want to get the information of 25(smtp) port in the target ip ,so i write the script smtp.py,and the mx.short.txt is the target ip list.You can run the script like this :python smtp.py(the smtp.py and mx.short.txt are in the same directory).Then I find this script is can't stop. Can you help me solution this problem?It's had troubled me about one month.Grateful! 203.188.197.111 220.181.14.132 220.181.14.131 220.181.14.133 220.181.14.134 163.177.65.211 123.125.50.139 123.125.50.140 61.135.181.94 211.150.64.49 211.150.74.49 220.181.26.202 61.135.132.100 220.181.14.136 220.181.14.137 123.125.50.119 123.125.50.118 220.181.14.140 220.181.14.141 220.181.14.142 220.181.14.139 220.181.14.135 220.181.14.143 220.181.14.138 220.181.14.163 220.181.14.148 220.181.14.162 220.181.14.156 220.181.14.159 220.181.14.164 220.181.14.161 202.108.3.190 220.181.14.144 61.135.132.112 220.181.14.158 220.181.14.160 220.181.14.157 183.60.62.12 220.181.14.147 220.181.14.146 220.181.14.155 220.181.14.150 220.181.14.149 60.28.2.175 220.181.14.154 220.181.14.145 211.150.72.49 112.90.137.120 58.250.132.64 183.60.61.225 112.95.241.138 42.121.103.105 119.147.192.101 59.36.102.50 59.36.102.51 113.108.18.210 113.108.64.240 119.147.6.81 202.108.35.225 183.62.125.200 113.108.77.23 119.147.192.199 183.62.125.223 183.62.125.199 202.123.98.10 112.90.142.55 74.125.133.26 74.125.133.27 42.121.103.108 203.209.250.146 192.168.95.236 121.14.53.136 202.108.3.153 123.125.50.213 211.150.64.59 139.175.54.239 123.125.50.214 123.125.50.217 202.108.255.210 42.121.103.104 74.125.134.26 74.125.134.27 112.95.241.32 211.150.64.209 10.54.5.184 121.14.6.203 10.54.5.212 202.108.5.185 10.54.5.211 221.176.9.178 113.108.225.10 121.14.129.73 113.108.225.9 173.194.79.26 121.14.129.75 74.125.25.26 10.54.5.213 61.135.129.15 74.125.129.26 61.135.132.71 173.194.74.27 173.194.74.26 159.226.251.12 173.194.79.27 74.125.129.27 74.125.25.27 173.194.73.26 10.54.5.172 60.28.2.248 10.54.5.171 10.54.5.173 220.181.97.145 173.194.73.27 10.54.5.186 10.54.5.174 10.54.5.185 123.125.50.132 123.125.50.135 123.125.50.138 220.181.97.147 220.181.97.146 123.125.50.134 123.125.50.133 113.108.212.78 121.14.26.25 220.181.26.195 61.145.121.80 61.145.121.82 60.28.2.177 61.145.121.60 202.142.16.131 123.125.50.110 123.125.50.111 123.125.50.112 219.142.78.189 123.58.178.224 202.108.3.154 123.58.178.225 61.135.132.99 123.58.178.226 61.50.161.42 61.50.161.36 202.96.74.67 61.152.74.37 61.135.132.86 121.14.53.133 121.14.7.203 123.58.177.169 123.58.177.168 211.150.74.59 123.58.177.170 218.1.66.97 74.125.141.27 74.125.141.26 60.191.88.145 64.71.138.90 218.30.115.106 123.125.51.77 64.71.138.53 123.58.178.52 123.125.51.76 65.55.37.88 209.181.247.105 65.55.37.104 123.58.178.203 220.181.26.14 123.58.178.60 123.58.178.204 123.58.178.105 202.108.3.193 65.55.37.72 65.55.37.120 65.54.188.94 58.250.132.68 65.54.188.72 65.55.92.184 65.54.188.110 61.135.158.109 65.55.92.168 65.55.92.136 123.58.178.51 65.55.92.152 65.54.188.126 61.135.132.154 61.136.58.184
Re: [Twisted-Python] Twisted as a House for Sale
Senthil, Thanks! I don't think I realized Dave Peticola was the author of the krondo series. His series is great for learning how Twisted (and asynchronous programming) works, but I've had mixed reviews from newbies I've sent there -- mostly because they didn't know why they would want to use Twisted. They lacked the motivation to actually go through the series. With TwistedFTW I hope to get them excited enough that when they're sent to his series they'll devour it. Up to six articles now: http://iffy.github.io/twistedftw/ Matt On Fri, Aug 23, 2013 at 8:10 PM, Senthil Kumaran wrote: > Hi Matt, > > On Fri, Aug 23, 2013 at 3:31 PM, Matt Haggard wrote: >> >> Thanks for positive response, everyone! >> >> There are now two legitimate articles (yeah, they're small) >> iffy.github.io/twistedftw > > > This is great. It will be appealing to new audience, who value UI design > highly. > > I hope you have come across Dave Peticola's twisted introduction. With those > docs, I think, this "house for sale" story could have been a "disneyland > trip". > :-) > > -- > Senthil > > ___ > 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] Advice on porting Python application to Twisted
On Mon, Aug 26, 2013 at 9:06 PM, Matthew Humphrey wrote: > 2) A thread that runs a loop which manages the hardware. It does this with a > simple state machine composed of a base class and subclasses for all the > states that the hardware can be in (starting, idle, displaying status on the > lcd, dispensing a treat, recovering from treat dispense cycle, shutting > down). After initializing the hardware and the initial state, the thread > loops continuously calling a "timeTick" event to the current state. WIthin > the states, the code looks at various hardware status (like whether a button > is pressed) and decides to take action or to trigger transition to another > state. I am not familiar with how you communicate with hardware on a Raspberry PI. Can you link to your existing code? In my brief reading this morning, I'm guessing you might be using the RPi.GPIO library? If so, I'm looking at https://code.google.com/p/raspberry-gpio-python/wiki/Inputs which indicates that wait_for_edge() or event_detected() might be useful (instead of a "continuously called a 'timeTick' event"). But I'm not sure what thread the callbacks to those functions are called in. I've also come across https://www.kernel.org/doc/Documentation/gpio.txt which makes me think it would be possible to register the GPIO events with the Twisted reactor (but I've never done that and don't have a Pi to test with). Perhaps it's time to buy one. > 3) A thread that runs continuously capturing images from a webcam. This > thread captures low resolution images continuously, and compares sucessive > frames to see if there is significant number of different pixels (motion > detect). If so, it captures a higher resolution image, updates a symbolic > link to point to the most recent image captured, and deletes any excessive > files from previous captures. The images captured for the motion detect are > handled by executing a process and capturing the stdout. The higher res > images captured by executing a process that writes directly to a file. Someone with more intelligence than me should answer this, but here's my attempt: You can do this without threads since you're just spawning processes for the image captures. I'm assuming you only want to capture as many low res images as you can process. Here's one way to do it: from twisted.internet import reactor, task, defer from twisted.internet.utils import getProcessOutput from twisted.python import log from twisted.python.filepath import FilePath class ImageCapturer: lowres_args = ('/path/to/lowres_args',) highres_args = ('/path/to/highres_args', ['/path/to/outpufile']) def __init__(self): self._last_image = None def getLowResImage(self): return getProcessOutput(*self.lowres_args) def getHighResImage(self): log.msg('getting high res image') d = getProcessOutput(*self.highres_args) d.addCallback(log.msg) return d def start(self): self.doCycle() def doCycle(self): d = self.getLowResImage() d.addCallback(self.processLowResImage) d.addCallback(self.finishCycle) return d def finishCycle(self, _ignored): self.doCycle() def processLowResImage(self, image): if self._last_image: if self.isDifferentEnough(self._last_image, image): # if it's bad for the lowres script and the highres script # to run at the same time, you may want to wait for the high # res script to finish (this code doesn't do that). self.getHighResImage() self._last_image = image def isDifferentEnough(self, image1, image2): """ Compare the two images for differences. Return True if it warrents a high res capture. If this is a long-running function, you could send it off to a thread with deferToThread. """ return image1 != image2 def example(reactor): # for example capturer = ImageCapturer() # since I don't have an image capture script, I'll just list a directory. # low res directory capture :) capturer.lowres_args = ('/bin/ls', ['/tmp/']) # high res directory capture :) capturer.highres_args = ('/bin/ls', ['-al', '/tmp/']) capturer.start() # add and remove a file tmpfile = FilePath('/tmp/foo') reactor.callLater(1, tmpfile.setContent, 'foo') reactor.callLater(2, tmpfile.remove) return task.deferLater(reactor, 10, lambda:None) if __name__ == '__main__': import sys log.startLogging(sys.stdout) task.react(example) ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Interesting plot on new author contributions post-Github for several Python packages
On Tue, Aug 27, 2013 at 2:14 PM, wrote: > On 09:54 am, _...@lvh.io wrote: > >> IIUC, Tom does most of his contributing through Github. That probably >> means >> that it's a well-supported process that has most of the kinks ironed out: >> after all, if Tom hasn't caught them, I would guess a new contributor >> probably wouldn't either :-) >> > > Or it means Tom's workflow is fine and he's learned all the issues he > needs to avoid tripping over. > That sounds like what I mean. I don't understand the difference. I am saying that Tom's workflow is fine and knows where the hard parts are. Also, given the amount of time that he (usually) gets to spend on Twisted and his responsiveness on the IRC channel, I think it counts as "well-supported". > You didn't quote anything in the message you replied to, so I'll just > guess that this is an email meant as a "+1 please switch to github". Please > correct that impression if it is mistaken. > No. I am suggesting that there is a way to contribute using Github that isn't totally broken, and someone has already figured out what that way is, and that someone is in a position to explain it to others. I'm saying we don't need to switch to github, because apparently you can already use github if you want to, everything else staying the same. It's possible that this way of using github does not please the would-be new reviewers sufficiently, but I'm saying that if someone suggests we move to github, I'd like to make it clear to them that you can already use github, and that they should probably at least formulate their arguments in the shape of "the current way that I can use github is bad because ..." :) Thanks, > Jean-Paul cheers lvh ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Interesting plot on new author contributions post-Github for several Python packages
On 09:54 am, _...@lvh.io wrote: IIUC, Tom does most of his contributing through Github. That probably means that it's a well-supported process that has most of the kinks ironed out: after all, if Tom hasn't caught them, I would guess a new contributor probably wouldn't either :-) Or it means Tom's workflow is fine and he's learned all the issues he needs to avoid tripping over. You didn't quote anything in the message you replied to, so I'll just guess that this is an email meant as a "+1 please switch to github". Please correct that impression if it is mistaken. If it is not mistaken, then please let this sub-thread of the discussion die right here (reasons for doing so already given in near countless previous threads). The ideas suggested elsewhere for encouraging more reviewers and other contributions seem more likely to bear fruit. Let's follow through on those. Thanks, Jean-Paul ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Interesting plot on new author contributions post-Github for several Python packages
IIUC, Tom does most of his contributing through Github. That probably means that it's a well-supported process that has most of the kinks ironed out: after all, if Tom hasn't caught them, I would guess a new contributor probably wouldn't either :-) cheers lvh ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] Encouraging New Reviewers (was: Re: something about Github, as all threads about fostering community now start on that subject)
On Tue, Aug 27, 2013 at 6:07 AM, Glyph wrote: > I think that's a fine rule, but it has one gigantic problem: we don't have > a list of committers anywhere. Making this list - and, critically, > associating VCS handle (svn.twistedmatrix.com login) with Trac handle, > for those cases where it differs - would really help new contributors > figure out whether there's > You got cut off here. > I feel like if someone could hack up a Trac report, or an extension to the > high scores page, that addressed the first point, it would be a lot easier > to deal with the second and third ones. So, if anyone reading this would > like to do that, I would be forever in your debt. > What would be the extension to the score board? lvh ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python