Re: python win32 and COM? for internet monitoring

2005-11-22 Thread Matthew Thorley
Graham Fawcett wrote: > You might want to look into PCAP (a.k.a libpcap), which is the > network-sniffing libary used by Ethereal, among other programs. Much > more portable than COM, and there are Python wrappers for it, IIRC. > > You could also implement an HTTP proxy server in Python; Google s

python win32 and COM? for internet monitoring

2005-11-22 Thread Matthew Thorley
Greetings, I have a question I hope some one with more back ground can give me a little help with. I want to write a simple internet monitoring script for windows that watches out bound http traffic and keeps a list of all the site visited. I am thinking that I might be able to use pywin32 and

Re: formatted xml output from ElementTree inconsistency

2005-06-23 Thread Matthew Thorley
Jarek Zgoda wrote: > Matthew Thorley napisaƂ(a): > >> The output I get shows xmla as nicely formatted text, with elements on >> different lines and everything all tabbed and pretty. Inverly, xmlb is >> one long string on one line. >> >> Is that because

formatted xml output from ElementTree inconsistency

2005-06-23 Thread Matthew Thorley
Greetings, perhaps someone can explain this. I get to different styles of formatting for xmla and xmlb when I do the following: from elementtree import ElementTree as et xmla = et.ElementTree('some_file.xml') xmlb = et.Element('parent') et.SubElement(xmlb, 'child1') et.SubElement(xmlb, 'child2')

Re: how do you return an exit code with out exiting

2005-05-23 Thread Matthew Thorley
thanks thats perfect! Grant Edwards wrote: > On 2005-05-23, Matthew Thorley <[EMAIL PROTECTED]> wrote: > > >>I wrote a simple python program that scrapes a web page every >>30 secons and dumps the result in a data base. I want to use >>my linux distros build i

how do you return an exit code with out exiting

2005-05-23 Thread Matthew Thorley
hangs, waiting for my program to exit 1 or 0. My program never does exits because its looping every 30 seconds. Is there a way I can pass an exit value with out actualy exiting? or is there are better way to do this? Thanks -- Matthew Thorley -- http://mail.python.org/mailman/listinfo/python-list

Re: ElementTree and xsi to xmlns conversion?

2005-05-19 Thread Matthew Thorley
Thanks for the reply I am understanding it better now. Please forgive my ignorance. So the xsi is just an arbitrary name space prefix, I get that now. And it make sense to me why it gets converted to an xmlns. What I really need to know is why it is not inherited by the child elements? From what I

ElementTree and xsi to xmlns conversion?

2005-05-18 Thread Matthew Thorley
Why does ElementTree.parse convert my xsi to an xmlns? When I do this from elementtree import ElementTree # Sample xml mgac =""" http://www.chpc.utah.edu/~baites/mgacML"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://www.chpc.utah.edu/~baites/mgacML

Re: ElemenTree and namespaces

2005-05-16 Thread Matthew Thorley
Thanks Andrew & Oren, that should do the trick. -- http://mail.python.org/mailman/listinfo/python-list

ElemenTree and namespaces

2005-05-16 Thread Matthew Thorley
Does any one know if there a way to force the ElementTree module to print out name spaces 'correctly' rather than as ns0, ns1 etc? Or is there at least away to force it to include the correct name spaces in the output of tostring? I didn't see anything in the api docs or the list archive, but befo

Re: object oriented inheritance problem

2005-05-10 Thread Matthew Thorley
So is elementtree a module of modules? I didn't know you could do that. I just assumed that from elementtree import ElementTree imported a class from the module elementtree. It works now. Thanks guys. Fredrik Lundh wrote: > Matthew Thorley wrote: > > >>I am trying to inhe

object oriented inheritance problem

2005-05-10 Thread Matthew Thorley
I am trying to inherit from ElementTree so I can add some methods. This is the code I am trying to make work, and the following is the error I am getting. from elementtree import ElementTree class AcidTree(ElementTree): def write_string(self): File "/home/hope/var/proj/acid/serve

using tarfile with an open file object

2005-05-04 Thread Matthew Thorley
I've been using tarfile like this import tarfile tar = tarfile.open('path_to_tar_archive', 'r:gz') But I need to use it like this: archive = open('path_to_tar_archive', 'r') tar = tarfile.open(archive.readlines()) or something similar. In essence I need to use tarfile to manipulate an already

Re: How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
Peter Otten wrote: > Matthew Thorley wrote: > > >>Esben Pedersen wrote: >> >>>Matthew Thorley wrote: >>> >>> >>>>I'm writing a web app whereby a user uploads a tar acrhive which is then >>>>opened and pr

Re: How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
Esben Pedersen wrote: > Matthew Thorley wrote: > >> I'm writing a web app whereby a user uploads a tar acrhive which is then >> opened and processed. My web form reads the file like this: >> >> while 1: >> data = value.file.read(1024 * 8) # Read b

