SNMPV3

2005-12-06 Thread Jacek Popławski
Do you have any experience with Python in SNMPv3 area? I just realized that pySNMP we are using supports only v1 and v2c, development version probably supports SNMPv3 but I am unable to find any v3-specific documentation, could you help me? Is there any other solution than pySNMP? -- http://ma

Re: memoru usage of process

2005-09-28 Thread Jacek Popławski
MrJean1 wrote: > Yes, I have seen it in archive, but I was searching for Python way, and it's not Python related at all (it is just reading system file), and won't work on QNX. -- http://mail.python.org/mailman/listinfo/python-l

memoru usage of process

2005-09-27 Thread Jacek Popławski
I need to know how much memory uses child process (after subprocess.Popen), so I want function: get_memory_usage(pid) I found two ways: - call "ps" and analyze its output - this is not portable (different output on Linux, Cygwin and QNX) - use resource.getrusage - but it works for self/childr

Re: read stdout/stderr without blocking

2005-09-16 Thread Jacek Popławski
Donn Cave wrote: > I don't recall the beginning of this thread, so I'm not sure > if this is the usual wretched exercise of trying to make this > work on both UNIX and Windows, It is used in "test framework" which runs on Linux, Windows (Cygwin) and QNX. I can't forget about Windows. -- http://

Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Grant Edwards wrote: > You're right. I must have been remembering the behavior of a > network socket. Apparently, you're supposed to read a single > byte and then call select() again. That seems pretty lame. I created another thread with single read(), it works, as long as I have only one PI

Re: popen in thread on QNX

2005-09-13 Thread Jacek Popławski
Laszlo, I can't reply your mails, your address doesn't work, please try jacekpoplawski-at-gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Only solution which works for now is to redirect stderr to stdout, and read stdout on thread. Code without thread or with read() or read(n) (when n>1) can block. Code with select() and read(1) works, but it is very slow. -- http://mail.python.org/mailman/listinfo/python-list

Re: read stdout/stderr without blocking

2005-09-13 Thread Jacek Popławski
Grant Edwards wrote: > On 2005-09-12, Jacek Pop?awski <[EMAIL PROTECTED]> wrote: > >>>ready = select.select(tocheck, [], [], 0.25) ##continues after 0.25s >>>for file in ready[0]: >>>try: >>>text = os.read(file, 1024) >> >>How do you know here, that you

Re: read stdout/stderr without blocking

2005-09-12 Thread Jacek Popławski
> ready = select.select(tocheck, [], [], 0.25) ##continues after 0.25s > for file in ready[0]: > try: > text = os.read(file, 1024) How do you know here, that you should read 1024 characters? What will happen when output is shorter? -- http://mail.python

Re: read stdout/stderr without blocking

2005-09-12 Thread Jacek Popławski
Adriaan Renting wrote: > Check out the select module, for an example on how to use it: > pexpect.sourceforge.net Two problems: - it won't work on Windows (Cygwin) - how much data should I read after select? 1 character? Can it block if I read 2 characters? -- http://mail.python.org/mailman/listi

read stdout/stderr without blocking

2005-09-12 Thread Jacek Popławski
Popen from subprocess module gives me access to stdout, so I can read it. Problem is, that I don't know how much data is available... How can I read it without blocking my program? example: import subprocess import time comman

subprocess solved all my problems

2005-09-09 Thread Jacek Popławski
In the last week I was working to create script which will read command from socket, call it, return result, stdout, stderr and kill it after timeout. After playing with threads, processes, spawns and popens I found subprocess module. To call command I use following construction:

Re: popen in thread on QNX

2005-09-08 Thread Jacek Popławski
Laszlo Zsolt Nagy wrote: > - one of your worker threads wants to run a command > - it creates the argument list and puts it into a message queue > - woker thread starts to sleep > - main thread processes the message queue -> it will run popen, put back > the file descriptors into the message and w

Re: killing thread after timeout

2005-09-08 Thread Jacek Popławski
Paul Rubin wrote: > Maybe the child process can just use sigalarm instead of a separate > thread, to implement the timeout. Already tried that, signals works only in main thread. > To get even more OS-specific, AF_UNIX sockets (at least on Linux) have > a feature called ancillary messages that al

Re: killing thread after timeout

2005-09-08 Thread Jacek Popławski
Bryan Olson wrote: > First, a portable worker-process timeout: In the child process, > create a worker daemon thread, and let the main thread wait > until either the worker signals that it is done, or the timeout > duration expires. It works on QNX, thanks a lot, your reply was very helpful! > I

Re: popen in thread on QNX

2005-09-08 Thread Jacek Popławski
Laszlo Zsolt Nagy wrote: > os.popen already creates a new process. So what if you try to call > os.popen from your main thread, then pass the file descriptors to your > thread? > It is just an idea... But I need to run command from thread, that's the main reason to create new thread :) -- http

Re: popen in thread on QNX

2005-09-08 Thread Jacek Popławski
It works when I use os.system() instead os.popen3(), but with os.system() I have no access to stdout and stderr :-( -- http://mail.python.org/mailman/listinfo/python-list

popen in thread on QNX

2005-09-08 Thread Jacek Popławski
I am still in the process of creating my script which will run command received from socket. My scripts works perfectly on Linux, but doesn't work on QNX! File "/usr/lib/python2.4/popen2.py", line 108, in __init__ self.pid = os.fork() OSError: [Errno 89] Function not implemented When I t

Re: killing thread after timeout

2005-09-06 Thread Jacek Popławski
After reading more archive I think that solution may be to raise an Exception after timeout, but how to do it portable? -- http://mail.python.org/mailman/listinfo/python-list

killing thread after timeout

2005-09-06 Thread Jacek Popławski
Hello. I am going to write python script which will read python command from socket, run it and return some values back to socket. My problem is, that I need some timeout. I need to say for example: os.system("someapplication.exe") and kill it, if it waits longer than let's say 100 seconds I

Re: telnet.read_until() from telnetlib

2005-08-31 Thread Jacek Popławski
my newsreader told me that [EMAIL PROTECTED] wrote: > "If end of file is found and no text was read, raise EOFError. > Otherwise, when nothing matches, return (-1, None, text) where text is > the text received so far (may be the empty string if a timeout > happened). " What if: - exception has not

Re: telnet.read_until() from telnetlib

2005-08-29 Thread Jacek Popławski
I have same problem with expect :-( I am calling: l=[expected] result=self.telnet.expect(l,timeout) it works in most cases, but sometimes (with exacly same "expected" value) it returns -1,Nil,"some text" the point is, that: - connection is still active, so it should read more! - it doesn't wait

Re: telnet.read_until() from telnetlib

2005-08-29 Thread Jacek Popławski
my newsreader told me that [EMAIL PROTECTED] wrote: > Please post the minimum code necessary to duplicate the problem. It's impossible, because I am writting performance tests for big commercial project, I am trying to understand why they sometime fail. By definition of "read_until()" it should re

telnet.read_until() from telnetlib

2005-08-26 Thread Jacek Popławski
I have strange problem with telnetlib. r=self.telnet.read_until(expected,timeout) It works in most cases (hundrets of iterations), but sometimes "r" doesn't contain "expected", first I thought that server is responding incorrectly, then I realized that read_until doesn't wait timeout seconds! ex