python win32 and COM? for internet monitoring
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 COM to listen on open ports (e.g. 80) and watch for http headers. But I'm not sure if there is a better way to do it. I would eventualy like to port this to Mac and Linux, but I figured that networking was at a low enough that I would have to do it differently for each OS. Could some one please tell me if I'm way off and point me in the right direction? Thanks very much --Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: python win32 and COM? for internet monitoring
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 should > turn up numerous existing implementations. > > Graham > Thanks for the tip, I'll check that out. -- Matthew -- http://mail.python.org/mailman/listinfo/python-list
formatted xml output from ElementTree inconsistency
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') root = et.Element('root') root.append(xmla.getroot()) root.append(xmlb) print et.tostring(root) 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 the some_file.xml is already nicely formatted? I thought that the formatting was ignored when creating new elements. Is their a function to 'pretty print' an element? I looked in api ref and didn't see anything that would do it. It would be nice if their was a way to create 'standard' formatted output for all elements regardless of how they were created. Comments and suggestions are greatly appreciated. regards -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: formatted xml output from ElementTree inconsistency
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 the some_file.xml is already nicely formatted? I >> thought that the formatting was ignored when creating new elements. > > > Why want you to read an XML document "by hand"? It's a "machine related" > data chunk. > > Document formatting should be done by means of CSS and/or XSL stylesheet. > It is just data to the machine, but people may have to read and interpret this data. I don't think there is anything unsual about formatting xml with tabs. Most web pages do that in their html/xhtml. Just imagine if you wanted to change a broken link on your web page, and the entire page was one long string. That may not matter to Dream Weaver, but it sure would be annoying if you were using vi :) -Matthew -- http://mail.python.org/mailman/listinfo/python-list
problem with tk and pass by refference (I think :)
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 happening. for verse in self.activeSong['verses']: verseNum = self.activeSong['verses'].index(verse) activeSong = self.activeSong.copy() firstLine = split(verse, '\n')[0] button = Button(self.songWin, text=verse, command=(lambda: self.showVerse(verseNum)) ) button.config(bg='grey') button.pack(expand=YES, fill=BOTH, side=TOP) self.verseButtons.append(button) This is as simple app for displaying the words of a song with an overhead projector. When you click on a song the program reads it and creates a button for each verse. When you click the button it is supposed to display that verse. As you can see above I am trying to call the showVerse method and pass it the verseNum. The problem I am having is that every button gets assigned the verseNum for the last verse that gets processed. That is to say, if a sone has 4 verses every button shows verse for, a 6 verse song loads verse 6 for every button, etc. I think that the value is getting passed by reference, so it gets updated with every iteration. I have seriously tried every thing I can think of to fix this. If any one has any thoughts I would really appreciate it. Thanks very much! -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with tk and pass by refference (I think :)
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 the argument to a parameter in the lambda will keep the right value for each iteration. 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? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with tk and pass by refference (I think :)
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 = [lambda: foo(i) for i in xrange(5)] for f in fs: f() fs = [lambda x=i: foo(x) for i in xrange(5)] for f in fs: f() You're right! It was my fault. I left the colon after the lambda by mistake. e.g. lambda: num=verseNum:... Thanks very much for the help it works great now! I wish I would have asked somebody sooner :) -Matthew -- http://mail.python.org/mailman/listinfo/python-list
trouble building python2.4
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 modules complains when I try to call the poplib.POP3_SSL class, saying that the module has no such class, though the online docs say it does. I read the README and I didn't see anything about having to pass options to configure to get it to build version 2.4. I appears to me that the tarball I downloaded wasn't really python2.4, even though it was 'official' and named Python-2.4.tgz. Can anyone please tell me what might of happened, or if they have had a similar experience? Thanks -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: trouble building python2.4
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:29:48) at the top of its banner. Further more, the poplib modules complains when I try to call the poplib.POP3_SSL class, saying that the module has no such class, though the online docs say it does. You've got a copy of Python 2.3.4 installed on your system which is in your PATH first. I have got to be the stupidest person on the face of the planet. Thanks very much. I was in the Python-2.4 dir, but I didn't call python with ./python. I can't believe I missed that. Thanks again -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Can dictionary values access their keys?
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 like this. >>> class child: ... def get_parent_index(self, parent): ... return parent.index(self) ... >>> a = child() >>> l = [a] >>> b = l[0] >>> b.get_parent_index(a) >>> b.get_parent_index(l) 0 Is there a way to do something like that with dicts? On a similar note, if one object is part of another, is there a way for the 'child' obj to discover what/who the 'parent' object is? That way parent does not have to be explicityly passed to get_parent_index? The idea is like this: >>> class child: ... def get_parent_index(self): parent = self.magic_parent_discovery() ... return parent.index(self) ... Thanks much -- Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: Can dictionary values access their keys?
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
Re: Can dictionary values access their keys?
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 of speed penalty I pay. The data I am using has multiples dictionaries with maybe a thousand entries each. But each entry is an object containing a history of data with perhaps hundreds or even thousands more entries. So we're talking about maybe a million+ total nested key:values. I don't know if that counts as large or not. I can't even guess how much k memory that is. I must say I am *very* suprised that python does not have a way to look up what key is pointing to a given object--without scanning the whole list that is. Is that what list.index() does under-the-hood? I mean is list.index(y) just the same as itemnum = 0 for item in list: if y == item: return itemnum else: itemnum = itemnum+1 I think I am going to have to reevaluate my system design... grrr. thanks -- Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: Can dictionary values access their keys?
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 *must*. > > regards > Steve Thanks very much for the detailed reply. Let me explain in a little more detail what I am doing, and perhaps you could let me know if I am going about it the wrong way. I am creating an object database to store information about network devices, e.g. switches and routers. At the top level there are device objects, every device object contains a mib object--and other various properties--where the actual data is stored. The mib object is a dicitionary--or at least subclasses dictionary--where the key is the oid (a unique string) and the value is a special object called Datapoint. Datapoints come in two types Static and Dynamic, and every Datapoint is unique. So a simple structure looks something like this: Device1 Mib1 {'1.3.6.1':Datapoint-x1, '1.3.6.2':Datapoint-y1, '1.1.5.4':Datapoint-z1, '1.2.7.3':Datapoint-q1} Device2 Mib2 {'1.3.6.1':Datapoint-x2, '1.3.6.2':Datapoint-y2, '1.1.5.4':Datapoint-z2, '1.2.7.3':Datapoint-q2} In the example Datapoint-xx should be read as, some unique data point in memory. The key in the Mib object is important because it is used by the Datapoint is points to to look up its current value on the given device, which is why I asked the two questions. In my program I use snmp to look up values on network devices. i.e. 'Go find the value of 1.3.6.1 from device1.' I want to be able to say something like Device1.Mib['1.3.6.1].update(), and the correct Datapoint discovers its key (oid) and parent device, then executes an snmp query that looks something like this snmpget(keyThatPointsToSelf, parentObj.ipAddress, parentObj.paramx) I know of course I could keep all this in a relational database and do a bunch of queries, but that would really suck! and I would have to track all the Devices and oids my self. What I really want is smart objects that think for me--thats what computers are for, right? ;) I thought my design was a wonderfuly beautiful use of python an oop, but perhaps I am mistaken and there is a much more pragmatic way to get the job done. In the end preformance doesn't matter a lot. The front end will be web based, so if the db can process faster than http/javascript and user Bob who has to mouse, then everything will be fine. Let me know what you think Thanks much --Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: Can dictionary values access their keys?
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 is the parent of 23 in the following expression? > > 1 + 11 * 2 > > If you know that, what is the parent of 293 in the same expression? > >> 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. > > > def keyfor(dictionary, element): > for key, value in dictionary.iteritems(): > if value == element: # value is element if identity quest > return key > raise ValueError, element > >> On a similar note, if one object is part of another, > > This is the idea you have wrong. In C, C++, Java, and Fortran you > might have objects part of other objects, but in Python objects refer > to each other. > > How about this: > > class Holder(object): pass > > v = [1 + 11 * 2] > w = [1, v, 3] > d = {1: v} > o = Holder() > o.x = v > > What is the parent of v? > > Or even worse: > > v = [1] > v[0] = v > > What is the parent of v now? > > --Scott David Daniels > [EMAIL PROTECTED] I see what your saying, but I my situation the values of the dictionary are unique objects created by a parent object. Sorry :(, I didn't explain that very well in my first post. When the 'root object' is 'global' I see what your saying, but when class A: def __init__(self, container): self.container=container class B(dict): def magice_get_parent(self): ... class special_value(): def __init__(self, val): self.val = val def magic_get_key(self): ... parent = A(B) parent.container[x] = special_value(1) parent.container[y] = special_value(2) parent.container[z] = special_value(1) In this example, in my mind, the following should happen, and in theory using introspecition, actualy possible. child = parent.container D.magic_get_parent() #returns parent value1 = parent.container[x] value2 = parent.container[y] value3 = parent.container[z] value1.magic_get_key() #returns x value2.magic_get_key() #returns y value3.magic_get_key() #returns z Let me know if I'm nutz! --Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: Can dictionary values access their keys?
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, so why > make work for yourself when you can trade a little storage and make the > whole thing easy? > I'll give that a shot and see how it goes. It makes sense, the parent objects create the child objects, so they could very easily set the apropriate parameter. On the other hand, the introspecitve stuff is cool! When you say "make more work for yourself" are you talking about 400 lines of code or 50. Further, is there much processing required to do the magic? When python do introspective magic, is it memory intensive? by that I mean does it have to make copies of the objects to do the look-ups? I don't mind copying the info like you suggest, but if the extra work won't take more than a day or two, (or maybe even a week if its fun) I'd like to do the introspection so that 1: I know how, 2: I can say that I did ;) Is there any kind of documentaion, (refference, article, blog-post, tutorial), that explains introspection in useful detail, or at least enough to get me started? > You might also be interested to know that the Python Software Foundation > funded the development of a Python package to support SNMP as a part of > its first round of grant funding last year, so there's at least one > other person working on this stuff! > I did see that and I was quite pleased! :) I am currently using the authors 'old' pysnmp which gets me by, but I am very excited to try out the new version when it is ready. Thanks again, for the reply and for the grant to pysnmp! -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: Can dictionary values access their keys?
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 other hand, the introspecitve stuff is cool! When you say "make >> more work for yourself" are you talking about 400 lines of code or 50. >> Further, is there much processing required to do the magic? When python >> do introspective magic, is it memory intensive? by that I mean does it >> have to make copies of the objects to do the look-ups? >> > Frankly I am not sure I see the advantage. You seem to be saying that > rather than provide each child object with a reference to its parent you > would rather provide it with a reference to the collection of parent > objects and let it work out which one it wants. Where's the benefit? All right then. > Happy to help, but I can't take credit for the grant, since all I did as > a PSF director was vote affirmatively on the recommendations of Martin > von Lowis' extremely hard-working grants committee. Thanks to the PSF for the grant! -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: Utah Python Users Group
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/python-list
How do you convert a string obj to a file obj?
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 have is that the function that processes the archive expects a file object. So far the only solution I have found it to write the file to disk and then read it back. Is there an easy way to convert data, in the example above into a file object? Thanks -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you convert a string obj to a file obj?
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 of 8KB at a time >>if not data: break >> >> which leaves me with data as a string obj. The problem that I have is >> that the function that processes the archive expects a file object. So >> far the only solution I have found it to write the file to disk and then >> read it back. >> >> Is there an easy way to convert data, in the example above into a file >> object? >> >> Thanks >> -Matthew >> >> > fileObj = StringIO.StringIO() > fileObj.write( data ) > > J > I gave that a shot but got this error? Perhaps I misunderstood what kind of object I needed. Any thoughts? AttributeError: StringIO instance has no attribute 'rfind' -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you convert a string obj to a file obj?
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 blocks of 8KB at a time >> if not data: break >> >> which leaves me with data as a string obj. The problem that I have is >> that the function that processes the archive expects a file object. So >> far the only solution I have found it to write the file to disk and then >> read it back. >> >> Is there an easy way to convert data, in the example above into a file >> object? >> >> Thanks >> -Matthew > > > value.file is a file object. Why don't you give that as an argument? > > /Esben Ok I tried that but I still get this error. Any clue what I need to do? AttributeError: 'file' object has no attribute 'rfind' thanks -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: How do you convert a string obj to a file obj?
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 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 have is >>>>that the function that processes the archive expects a file object. So >>>>far the only solution I have found it to write the file to disk and then >>>>read it back. >>>> >>>>Is there an easy way to convert data, in the example above into a file >>>>object? >>>> >>>>Thanks >>>>-Matthew >>> >>> >>>value.file is a file object. Why don't you give that as an argument? >>> >>>/Esben >> >>Ok I tried that but I still get this error. Any clue what I need to do? >> >>AttributeError: 'file' object has no attribute 'rfind' > > > str has an rfind() method while file has not: > > >>>>file.rfind > > Traceback (most recent call last): > File "", line 1, in ? > AttributeError: type object 'file' has no attribute 'rfind' > >>>>str.rfind > > > > So "the function" seems to expect a string rather than a file. Or perhaps > there's an (evil) isinstance(param, file) check somewhere that triggers > param to be treated as a filename. Absent further information, only you can > find out. > > Peter Ok you're right. tarfile.open expects a string; the path to the file open. I thought that I had tried it with open file objects but I guess I was mistaken. Thanks all for the help -Matthew -- http://mail.python.org/mailman/listinfo/python-list
using tarfile with an open file object
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 open file object. I searched in the docs but didn't find anything. Maybe I just over looked the obvious. Does any one know how to do this? Thanks -matthew -- http://mail.python.org/mailman/listinfo/python-list
object oriented inheritance problem
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/server/mgacparse.py", line 22, in ? class AcidTree(ElementTree): TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) I have *no* idea what is going on here. AcidTree does not implement an __init__. It just adds two simple methods, which aren't even being called when then exception is thrown. The exception occurs on the class definition line when I try to inherit from ElementTree. I looked around, and read some stuff in the python cook book, and everything I've seen indicates that it should just work. My only thought is that its a 'oldstyle' vs 'newstyle' classes issue. I know that elementtree was written to be compatible with python 1.5 so maybe it doesn't work with the new stuff. But thats just a crazy assumption I made up to make myself feel better. If anyone could please exmplain what my problem *really* is I would appreciate it greatly. Thanks very much. -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: object oriented inheritance problem
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 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/server/mgacparse.py", line 22, in ? >>class AcidTree(ElementTree): >>TypeError: Error when calling the metaclass bases >>module.__init__() takes at most 2 arguments (3 given) >> >>I have *no* idea what is going on here. > > > note that you're trying to inherit from a module. the error message could > need some work... > > something like > > from elementtree.ElementTree import ElementTree, tostring > > class AcidTree(ElementTree): > def write_string(self): > return tostring(self) > > should work better. > > > > > -- http://mail.python.org/mailman/listinfo/python-list
ElemenTree and namespaces
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 before I set off to do it myself I thought I should ask, because it seemed like the kind of thing that has already been done. thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: ElemenTree and namespaces
Thanks Andrew & Oren, that should do the trick. -- http://mail.python.org/mailman/listinfo/python-list
ElementTree and xsi to xmlns conversion?
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 http://www.chpc.utah.edu/~baites/mgacML/mgac.xsd";> """ xml = ElementTree.fromstring(mgac) ElementTree.tostring(xml) I get this 'http://www.chpc.utah.edu/~baites/mgacML http://www.chpc.utah.edu/~baites/mgacML/mgac.xsd"; xmlns:ns0="http://www.chpc.utah.edu/~baites/mgacML"; xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance";>' The xsi is gone and has been replaced by a new xmlns, which is also NOT inherited by the child elements. ElementTree.tostring(xml.getchildren()[0]) 'http://www.chpc.utah.edu/~baites/mgacML"; />' If some one could please explain where I'm off I'd really appreciate it. I need to use xsi: to validate the document, and I'm not sure how to pass it on to the children when I reformat the doc. Thanks -Matthew -- http://mail.python.org/mailman/listinfo/python-list
Re: ElementTree and xsi to xmlns conversion?
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 an told, I need the second namespace, so that I can point to the schema, so that I can validate the document. Is that the wrong way to link to the schema? Can I force both namespaces to be inherited by the child elements? Thanks for all the help -Matthew -- http://mail.python.org/mailman/listinfo/python-list
how do you return an exit code with out exiting
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 in init tools to run the script in the back ground as a daemon. The problem is when I call the daemon script to background the program I wrote it just 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: how do you return an exit code with out exiting
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 in init tools to run the script in the >>back ground as a daemon. The problem is when I call the daemon >>script to background the program I wrote it just 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? > > > No. > > >>or is there are better way to do this? > > > Yes. > > To be a well-behavied daemon, you need to do the things > described in this howto: > > http://www.linuxprofilm.com/articles/linux-daemon-howto.html > > Here are a couple references on how to do this in Python: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 > http://homepage.hispeed.ch/py430/python/ > -- http://mail.python.org/mailman/listinfo/python-list