Re: How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
John Abel wrote: > Matthew Thorley wrote: > >> I'm writing a web app whereby a user uploads a tar acrhive which is then >> opened and processed. My web form reads the file like this: >> >> while 1: >>data = value.file.read(1024 * 8) # Read blocks

How do you convert a string obj to a file obj?

2005-05-04 Thread Matthew Thorley
I'm writing a web app whereby a user uploads a tar acrhive which is then opened and processed. My web form reads the file like this: while 1: data = value.file.read(1024 * 8) # Read blocks of 8KB at a time if not data: break which leaves me with data as a string obj. The problem that I ha

Re: Utah Python Users Group

2005-04-13 Thread Matthew Thorley
lugal wrote: > Is anyone aware if there's a Utah-based Python User Group? If not, does > any else from Utah have any interest in forming a Utah-based Python > User Group? > I'm in Utah, I don't know of any groups but I might be interested. -Matthew -- http://mail.python.org/mailman/listinfo/pyth

Re: Can dictionary values access their keys?

2005-04-08 Thread Matthew Thorley
Steve Holden wrote: > Indeed, they will probably just need to pass "self" as an argument to > the child object's creator (it will become an argument to the __init__() > method). This will be pretty cheap, since the additional attribute will > be bound to an already-existing value. > >> On the oth

Re: Can dictionary values access their keys?

2005-04-08 Thread Matthew Thorley
Steve Holden wrote: > I think that since each Datapoint appears to be unique, the simplest > thing to do is to include a reference to the parent object as an > attribute of the datapoint. Presumably when you create the Datapoint you > already know which Device and Mib it's going to be stored in, s

Re: Can dictionary values access their keys?

2005-04-08 Thread Matthew Thorley
Scott David Daniels wrote: > Matthew Thorley wrote: > >> This may be a very rudimentary question, but here goes: > > From your questions, I believe you are not thinking of values as > being distinct from the names and data structures that refer to them. > > What

Re: Can dictionary values access their keys?

2005-04-08 Thread Matthew Thorley
Steve Holden wrote: while not impossible (using Python's excellent > introspection facilities) is way beyond what most people would consider > practical. Obviously the garbage collector has to solve this problem, > but you *really* don't want to be doing this stuff in Python unless you > absolutely

Re: Can dictionary values access their keys?

2005-04-08 Thread Matthew Thorley
Axel Straschil wrote: > > For unique values, I did something like that couple of weeks ago, the > thing you would need is the getKey thing, it's fast, but needs much > memory for big structures becouse I use two dicts. Thanks for the tip, I may give that a try. I'll be interested to see what kind

Re: Can dictionary values access their keys?

2005-04-08 Thread Matthew Thorley
Can you please elaborate on this? -Matthew Diez B. Roggisch wrote: >>keeping a additional mapping between values and keys. > -- http://mail.python.org/mailman/listinfo/python-list

Can dictionary values access their keys?

2005-04-08 Thread Matthew Thorley
This may be a very rudimentary question, but here goes: If I have a simple dictionary, where the value is a class or function, is there an interface through which it can discover what its key is? Similar to index() for list. For a list, assuming I new what the parent list was I could do something

Re: problem with tk and pass by refference (I think :)

2005-02-11 Thread Matthew Thorley
Diez B. Roggisch wrote: I tried it but I got a syntax error. The interpreter didn't like the equals sign in the lambda. I am using python 2.3.4. Is there another way of writing that? Strange. This script works and shows the desired behaviour - python is also 2.3.4: def foo(x): print x fs = [la

Re: problem with tk and pass by refference (I think :)

2005-02-11 Thread Matthew Thorley
Diez B. Roggisch wrote: Hi, button = Button(self.songWin, text=verse, command=(lambda num=verseNum: self.showVerse(num)) ) should do the trick. The reason is basically that your version kept a reference to verseNum - and when executed, the value verseNum points to is the lasts one stored. Rebinding

problem with tk and pass by refference (I think :)

2005-02-11 Thread Matthew Thorley
Greetings, Maybe someone out there can lend me an eye? I've been stumped, banging my head against the wall trying to figure out why my script doesn't work. I've tried every thing I could think of, even unecessarily complicated mumbo-jumbo. Let me show you a snippet and then I'll explain what's

Re: trouble building python2.4

2004-12-22 Thread Matthew Thorley
Erik Max Francis wrote: Matthew Thorley wrote: Greetings, I just downloaded the python2.4 source from python.org and built it the usual way, i.e. ./configure && make. What I don't understand is that the resulting binary, when run, prints this line Python 2.3.4 (#1, Nov 15 2004, 10:

trouble building python2.4

2004-12-22 Thread Matthew Thorley
Greetings, I just downloaded the python2.4 source from python.org and built it the usual way, i.e. ./configure && make. What I don't understand is that the resulting binary, when run, prints this line Python 2.3.4 (#1, Nov 15 2004, 10:29:48) at the top of its banner. Further more, the poplib mo