[issue26819] _ProactorReadPipeTransport pause_reading()/resume_reading() broken if called before any read is perfored
New submission from Fulvio Esposito: Calling pause_reading()/resume_reading() on a _ProactorReadPipeTransport will result in an InvalidStateError('Result is not ready.') from a future if no read has been issued yet. The reason is that resume_reading() will schedule _loop_reading() a second time on the event loop. For example, currently aiomysql always fails to connect using a ProactorEventLoop on Windows because it calls pause_reading()/resume_reading() to set TCP_NODELAY on the socket just after connecting and before any read is performed. -- components: asyncio files: pause_resume_test.py messages: 263927 nosy: Fulvio Esposito, gvanrossum, haypo, yselivanov priority: normal severity: normal status: open title: _ProactorReadPipeTransport pause_reading()/resume_reading() broken if called before any read is perfored type: behavior versions: Python 3.5 Added file: http://bugs.python.org/file42559/pause_resume_test.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26819> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Request for research feedback
Hi, I am a research intern at the University of Strathclyde who has been doing a summer research internship. I hope that this is not an inappropriate place to ask, but I am looking for participants willing to use and evaluate an application that was written as part of this internship. If you choose to participate, this should only take no more than an hour or two of your time at the very most, unless you wish to not use the analysis files provided. My project is to experiment with ways of inferring and displaying socio-technical information about a software project from a version control repository by creating a prototype application. The application infers authorship information in the form of closeness scores between authors and the files they have worked on by traversing the history of a Mercurial repository. This is then displayed as a map of socio-technical dependencies between files and the authors that worked on them and between authors and the files they have worked on, which should allow for easy visual comparisons of closeness. Some potential applications and use cases I can envision in the program's current form include discovering who the key figures are (i.e. who to talk to about a problem) or what the bus factor (how many people need to be hit by a bus before a project is in trouble because there's nobody left who understands it) is for a project or a subsystem within it. Perhaps a little more depressingly, this also maybe be used to highlight potential cases of poor productivity to be investigated. The program itself, Jimmy (for lack of a better name), has a binary distribution which can be found at http://geeksoc.org/~fvalente/jimmy/jimmy_r1.zip and only requires Java 7 and Mercurial (other libraries are included), getting you started quickly. The source is available at https://bitbucket.org/fvalente/jimmy and if you wish to build it yourself, it depends on Guava r09 and JUNG 2.0.1 (api, algorithms, graph-impl, visualization) which itself depends on Apache Commons collections-generic 4.0.1. To perform a basic analysis of a project, you can open a directory that's a Mercurial repository and it will just look at the list of commits and the files that changed, adding 1 to a score each time an author touches a file, which should only take a minute or two, even for large projects. If you have more time, you can do the more expensive diff stats analysis which compares the size of each diff with the average diff size of the project, excluding empty diffs and binary changes. Unfortunately, the diff stats analysis is very slow due to retrieving each diff requiring the spawning of a hg subprocess (for reference, my 4 year old quad-core machine can do only ~10,000 commits per hour). I don't have a progress UI yet, but progress status is sent to stdout when doing a diff stats analysis. Once analysis is complete, you can save the results to review later by using the open analysis results option. To navigate the results you can switch to viewing a particular file or author of interest from the file and author lists on the left. For files, this will display that file as a node in the centre with the authors that have been involved with it as orbiting nodes, with the connecting lines' length, thickness and colour shortening, thickening and approaching red respectively as the closeness score between that author and the file increases. For authors, it is the same except the files they have worked on will be the orbiting nodes. You can also directly navigate to having a display based on an orbiting node by clicking it in the display rather than searching through the file or author lists. The display can be zoomed by using the scroll wheel and can be translated with the scroll bars or by dragging on an area not occupied by a node. What I would like is for you to please run Jimmy on one or more Mercurial repositories of your choice and to give some feedback on it. Some questions I'd particularly like answered are: * Do the closeness scores it produces match with your perception of the relationships between people and code in the project? (e.g. if you're looking at a particular file and some authors involved in it are shown as closer than others, is this the result you would have expected from a perfect version of Jimmy?) * Does the visualisation of the scores substantially improve your ability to draw conclusions from the data compared to just reading a saved analysis (which is just plaintext)? * If, hypothetically, you had no prior knowledge about the project, would using it help you to discover the key figures (e.g. maintainer, BDFL) behind the project or any of its subsystems? (Alternatively, do such people correctly show up as having touched a wider variety of files and with closer relations to them than other people?) * If you were a manager would you be able to use it to discover potential productivity issues that you would then
Re: Request for research feedback
Whoops, I thought the rather iffy Exchange web client at my institution would've wrapped outgoing messages automatically. I'm now using a proper client for that account which should prevent such issues in the future. Thanks for the heads up. For anyone who couldn't stand to read the original message, a fixed version is at http://geeksoc.org/~fvalente/jimmy/request.txt (figured it'd be rude to repost it directly in this message). On 15/09/2011 20:14, Waldek M. wrote: On Thu, 15 Sep 2011 16:55:13 +0100, Fulvio Valente wrote: Hi, I am a research intern at the University of Strathclyde who has been doing a summer research internship. I don't want to be rude, but please: could you rather first research how to use a newsreader before you use it? These long lines (a few times the limit of 78 characters per line) make your post unreadable. Thanks, Waldek -- Regards, - Fulvio -- http://mail.python.org/mailman/listinfo/python-list
Optparse buggy?
Hello, I'm on python3.2, trying some experiment with OptionParser but no success from optparse import OptionParser as parser parser.add_option('-n','--new', dest='new') Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python3.2/optparse.py, line 1001, in add_option option = self.option_class(*args, **kwargs) AttributeError: 'str' object has no attribute 'option_class' Any futher item in the option won't make any better. -- Archlinux on $(uname -a) :P -- http://mail.python.org/mailman/listinfo/python-list
Re: Optparse buggy?
Terry Reedy wrote: Do note The optparse module is deprecated and will not be developed further; development will continue with the argparse module. Then,do you propose me to opt to argparse? -- Archlinux on $(uname -a) :P F -- http://mail.python.org/mailman/listinfo/python-list
Saving emails
Hello, my curiosity these day lay around the problem given by Kmail2. I'd like to keep my old emails and a backup would satisfy my needs. The only conditions should be that the mails will come back in a quick way. I found this page http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old- mails/ Which gives me some point, but the program is too old and I'd like to use Python 3. Another chance it would be to implement an IMAP server which move old emails in and out of an archive. Then it will be simple to recall old emails. Some docs about email deciphering. Kmail uses a maildir and several subfolders. I'd like to export the emails in mbox file and perhaps to separate by a period of time, say July2010, September2010 end so forth. Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding duplicated photo
Thomas Jollans wrote: If Gwenview simply moves/renames the images, is it not enough to compare the actual files, byte by byte? For the work at the spot I found Geeqie, doing right. In the other hand learning some PIL function is one of my interest. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding duplicated photo
Kevin Zhang wrote: If anyone's interested, pleas checkout the source code in the attachment and welcome any advise. I found that isn't python 3 code :( Then the code should go into some other program to allow actions on those pictures which are matching each other. Am I right? -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding duplicated photo
Dave Angel wrote: If your real problem is identifying a renamed file amongst thousands of others, why not just compare the metadata? it'll be much faster. This was the primer situation, then to get into the dirt I tought something more sophisticated. There was a program some year's back which was brilliant an fast to find similar pictures on several thousand of them. Now I can't recall what was the program name and very interesting to do some of mine experiments. -- http://mail.python.org/mailman/listinfo/python-list
CPU management
Hello everybody, I usally develop a lot of expensive (in terms of CPU usage) algorithms. I would like to develop something that allows my application to run quietly all day long with a little CPU usage, so that I can work in the meanwhile! I was wondering if there is a way to limit the CPU usage: e.g. 10% instead of 100%, or to let the algorithm to be resumed only when the CPU usage changes. I think these kind of things are called resource management. So, are there facilities for this in Python= I'm running Python2.4 on Windows XP. Thank you for your help. Fulvio-- http://mail.python.org/mailman/listinfo/python-list
Re: question about True values
*** Your mail has been scanned by InterScan MSS. *** On Thursday 26 October 2006 02:56, John Salerno wrote: s = 'hello' s == True False if s: print 'hi' this isn't only a python behavior. the if test is valid for all non-zero variables. only None, 0 and False make the condition to jump over. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing Hidden Character in Python
*** Your mail has been scanned by InterScan MSS. *** On Thursday 26 October 2006 16:43, Wijaya Edward wrote: How can we print out the hidden character like \n, \r etc in Python? If it's meant to evidentiate then you should scan each byte an print it out i.e. o = open('yourfile'.'rb') o = open('paths.con','rb') for c in o.read(): ... if c == '\n': ... print '\\n' ... if c == '\r': ... print '\\r' ... print c, ... unfortunately it will be a space between each letter. Maybe using sys.stderr.write (c) will avoid that. F -- http://mail.python.org/mailman/listinfo/python-list
Configfile
*** Your mail has been scanned by InterScan MSS. *** HI, I've a small doubt regarding the way to save a configuration file on the file manipulated by ConfigParser. As far as I could understand this: cp = ConfigParser.ConfigParser cp.set(section,option) will it do the set on the file or do I have to issue a cp.write(fp) in order to get it done? My tests didn't resulted positively. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Tracing the execution of scripts?
*** Your mail has been scanned by InterScan MSS. *** On Friday 27 October 2006 17:31, R. Bernstein wrote: pydb (http://bashdb.sf.net/pydb) has a both the ability to trace lines I faced several time that pydb stuck without sign of errors. In the other hand Pdb doesn't appear that problem. Mostly pydb freeze on long loops. It might be some problem on my setup, I'll check it up... F -- http://mail.python.org/mailman/listinfo/python-list
Re: Handling emails
*** Your mail has been scanned by InterScan MSS. *** On Friday 27 October 2006 06:48, Ben Finney wrote: There is always the option to not send messages to this list using that mail server Once again sorry for that. I'll take action to switch to another mailserver. Thank for the advice F -- http://mail.python.org/mailman/listinfo/python-list
Re: Debugging
*** Your mail has been scanned by InterScan MSS. *** On Wednesday 25 October 2006 06:13, Bruno Desthuilliers wrote: The bp #1 should only trigger if y = 6 This give me the right point. Supposing to have a function on program's variables the statement like if myvar == True: break doesn't gives power to the BP. I definitively don't understand you. How does statements in your program relates to setting conditions on a bp in the debugger ? The online help states : |(Pdb) h b |b(reak) ([file:]lineno | function) [, condition] |With a line number argument, set a break there in the current |file. With a function name, set a break at first executable line |of that function. Without argument, list all breaks. If a second |argument is present, it is a string specifying an expression |which must evaluate to true before the breakpoint is honored. (Pdb) is the prompt, as you can see. I was thinking the condition is anything python can digest .Therefore an 'if condition: code' should be accepted. Editing a BP with a condition like that is taken as good (perhaps there's no check on its validity) Did you really bother reading the doc http://www.python.it/doc/Python-Docs/html/lib/debugger-commands.html I downloaded all directory tree :) Doesn't make difference in what is wrote on those and what is given at command line help. If my ignorance disturbing too much, feel free to ignore it any time. (No flame intention, however) I appreciate your help and these replies will make easier for somebody else when a search engine will hit this post. |(Pdb) b 17 |Breakpoint 3 at /home/user/tmp/mbxreader.py:17 |(Pdb) cl 3 |No breakpoint numbered 3 |(Pdb) h cl |cl(ear) filename:lineno |cl(ear) [bpnumber [bpnumber...]] |With a space separated list of breakpoint numbers, clear |those breakpoints. Without argument, clear all breaks Do I input wrongly? Finally I've done some test on pydb, I felt no much differences. But also the author tried to keep compatibility with Pdb/Bdb, except some more functions. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Handling emails
*** Your mail has been scanned by InterScan MSS. *** On Wednesday 25 October 2006 13:06, Dennis Lee Bieber wrote: # based upon bits from the (Active)Python 2.4 help system and other code... OK, good help, Thank you. As I had confessed, that code was extrapolated from other sources and I took it for granted as long as is working on my purpose. Most of my purpose is to get the whole mail. Last function has no use. Both code doing well the only difference is the way to call email.message_from_(file|string) F -- http://mail.python.org/mailman/listinfo/python-list
Re: Change on file
*** Your mail has been scanned by InterScan MSS. *** On Tuesday 24 October 2006 20:22, Alan Franzoni wrote: it could put the system under severe workload. Thank you for the enlightment :-) In my case it's meant to check a couple of files, but no more than 10 Mbytes. The most purpose is to find differences since last check. I suppose it's a good way, as other programs using CRC as comparison between file, better than byte-to-byte diff. Also CD images and big files download are giving a MD5 check. My point stand as platform indipendent solution and won't take extra fancy modules which aren't part of python package itself. I'll look at SVF and timestamp options. I'm less actracted by the idea of 'stat' on the file, Now I'm on linux and I've some doubt about win32 options. PS. C'e' la MList per iclp? F -- http://mail.python.org/mailman/listinfo/python-list
Re: Handling emails
*** Your mail has been scanned by InterScan MSS. *** On Tuesday 24 October 2006 03:07, Gerard Flanagan wrote: The 'PopClient' class here might help you: I got a look rather later. Let me say that is impressively pythonic :-) On the other hand I've to go deep on learning the use of Python classes, as much as the POPClient likes a different config file and will upset a big chunk of my code. Functions are good, I'll study the emails handling, only I need some time to prepair a method to discern local and remote emails and a way to save/recover the most important ones. F -- http://mail.python.org/mailman/listinfo/python-list
Change on file
*** Your mail has been scanned by InterScan MSS. *** Hello, I was thinking about use md5 check to se if a file had changes since last check. Am I correct? Is there any other light method? F -- http://mail.python.org/mailman/listinfo/python-list
Re: Handling emails
*** Your mail has been scanned by InterScan MSS. *** On Tuesday 24 October 2006 01:12, Dennis Lee Bieber wrote: Message-id: [EMAIL PROTECTED] as the ID is generally created when the message is submitted to the delivery system Well, that's what I'm dealing with, since a couple of weeks :-) indeed. Some might not have one, but Kmail should had fixed. The second will be the way to get the whole email from the mbox file. My problem still remain, partially. I'm not sure if the below procedure will give me the emails off including multipart ones. 8-8-8-8-8- #! /usr/bin/env python from __future__ import generators import email, re import mailbox import email.Message def getmbox(name): Return an mbox iterator given a file/directory/folder name. fp = open(name, rb) mbox = mailbox.PortableUnixMailbox(fp, get_message) return iter(mbox) def get_message(obj): Return an email Message object. if isinstance(obj, email.Message.Message): return obj # Create an email Message object. if hasattr(obj, read): obj = obj.read() try: msg = email.message_from_string(obj) except email.Errors.MessageParseError: obj = obj[len(headers):] msg = email.Message.Message() return msg header_break_re = re.compile(r\r?\n(\r?\n)) def extract_headers(text): Very simple-minded header extraction m = header_break_re.search(text) if m: eol = m.start(1) text = text[:eol] if ':' not in text: text = return text if __name__ == '__main__': #simple trial with local mbox file import sys try: file =sys.argv[1] except IOError: print 'Must give a mbox file program /path/to_mbox' sys.exit() k = getmbox(file) while 1: full_email = get_message(k.next()) print '%78s' %full_email answer= raw_input('More? Y/N') if answer.lower() == 'n': break 8-8-8-8-8- I admit that not all code is my genuine design, ;-) some other programs extrapolating have been done. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Handling emails
*** Your mail has been scanned by InterScan MSS. *** On Tuesday 24 October 2006 03:07, Gerard Flanagan wrote: The 'PopClient' class here might help you: Thank you, both for the replies. Gerard, Surely I'll peep on that code ;-) to gather a wider perspective. A small negative point is that for pop deals I've gotten a good success :-) But I don't give up, perhaps it there'll be some good idea. I'm more interested for the IMAP side of the issue, even I might avoid for my own purposes. Last, suppose to publish the thing where will it be the appropriate site? At the present my program can do filtering and sincronizing with local MUA trash. Small problems with IMAP protocol, but it may work for POP3 or IMAP4 on regex filter options. Alfa testers (cooperators) needed ;-) F -- http://mail.python.org/mailman/listinfo/python-list
Re: Debugging
*** Your mail has been scanned by InterScan MSS. *** On Monday 23 October 2006 19:10, Bruno Desthuilliers wrote: ignore bpnumber [count] Sorry, I ignored this command :-) timed saw nothing about this one... but perhaps with There's tbreak FYI, but what condition will trigger I haven't tried yet. condition bpnumber [condition] Condition is an expression which must evaluate to true before the breakpoint is honored. If condition is absent, any existing condition is removed; i.e., the breakpoint is made unconditional. I did some test, but whatever comes out doesn't disable the breakpoint until condition becomes true. Supposing to have a function on program's variables the statement like if myvar == True: break doesn't gives power to the BP. If I do a check on the list of BPs the condition evidently appears, but no luck :-O Also clear statement does clear only all BPs, it won't let me clear the choosen BP number. OK. I still on the learning curve, so things come slowly. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Debugging
*** Your mail has been scanned by InterScan MSS. *** On Tuesday 24 October 2006 00:59, R. Bernstein wrote: analogous the command of the same name in gdb. That's available as pdb in the same directory. I didn't try it yet. About pydb, I may say that triggered my curiosity and I'll give it a try. Should you want to somehow build such a debugger script from an interactive debugging session, set history and set logging might be helpful. Well, in my normal use (as I was used to do with trace in Arexx :-) ), I'm putting the program on hold and run it from inside pdb. I don't know procedures by use of command file set. In such mode I might seed some breakpoint at keypoint of the program and when there it stops I investigate some of the critical variable used in that point, to see if all goes as expected. F -- http://mail.python.org/mailman/listinfo/python-list
Handling emails
*** Your mail has been scanned by InterScan MSS. *** Hello, I'd like to ask some clue to move further on my project :-) The purpose would be to gather all emails (local and remote ones) to do some backup. I've tried to get ideas by reading all about the modules enclose with python, but neither email framework nor mailbox give me the idea how to handle *one* email complete of payload and attachment (if any). This purpose will give me chance to avoid duplicates and I suppose to achieve the grade of making a maildir o mbox file. It's welcome to point me to useful information. Surely I'm not asking ready-made solution :-). BTW sorry to whom feel hurt by the virus scan banner. That's not generated by me, but rather by my ISP. I'll try to contact my ISP and ask to move it off from the email body. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Debugging
*** Your mail has been scanned by InterScan MSS. *** On Saturday 21 October 2006 23:43, R. Bernstein wrote: (I think all of this is the case also with pdb, but someone might check on this; it's possible breakpoints in pdb start from 0 instead of 1 as is the case in gdb/pydb.) Thank you for your details. The pdb that I'm talking about, can be found in /usr/lib/python2.4/pdb.py (an C:\python2.4\lib\pdb.py for the win32 version). I'll give a look to pydb site... The previous post I might have missed some explaination on my proceeding. I'd say that I'm testing a small program under pdb control (python /usr/lib/python2.4/pdb.py ./myprog.py). So pdb will load myprog and stop the first line code. Once I'm at the pdb command line I can issue the commands available inside the pdb itself. Concerning the mentioned BP function I meant to set a counter/function which let the BP run until reach the true condition. Then condition is one of the pdb commands which let add a conditon to a BP. The reference Manual gives information for all the pdb functions, but aren't detailed, specially on how to set up BP conditions, like countdown, timed and camparison conditions. Hope I've been clear this time :-) F -- http://mail.python.org/mailman/listinfo/python-list
Re: The fastest search
*** Your mail has been scanned by InterScan MSS. *** On Saturday 21 October 2006 19:09, Steven D'Aprano wrote: So for searches that succeed, dicts are much faster than lists. Very precious advice. Thank you, indeed. The lesson was good :-) I'd only like to know if List.index(vars) has the same performance than vars in List or even it's the same thing. But, so far I still have my own question about that the search goes on the key's name rather then its paired value. In fact, in my actual case the value doesn't make any use. However the search goes on a few hundred email ID, the difference is less than a jiffy :-) F -- http://mail.python.org/mailman/listinfo/python-list
Re: Debugging
*** Your mail has been scanned by InterScan MSS. *** On Saturday 21 October 2006 19:40, Gregor Horvath wrote: Small snippets of code are developed in the interpreter and when they are working assembled in the editor. If something goes wrong a print on the suspect place or the traceback is all I need. (of course this is matter of taste) I also using this techinque, but I found myself to do a lot of rewriting on the code, as long as probing several points on the program. The pdb.py is much of what I need. Running the program can stop in critical points and see if all comes as expected. It won't need to remove several print from the code. Obvious, it's referred for programs which aren't time critical. F -- http://mail.python.org/mailman/listinfo/python-list
Debugging
*** Your mail has been scanned by InterScan MSS. *** Hello, I'm trying out a small utility and my method uses PDB for debugging. I tried to read some information regarding the commands of PDB but are rather synthetic. Mostly I'd like to understand the use of condition command in terms to use breakpoints (BP) with functions. Simple the first doubt was a counted BP. What variable using that BP and which function can be taken from the command line? 10x F -- http://mail.python.org/mailman/listinfo/python-list
The fastest search
*** Your mail has been scanned by InterScan MSS. *** Hello, I'm poor in knoweledge of python, sorry. What's the fastest result between : if item in alist: do_something or if adictionay has_key(item): do_something Is there some trick to apply the best search in wise use of resources while using the above said methods? F -- http://mail.python.org/mailman/listinfo/python-list
Re: Pygtk but no gtk?
*** Your mail has been scanned by InterScan MSS. *** On Saturday 21 October 2006 03:01, Jonathan Smith wrote: my pygtk provides /usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py, which contains the gtk module Great advice. I've tried : $ ls /usr/lib/python2.4/site-packages/gtk-2.0 atk.so dsextras.py dsextras.pyc dsextras.pyo gobject.so gtk pangocairo.so pango.so So, I found some problem related this, would you please post the content of that file? NOTE there's one more directory in that position and has its own __init__. F -- http://mail.python.org/mailman/listinfo/python-list
Re: help with my first use of a class
*** Your mail has been scanned by InterScan MSS. *** On Saturday 21 October 2006 02:01, James Stroud wrote: I think the trick is to identify when a class would make more sense than a collection of subroutines I do believe that's a bit of forecasting, in sense to determine whether a piece of code may have a future. Usually in hobbistic term I think we can bear with copypasting pieces of code across programs rather than go for a class(es) module. Only I remembered the mottos when I ran this,py which gives me some good points of view. F -- http://mail.python.org/mailman/listinfo/python-list
Re: a little about regex
On Wednesday 18 October 2006 23:05, Ant wrote: allow = re.compile(r'.*(?!\.com)\.my(|$)') # negative lookbehind if allow.search(adr): return True return False I'd point out that : allow = re.search(r'.*(?!\.com)\.my(|$)',adr) Will do as yours, since the call to 're' class will do the compilation as here it's doing separately. Though having the explicit allow and deny expressions may make what's going on clearer than the fairly esoteric negative lookbehind. This makes me think that your point is truly correct. The option for my case is meant as deny all except those are specified. Also may go viceversa. Therefore I should refine the way the filtering act. In fact the (temporarily) ignored score is the base of the method to be applied. Obviously here mainly we are talking about email addresses, so my intention is like the mailfilter concept, which means the program may block an entire domain but some are allowed and all from .my are allowed but not those from .com.my (mostly annoying emails :P ) At the sum of the view I've considered a flexible programming as much as I'm thinking that may be published some time to benefit for multiplatform user as python is. In such perspective I'm a bit curious to know if exist sites on the web where small program are welcomed and people like me can express all of their ignorance about the mode of using python. For such ignorance I may concour for the Nobel Price :) Also the News Group doesn't contemplate the idea to split into beginners and high level programmers (HLP). Of course the HLP are welcome to discuss on such NG :). F -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] a little about regex
On Friday 20 October 2006 02:40, Ron Adam wrote: I see, is this a cleanup script to remove the least wanted items? Yes. Probably will remain in this mode for a while. I'm not prepaired to bring out a new algorithm Or is it a bit of both? Why the score? As exposed on another post. There should be a way to define a deny/allow with some particular exception.( I.e deny all .com but not [EMAIL PROTECTED]) I would think the allow(keep?) filters would always have priority over deny filters. It's a term which discerning capacity are involved. The previous post got this point up. I think to allow all .uk (let us say) but not info.uk (all reference are purely meant as example). Therefore if applying regex denial on .info.uk surely that doesn't match only .uk. I think keeping the allow filter seperate from the deny filter is good. Agreed with you. Simply I was supposing the regex can do negative matching. You might be able to merge the header lines and run the filters across the whole header at once instead of each line. I got into this idea, which is good, I still need a bit of thinking to code it. It need to remember what will be the right separator between fields, otherwise may cause problems with different charset. Actually I've problem on issuing the command to imap server to flag Deleted the message which count as spam. I only know the message I can't help you here. Sorry. Found it :), by tryfail. BTW whose Fred? news://news.cox.net:119/[EMAIL PROTECTED] I can't link foreigner NG than my isp giving me. I'm curious and I'll give it a try. F -- http://mail.python.org/mailman/listinfo/python-list
Re: I would like write some data recovery software
*** Your mail has been scanned by InterScan MSS. *** On Friday 20 October 2006 07:29, gel wrote: Once you get a way to access the bytes to recover... the Hachoir library can be interresting as a model to map structures on these data. http://hachoir.org/ Cheers, I am having a bit of look at it now Bacula, may be interesting too. (if my infos are correct). F -- http://mail.python.org/mailman/listinfo/python-list
Re: help with my first use of a class
*** Your mail has been scanned by InterScan MSS. *** On Friday 20 October 2006 14:34, James Stroud wrote: You really don't need classes for this I'm in that matter too. Doesn't classes make the main program neater? Fundamentally OOP is the way to assemble ready objects to get a thing working, rather than worry about any single code line. Is this a concept of python? F -- http://mail.python.org/mailman/listinfo/python-list
Use I the classes?
*** Your mail has been scanned by InterScan MSS. *** Hello, I'm used to put up programs (small right now), but I could find the only way to define some functions. I'm interested to split some function into class, but I don't have know-how for these beasts. Looking for documents (free download) which clearly explain the way of programming python classes and lots of examples as a bonus. Thanks F -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] a little about regex
*** Your mail has been scanned by InterScan MSS. *** On Wednesday 18 October 2006 15:32, Ron Adam wrote: |Instead of using two separate if's, Use an if - elif and be sure to test Thank you, Ron, for the input :) I'll examine also in this mode. Meanwhile I had faced the total disaster :) of deleting all my emails from all server ;( (I've saved them locally, luckly :) ) |It's not exactly clear on what output you are seeking. If you want 0 for | not filtered and 1 for filtered, then look to Freds Hint. Actually the return code is like herein: if _filter(hdrs,allow,deny): # allow and deny are objects prepared by re.compile(pattern) _del(Num_of_Email) In short, it means unwanted to be deleted. And now the function is : def _filter(msg,al,dn): Filter try to classify a list of lines for a set of compiled patterns. a = 0 for hdrline in msg: # deny has the first priority and stop any further searching. Score 10 #times if dn.search(hdrline): return len(msg) * 10 if al.search(hdrline): return 0 a += 1 return a # it returns with a score of rejected matches or zero if none The patterns are taken from a configuration file. Those with Axx ='pattern' are allowing streams the others are Dxx to block under different criteria. Here they're : [Filters] A01 = ^From:.*\.it\b A02 = ^(To|Cc):.*frioio@ A03 = ^(To|Cc):.*the_sting@ A04 = ^(To|Cc):.*calm_me_or_die@ A05 = ^(To|Cc):.*further@ A06 = ^From:.*\.za\b D01 = ^From:.*\.co\.au\b D02 = ^Subject:.*\*\*\*SPAM\*\*\* *A bit of fake in order to get some privacy* :) I'm using configparser to fetch their value and they're are joint by : allow = re.compile('|'.join([k[1] for k in ifil if k[0] is 'a'])) deny = re.compile('|'.join([k[1] for k in ifil if k[0] is 'd'])) ifil is the input filter's section. At this point I suppose that I have realized the right thing, just I'm a bit curious to know if ithere's a better chance and realize a single regex compilation for all of the options. Basically the program will work, in term of filtering as per config and sincronizing with local $HOME/Mail/trash (configurable path). This last option will remove emails on the server for those that are in the local trash. Todo = backup local and remote emails for those filtered as good. multithread to connect all server in parallel SSL for POP3 and IMAP4 as well Actually I've problem on issuing the command to imap server to flag Deleted the message which count as spam. I only know the message details but what is the correct command is a bit obscure, for me. BTW whose Fred? F -- http://mail.python.org/mailman/listinfo/python-list
Re: a little about regex
*** Your mail has been scanned by InterScan MSS. *** On Wednesday 18 October 2006 16:43, Rob Wolfe wrote: |def filter(adr): # note that filter is a builtin function also | import re I didn't know it, but my function _is_ starting by underscore (a bit of localization :) ) | allow = re.compile(r'.*(?!\.com)\.my(|$)') # negative lookbehind | deny = re.compile(r'.*\.com\.my(|$)') Great, it works perfectly. I found my errors. I didn't use r ahead of the patterns and i was close to the 'allow' pattern but didn't give positive result and KregexEditor reported wrong way. This specially because of '' inside the stream. I thing that is not a normal regex input. It's only python valid. Am I right? More details are the previous thread. F -- http://mail.python.org/mailman/listinfo/python-list
[OT] a little about regex
*** Your mail has been scanned by InterScan MSS. *** Hello, I'm trying to get working an assertion which filter address from some domain but if it's prefixed by '.com'. Even trying to put the result in a negate test I can't get the wanted result. The tought in program term : def filter(adr): ... import re ... allow = re.compile('.*\.my(|$)') ... deny = re.compile('.*\.com\.my(|$)') ... cnt = 0 ... if deny.search(adr): cnt += 1 ... if allow.search(adr): cnt += 1 ... return cnt ... filter('[EMAIL PROTECTED]') 2 filter('[EMAIL PROTECTED]') 1 Seem that I miss some better regex implementation to avoid that both of the filters taking action. I'm thinking of lookbehind (negative or positive) option, but I think I couldn't realize it yet. I think the compilation should either allow have no '.com' before '.my' or deny should have _only_ '.com' before '.my'. Sorry I don't get the correct sintax to do it. Suggestions are welcome. F -- http://mail.python.org/mailman/listinfo/python-list
Re: stdout not flushed before os.execvp()
On Wednesday 18 October 2006 00:25, Fredrik Lundh wrote: |feature. the exec system call operates on a lower level than the |stdio buffering system. I did in this manner: for exe in ('imap4', 'pop3'): if exe in cfgfil[optsrv + '.protocol']: exe = exe[:4]; exe = 'call_func = _call_' + exe.upper() \ + '(setting)' try: exec exe except ProtocolError: call_func = '#ERROR 02 = Protocol failed with %s' %optsrv break exists it a different way to do it? F -- http://mail.python.org/mailman/listinfo/python-list
Which class?
*** Your mail has been scanned by InterScan MSS. *** Hello, Sorry, I very new in programming and the use of the classes still unknown. I'm really interested to apply the right one as far as the results aren't as expected. Here's the example: from poplib import POP3 ProtocolError = 'Error in Protocol' # handler for IMAP4 and POP3 errors try: _pop = POP3(args[0]) _pop.user(args[1]) except: raise ProtocolError a.append( 'STAT = POP Server %s reply\n %s\n' %(args[0], _pop.pass_(args[2]))) (numMsgs, totalSize) = _pop.stat() for cnt in range(1, numMsgs +1): #Need a cleanup for the envelope header 'Unix-From' try: msgs =_pop.top(cnt,0)[1] except: raise ProtocolError # Here I'd like to have some part removed and I known that some class in email # will do the neat job without missing any of the needed detail hdrs = [k for itms in ('from', 'to', 'cc', 'date', 'subject', 'reply-to', 'message-') for k in msgs if k.startswith(itms.capitalize())] # This isn't the right risult. Some time missing one of the wanted item. _pop.quit() I've put my opinions as comments, in order to copy and try. The args contains (pop address, user, and password) respectively. The list comprehension fails for some comparison, might be more accurate a regex, I just fill too complicated for a simple scan and I know that there are already good classes that will do the right way. I just miss the learning how to use them. This a part of a small program, which will attempt to organize all the emails, locals and remote in order to do spam removal and/or backup the good ones. I'd like somebody to join, not for a speedy result but for a joy of exchanging technics and tricks. F -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser: whitespace leading comment lines
*** Your mail has been scanned by InterScan MSS. *** On Friday 13 October 2006 04:13, [EMAIL PROTECTED] wrote: I'd like to propose the following change to ConfigParser.py. IMO there's a reason that left it in such way. Whom didn't like the ConfigParser classes had made a new module, and I could find a the least 4 of them (cfgparse, config, configobj, pytconfpy). I choose ConfigParser because I'm very new and I haven't learn how to implement subclasses. I also will to use ConfigParser with some more feature like sub-options, but I didn't get that clue :( If you don't like that behavior easy you can override it in a subclass and use the way you prefer. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Best IDE?
*** Your mail has been scanned by InterScan MSS. *** On Friday 13 October 2006 23:17, limodou wrote: hope you try it. If you'll manage for macro recording, playing back and from file then I'll be yours :) F -- http://mail.python.org/mailman/listinfo/python-list
Re: error handling
On Thursday 12 October 2006 04:47, Gabriel Genellina wrote: |Why not refer to the *current* documentation? Gabriel, Thank you, some time I (we) forget to look at the most obvious place ;) Meanwhile yesterday I found some useful info on the web, which an *except* statement needs a string object or class for a named exception. Now I got the meaning and sys.exc_info()[0] Bernard's idea is useful to fish out more clues. F -- http://mail.python.org/mailman/listinfo/python-list
[Newbie] error handling
*** Your mail has been scanned by InterScan MSS. *** Hello there, Simple question : how do I manage errors by the use try/except clause. Example: If I'd like to catch error coming from a function call that's using IMAP4 class, which error may raise such class? In other words I've doubts about which error object I should put after the except statement in order to trap the wanted error. Is there, somehow, the way to list the errors from a class or function, prior digging into the source? F -- http://mail.python.org/mailman/listinfo/python-list
sign in
*** Your mail has been scanned by InterScan MSS. *** confirm 48f0beb37c698f0bb7b4c0327cf30dbd7a4b6335 -- http://mail.python.org/mailman/listinfo/python-list
Re: stripping blanks
Alle 17:06, martedì 02 maggio 2006, seeker ha scritto: printLine = line.rstrip(\n) I think that nobody considered if the text has (\r) or (\r\n) or (\n) at the end of the line(s). -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Leo 4.4 rc1 released
Alle 19:15, sabato 29 aprile 2006, Fredrik Lundh ha scritto: emacs I didn't like Emacs since the glory day of Amiga. Also vim look pretty rough for my tastes. I fill more confortable in Kate, but I don't deny any furter trial. May I'm gonna reconsidering Emacs :) F -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Leo 4.4 rc1 released
Alle 22:58, venerdì 28 aprile 2006, Edward K. Ream ha scritto: Many new commands, including Small question. Has it way of using macro or programmable input? I mean this because for linux there arent many text editors with macro (recording/playing back) nor any with script commands. Thank you. If Leo lack of this, would be appreciated to give some idea to get involved on making it running python code. F -- http://mail.python.org/mailman/listinfo/python-list
A fix to bluepin
Hello List, I'm very beginner on programming, I''m studing some fix on the Bluez's bluepin, which is rather vague to control the given input. Code /start: = def main(*args): if len(sys.argv) 2: print ERR sys.exit() dir= sys.argv[1] bdaddr = sys.argv[2] if len(sys.argv) 3: name = sys.argv[3] else: name = title = Bluetooth PIN Code # Bluetooth spec recommends automatic strong random PIN generation. # So eventually we should implement that. pin = { PIN: } if dir == out: mesg = Outgoing connection to else: mesg = Incoming connection from mesg = mesg + name + [ + bdaddr + ] if dialog(title, mesg, pin) == DLG_OK: pin[PIN] = string.strip(pin[PIN]) for i in pin: if i not in digits: print ERR break if len(pin[PIN]) = 1 and len(pin[PIN]) = 16: print PIN: + pin[PIN] else: print ERR else: print ERR # main() = Code /end: Assumed that digits is: from string import digits (equal to 1234567890) (Perhaps I could avoid such import ad assigned directly :-) ) Assumed that the purpose would be to don't print ERR but to return back to main. Therefore may I recursively call main() ? Does it re-open a new window, if I do so? Does it re-ask new args? Thanks for the patience to give some input here PS. sorry the code is in tabs not in space :-( F -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE for linux
Alle 09:43, giovedì 20 aprile 2006, Neil Isaac ha scritto: At this point I'm thinking that I would like to start using a real IDE. Idle, shipped with Python :-) F -- http://mail.python.org/mailman/listinfo/python-list
Re: Translate Cpp into python code
Alle 21:36, lunedì 17 aprile 2006, Ravi Teja ha scritto: If you are looking for ways to access C++ code in Python, there are several (Boost, SIP, CXX, SWIG, Weave etc). This way I knew about it. People usually convert higher level languages to lower level languages for performance Frankly I'm not looking for performances, but a viable python script which won't be tied up to a single platform. Those parts of the code which are calling proprietary functions will be removed. Probably the first step to make a port on a multiplatform concept. Another point will be a better chance to learn programming once I got the translation. F -- http://mail.python.org/mailman/listinfo/python-list
Translate Cpp into python code
Hi there, I'd like to ask if is there any tool that's able to parse C++ code and convert it into Python script? Probalby entirely would be difficult, but a good percentage I think it would be possible and the remain asking to the user what to do. F -- http://mail.python.org/mailman/listinfo/python-list
Re: List operation: Removing an item
On Sunday 16 April 2006 13:37, Terry Reedy wrote: Do you really need the items sorted? Do you really think he isn't a troll? See the latest thread on lists end related PEP. However there's always some good info on your reply (all of those had reply to OP). F -- http://mail.python.org/mailman/listinfo/python-list
Re: ftp connection and commands (directroy size, etc)
Alle 00:05, giovedì 13 aprile 2006, Arne ha scritto: a=ftp.sendcmd('Dir') By trying to get the directory with 'dir' Are you sure that the command 'dir is understood via ftp? IF I'm not wrong would be 'ls' o list. But since I don't have such psckage on my system, it's recommended you read the manual of that or read here: http://www.cs.colostate.edu/helpdocs/ftp.html Which is the result of google search of ftp command list (no quote). F -- http://mail.python.org/mailman/listinfo/python-list
Re: Figure out month number from month abbrievation
Alle 04:41, giovedì 13 aprile 2006, Fredrik Lundh ha scritto: but it also looks as if the meaning of the word localized isn't clear to you; if you changed the locale, those names will be translated Mine behave strangely. Linux localized for Italian, but Python (or its calander is in english) ?? F -- http://mail.python.org/mailman/listinfo/python-list
Re: Figure out month number from month abbrievation
Alle 20:16, giovedì 13 aprile 2006, Fredrik Lundh ha scritto: locale.setlocale(locale.LC_ALL, it_IT) 'it_IT' Thank you Great kind explanation F -- http://mail.python.org/mailman/listinfo/python-list
Re: I meet problems while using the py2exe,Please help me!
Alle 10:17, mercoledì 12 aprile 2006, boyeestudio ha scritto: What is wrong with this problem makes sense talking about the path on where cairo reside? F -- http://mail.python.org/mailman/listinfo/python-list
Re: the mysql for python cann't be install from the source! Help!!
Alle 22:24, martedì 11 aprile 2006, boyeestudio ha scritto: I search the mysql directory but gain none of it! In the version MySQL-python-1.2.0 there isn't such file. Better you re-read README file inside the tarball or zip file. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Curses and Character Handling
Alle 10:46, domenica 09 aprile 2006, [EMAIL PROTECTED] ha scritto: Does anyone know of a solution to this I still learning python, but probably some documentation is the basis of learning, rather than ask at the list. I suggest to see at http://docs.python.org/ for actual and growing python functions and/or builtins. F -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the text under the cusor ?
Alle 00:20, sabato 08 aprile 2006, Bo Yang ha scritto: I want to develop an application to record some of the best words and ideas On linux and KDE desktop is easy as a breathing, by Klipper applet:-) And also no virus prone like windowz. Pls no flame, just a consideration. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Splitting a string with extra parameters
Alle 11:23, giovedì 06 aprile 2006, Chris P ha scritto: when splitting based on a delimiter of , the above string gets broken up in 5 columns instead of 4 due to the , in the money amount. There should be cvs package in the python directory. Why don't you try that way? Reading some help gives more details of its use. F -- http://mail.python.org/mailman/listinfo/python-list
Re: how to convert string
Alle 08:51, giovedì 06 aprile 2006, [EMAIL PROTECTED] ha scritto: for x in range(10): sys.stdout.write(x) sys.stdout.write( ) BTW, how to write a number repeatly in the same line and position, without let the printout to scroll down. F -- http://mail.python.org/mailman/listinfo/python-list
Re: how to convert string
Alle 18:21, giovedì 06 aprile 2006, Fredrik Lundh ha scritto: will work, as long as the message isn't too long I was trying some print\b\b\b\b, i, For a number of 4 digit, but I think I miscalculated some lenght variation. The reason of this is because it won't leave previous printing. But I also got some wrong positioning :-) F -- http://mail.python.org/mailman/listinfo/python-list
Re: how to create file with spaces
Alle 18:18, giovedì 06 aprile 2006, [EMAIL PROTECTED] ha scritto: How can i deal with spaces in this case? I don't have an idea with python, but if can help I may say that bash you might use \ to escape a space or use a quoted full path. The shell program basename is failing, anyhow with file names containing spaces. F -- http://mail.python.org/mailman/listinfo/python-list
Re: detecting drives for windows and linux
Alle 03:17, domenica 26 marzo 2006, BWill ha scritto: Hi, I'm writing a file browser, but I'm not sure how I could go about detecting the drives available I was just asking a similar question some days back. I'm planning to try a file catalogger. I just remember something about Win32API, but I didn't find anything on the linux side. Frankly I got some curious info that concerns 'Bacula', disk backup. And a part of it is use to browse and catalog file. I think we should read some line of code on that program. F -- http://mail.python.org/mailman/listinfo/python-list
Re: Some info
Alle 22:14, mercoledì 22 marzo 2006, Sybren Stuvel ha scritto: different partitions might have, though. Then again, it all depends on the filesystems in use. Then I should make some extra programming to catch these info, according to which OS will run it :-( Regarding the names, CDROMs DVD have a label, which might be written during the burning process. Also partition have name, which can be written by fdisk, or in MS windows properties. Just a comparison : Imaging something like WhereIsIt (Windows) Gwhere (Linux), but in my opinion I'd like to give it free and less weak (as the before-mentioned programs). F -- http://mail.python.org/mailman/listinfo/python-list
Some info
Hello, I'm very new of Python programming. I just wrote some hundred lines of a programm. Now, I'd like to go some step farther and make a disk cataloger. There are plenty for win, but few for linux. So, I'd like to write one which is for win and linux. I'm, actually, a bit stuck on how to collect informations regarding disk names (CDroms or USB HDs). The matter is rather difficult if is suppose to make the programm running for linux as much as it would do for MSW. Suggestions are very welcome. Fulvio -- http://mail.python.org/mailman/listinfo/python-list
Re: Some info
Alle 21:22, mercoledì 22 marzo 2006, Sybren Stuvel ha scritto: disk names (CDroms or USB HDs). Depends on what names you want. It seems clear that was _disk_ names. If isn't to much would be also useful to know the serial number, so will avoid to record a disk twice. On Win, we can call Win32API, but this won't work for linux :-( It's my opinion that python should read some partition table or disk header to find these informations. For the remaining information will suffice a os.walk(path). OK I'm not 100% sure what's that function, but I remember that there's for win and lin. Later I'll go deeper for info according the MIME file type. Fulvio -- http://mail.python.org/mailman/listinfo/python-list