optparse commandline

2007-07-08 Thread vvikram

I want to call some function from my program and just pass it a
commandline. It should parse the commandline and return back a list of
parsed arguments (just like the sys.argv list)

Example:
foo.parse_cmdline("/usr/bin/foorun -v -d -h")
==> ['/usr/bin/foorun', '-v', '-d','-h']

Any suggestions on how to do this are appreciated.

Regards
Vikram

-- 
http://mail.python.org/mailman/listinfo/python-list


socket.getfqdn deadlock

2007-03-20 Thread vvikram
Hi,

I am getting deadlocks (backtrace pasted below) after a while at,
presumably, a socket.getfqdn() call in a child process .

Fwiw: This child process is created as the result of a pyro call to a
Pyro object.

Any ideas why this is happening?

Thanks. Regards,
Vikram

---
Machine info:

Linux abcd 2.6.13-15.15-smp #1 SMP Mon Feb 26 14:11:33 UTC 2007 i686
i686 i386 GNU/Linux
SUSE LINUX 10.0 (i586)
VERSION = 10.0


Backtrace:

#0  0xe410 in __kernel_vsyscall ()
#1  0x4014c13e in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.
0
#2  0x40148e35 in _L_mutex_lock_36 () from /lib/tls/libpthread.so.0
#3  0x in ?? ()
#4  0x40831ff4 in ?? () from /lib/libnss_files.so.2
#5  0x418c1ea0 in ?? ()
#6  0x418c1e78 in ?? ()
#7  0x418c1ac4 in ?? ()
#8  0x4082bc1c in _nss_files_gethostbyname2_r () from /lib/
libnss_files.so.2
#9  0x4082bc1c in _nss_files_gethostbyname2_r () from /lib/
libnss_files.so.2
#10 0x402f4b1c in gaih_inet () from /lib/tls/libc.so.6
#11 0x402f384c in getaddrinfo () from /lib/tls/libc.so.6
#12 0x404ffa21 in setipaddr ()
   from /cv/vendor/lib/python2.4/lib-dynload/_socket.so
#13 0x4050263b in socket_gethostbyaddr ()
   from /cv/vendor/lib/python2.4/lib-dynload/_socket.so

-- 
http://mail.python.org/mailman/listinfo/python-list


re.I slowness

2006-03-30 Thread vvikram
We process a lot of messages in a file based on some regex pattern(s)
we have in a db.
If I compile the regex using re.I, the processing time is substantially
more than if I
don't i.e using re.I is slow.

However, more surprisingly, if we do something on the lines of :

s = 
s = s.lower()
t = dict([(k, '[%s%s]' % (k, k.upper())) for k in
string.ascii_lowercase])
for k in t: s = s.replace(k, t[k])
re.compile(s)
..

its much better than using plainly re.I.

So the qns are:
a) Why is re.I so slow in general?
b) What is the underlying implementation used and what is wrong, if
any,
with above method and why is it not used instead?

Thanks
Vikram

-- 
http://mail.python.org/mailman/listinfo/python-list