Re: Introduction to Threading with Python, a podcast
I very much enjoyed this one! Good stuff. Ron, it would help to have the code from your guest podcasts on your site. Thanks for your help in promoting python. [EMAIL PROTECTED] wrote: > Chris Hefele has done an excellent talk about programming with threads > using Python, including a fair amount of detail and a look at various > related tools and topics. Chris did a lot of research and put a lot of > effort into producing this podcast. I find it to be a particularly > clear and lucid explanation of the basic principles of programming with > threads. > > This is a far better-than-normal piece of work, so I feel it is worth > mentioning here so that interested people can check it out, Go to > www.awaretek.com/python/index.html and just click on the top podcast in > the list of podcasts there. > > Ron Stephens -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a decent HTML parser for Python...
Agreed that the web sites are probably broken. Try running the HTML though HTMLTidy (http://tidy.sourceforge.net/). Doing that has allowed me to parse where I had problem such as yours. I have also had luck with BeautifulSoup, which also includes a tidy function in it. Just Another Victim of the Ambient Morality wrote: > "Just Another Victim of the Ambient Morality" <[EMAIL PROTECTED]> wrote > in message news:[EMAIL PROTECTED] > > > >Okay, I think I found what I'm looking for in HTMLParser in the > > HTMLParser module. > > Except it appears to be buggy or, at least, not very robust. There are > websites for which it falsely terminates early in the parsing. I have a > sneaking feeling the sgml parser will be more robust, if only it had that > one feature I am looking for. > Can someone help me out here? > Thank you... -- http://mail.python.org/mailman/listinfo/python-list
popen on windows
I am trying to set off commands on Windows 2003 from python. Specifically, I am trying to use diskpart with a script file (pointed to with path). cmd = ["diskpart", "/s", path] p = Popen(cmd, shell=True) The script is meant to loop through twice. It will do so if I comment out the Popen call and print cmd instead. But when Popen is called, one disk will be formated, but not the next. -- http://mail.python.org/mailman/listinfo/python-list
Re: popen on windows
Thanks for your reply. I figured it out. I was not closing the file that path pointed to before executing the command. D'oh! So sometimes it read the file that was created on the previous test run ... Anyway, for the benefit of anyone who might be googling for a similar question, what seems to work for running a command in Windows and having it wait for the command to finish was (after closing the file before I refer to it) was: (this is python 2.4.3. I think subprocess was new in 2.4. See documentation for subprocess module) from subprocess import Popen r = Popen(string_with_the_command, shell=True) r.wait() Sometimes the hardest part of python is to resist the urge to imagine that things *must* be complicated and therefore the simpliest possible solution can't possibly work ... Daniel Klein wrote: > On 27 Dec 2006 09:16:53 -0800, "hubritic" <[EMAIL PROTECTED]> > wrote: > > >I am trying to set off commands on Windows 2003 from python. > >Specifically, I am trying to use diskpart with a script file (pointed > >to with path). > > > >cmd = ["diskpart", "/s", path] > >p = Popen(cmd, shell=True) > > > >The script is meant to loop through twice. It will do so if I comment > >out the Popen call and print cmd instead. But when Popen is called, one > >disk will be formated, but not the next. > > What is the value of 'path' ? > > Does the command work from a Windows command prompt ? > > Dan -- http://mail.python.org/mailman/listinfo/python-list
pyparsing question
I am trying to parse data that looks like this: IDENTIFIERTIMESTAMP T C RESOURCE_NAME DESCRIPTION 2BFA76F6 1208230607 T S SYSPROCSYSTEM SHUTDOWN BY USER A6D1BD62 1215230807 I HFirmware Event My problem is that sometimes there is a RESOURCE_NAME and sometimes not, so I wind up with "Firmware" as my RESOURCE_NAME and "Event" as my DESCRIPTION. The formating seems to use a set number of spaces. I have tried making RESOURCE_NAME an Optional(Word(alphanums))) and Description OneOrMore(Word(alphas) + LineEnd(). So the question is, how can I avoid having the first word of Description sucked into RESOURCE_NAME when that field should be blank? The data I have has a fixed number of characters per field, so I could split it up that way, but wouldn't that defeat the purpose of using a parser? I am determined to become proficient with pyparsing so I am using it even when it could be considered overkill; thus, it has gone past mere utility now, this is a matter of principle! thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: pyparsing question
On Jan 1, 4:18 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 2, 10:32 am, hubritic <[EMAIL PROTECTED]> wrote: > > > The data I have has a fixed number of characters per field, so I could > > split it up that way, but wouldn't that defeat the purpose of using a > > parser? > > The purpose of a parser is to parse. Data in fixed columns does not > need parsing. > > > I am determined to become proficient with pyparsing so I am > > using it even when it could be considered overkill; thus, it has gone > > past mere utility now, this is a matter of principle! > > An extremely misguided "principle". Would you use an AK47 on the > flies around your barbecue? A better principle is to choose the best > tool for the job. Your principle is no doubt the saner one for the real world, but your example of AK47 is a bit off. We generally know enough about an AK47 to know that it is not something to kill flies with. Consider, though, if someone unfamiliar with the concept of guns and mayhem got an AK47 for xmas and was only told that it was really good for killing things. He would try it out and would discover that indeed it kills all sorts of things. So he might try killing flies. Then he would discover the limitations; those already familiar with guns would wonder why he would waste his time. -- http://mail.python.org/mailman/listinfo/python-list
Who is your daddy: Can I find what object instantiates another object?
I want to build a parser object that handles two different log file formats. I have an object that handles Connection logs and an object for Filter logs. Each will instantiate a Parser object, passing in the path to individual log files. There are a number of ways I could figure out whether I am dealing with connection or filter log. I could pass it in when creating the Parser, but that doesn't seem very pythonic. I could figure out the type of log file a particular instance of the Parser is working with by looking at the format of the file. This wouldn't be hard but it seems unnecessary. It would be jiffy if I could find what kind of object instantiated that particular parser. So if a FilterLog object instantiated it, the parser would know to parse a Filter log. Can the Parser object know who its Daddy is? Thanks -- http://mail.python.org/mailman/listinfo/python-list
pyparsing question: single word values with a double quoted string every once in a while
I want to parse a log that has entries like this:
[2009-03-17 07:28:05.545476 -0500] rprt s=d2bpr80d6 m=2 mod=mail
cmd=msg module=access rule=x_dynamic_ip action=discard attachments=0
rcpts=1
routes=DL_UK_ALL,NOT_DL_UK_ALL,default_inbound,firewallsafe,mail01_mail02,spfsafe
size=4363 guid=291f0f108fd3a6e73a11f96f4fb9e4cd hdr_mid=
qid=n2HCS4ks025832 subject="I want to interview you" duration=0.236
elapsed=0.280
the keywords will not always be the same. Also differing log levels
will provide a different mix of keywords.
This is good enough to get the majority of cases where there is a
keyword, a "=" and then a value with no spaces:
Group(Word(alphas + "+_-.").setResultsName("keyword") + Suppress
(Literal ("=")) + Optional(Word(printables)))
Sometimes there is a subject, which is a quoted string. That is easy
enough to get with this:
dblQuotedString(ZeroOrMore(Word(printables) ) )
My problem is combining them into one expression. Either I wind up
with just the subject or I wind up with they keywords and their
values, one of which is:
subject, '"I'
which is clearly not what I want.
Do I scan each line twice, first looking for quotes ?
Thanks
--
http://mail.python.org/mailman/listinfo/python-list
