Re: How to add a Decorator to a Class Method

2007-11-20 Thread Laszlo Nagy
>> Can new_func reference self? Would self just be one of the args? >> >> -Greg >> > > For methods, self is always "just one of the args". When the > decorator is applied to a method, self will be args[0] in new_func. > If you want to use the name "self" instead of args[0] you can: def

Re: sendmail a long message

2007-11-21 Thread Laszlo Nagy
Helmut Jarausch wrote: > Hi, > > to send a possibly long email I have seen a solution > which does os.popen to an external sendmail program and > then writes the message into that pipe. > > I wonder if it possible to use smtplib.SMTP.sendmail > but this requires building the complete body as one lo

Re: Control mouse position and clicking

2007-11-28 Thread Laszlo Nagy
Paul McGuire wrote: > On Nov 28, 1:29 pm, Glich <[EMAIL PROTECTED]> wrote: > >> hi, how can I, control mouse position and clicking from python? >> >> I want to interact with a flash application inside firefox. thanks. >> >> ps: I am not using windows. >> > > Ooof, I was about to suggest usi

kniterbasdb and datetime

2007-12-13 Thread Laszlo Nagy
Hi All, I connected to a FireBird 1.5 database this way: import kinterbasdb kinterbasdb.init(type_conv=200) # See http://kinterbasdb.sourceforge.net/dist_docs/usage.html#faq_fep_is_mxdatetime_required Then I try to update the database: sql = "UPDATE TABLE1 SET DATEFIELD=? where ID = ?" para

Re: kniterbasdb and datetime

2007-12-13 Thread Laszlo Nagy
DarkBlue írta: > On Dec 13, 7:45 pm, Laszlo Nagy <[EMAIL PROTECTED]> wrote: > >> Hi All, >> >> I connected to a FireBird 1.5 database this way: >> >> import kinterbasdb >> kinterbasdb.init(type_conv=200) # >> Seehttp://kinterba

Re: kniterbasdb and datetime

2007-12-13 Thread Laszlo Nagy
>> Kinterbasdb probably expects the format looking like >> >> month/day/year >> >> rather than >> >> year-month-day >> All right, I tried the month/day/year version: print sql print params cur.execute(sql,params) Results in: Inserting new TTT codes...insert into ttt( ID, T

Re: hi,everyone. a problem with shelve Module

2006-05-26 Thread Laszlo Nagy
[EMAIL PROTECTED] i'rta: > >> i only write ten records like this: > > >>name sex age > > >> jimmale 22 > >> tom male 23 > >> lucy female 21 >

urllib2 and HTTP 302

2006-05-26 Thread Laszlo Nagy
Hello, The code below uses urllib2 and build_opener. Having this code fragment, how can I return the redirection URL? I tried to get this information from the exception but I could not. Is it possible to read it from the openerdirector? Any suggestions? try: self

Re: Running Python scripts under a different user

2006-05-26 Thread Laszlo Nagy
Hello Diez, Please see below. > And as you refrain form telling us which OS you are running under one > can only be very vague on what to suggest - UNIXish OSes have for > example the setguid-bit, sudo springs to mind and under certain desktops > there are ways to acquire root-settings (but y

Want a strange XML RPC server

2008-01-08 Thread Laszlo Nagy
Hi, I would like to have a strage XML RPC server. It should use one main thread for all connections. I have some code like this (using a custom RPC server class): server_address = (LISTEN_HOST, LISTEN_PORT) # (address, port) server = mess.SecureXMLRPCServer.SecureXMLRPCServer(

ftplib question (cannot open data connection)

2008-01-11 Thread Laszlo Nagy
Hi All, I'm using a simple program that uploads a file on a remote ftp server. This is an example (not the whole program): def store(self,hostname,username,password,destdir,srcpath): self.ftp = ftplib.FTP(hostname) self.ftp.login(username,password) self.ftp.set_pasv(False) se

Re: ftplib question (cannot open data connection)

2008-01-13 Thread Laszlo Nagy
> BUT: active FTP does not just send the data to the port that was in > the random port that was sent to the server... it addresses to the port > you sent, but it sends its data response FROM port 20. This means the > response looks like a totally unsolicited connection attempt from the > ou

simpleparse - what is wrong with my grammar?

2008-02-24 Thread Laszlo Nagy
The program below gives me "segmentation fault (core dumped)". Environment: Linux gandalf-desktop 2.6.20-16-generic #2 SMP Tue Feb 12 05:41:34 UTC 2008 i686 GNU/Linux Python 2.5.1 What is wrong with my grammar? Can it be an internal error in simpleparse? Thanks, Laszlo from simplepa

Re: simpleparse - what is wrong with my grammar?

2008-02-25 Thread Laszlo Nagy
>> > You've created an infinitely recursing grammar. SimpleParse is a > straightforward recursive descent parser without look-ahead (unless > explicitly coded) or ambiguity resolution. You are asking it to parse > "expr" to see if "expr,binop,expr" is matched. It will continue > recursing

ZSI and attachments

2008-03-11 Thread Laszlo Nagy
Hi All, I wonder if the newest ZSI has support for attachments? Last time I checked (about a year ago) this feature was missing. I desperately need it. Alternatively, is there any other SOAP lib for python that can handle attachments? Thanks, Laszlo -- http://mail.python.org/mailman/l

Decode email subjects into unicode

2008-03-18 Thread Laszlo Nagy
Hi All, 'm in trouble with decoding email subjects. Here are some examples: > =?koi8-r?B?4tnT1NLP19nQz8zOyc3PIMkgzcHMz9rB1NLB1M7P?= > [Fwd: re:Flags Of The World, Us States, And Military] > =?ISO-8859-2?Q?=E9rdekes?= > =?UTF-8?B?aGliw6Fr?= I know that "=?UTF-8?B" means UTF-8 + base64 encoding,

Re: Decode email subjects into unicode

2008-03-18 Thread Laszlo Nagy
Sorry, meanwhile i found that "email.Headers.decode_header" can be used to convert the subject into unicode: > def decode_header(self,headervalue): > val,encoding = decode_header(headervalue)[0] > if encoding: > return val.decode(encoding) > else: > return val However, there are malformed emails

Re: Decode email subjects into unicode

2008-03-19 Thread Laszlo Nagy
Gertjan Klein wrote: > Laszlo Nagy wrote: > > >> However, there are malformed emails and I have to put them into the >> database. What should I do with this: >> > [...] > >> There is no encoding given in the subject but it contains 0x92. When I

eval and unicode

2008-03-20 Thread Laszlo Nagy
How can I specify encoding for the built-in eval function? Here is the documentation: http://docs.python.org/lib/built-in-funcs.html It tells that the "expression" parameter is a string. But tells nothing about the encoding. Same is true for: execfile, eval and compile. The basic problem: - e

Re: eval and unicode

2008-03-20 Thread Laszlo Nagy
>> I tried to use eval with/without unicode strings and it worked. Example: >> >> >>> eval( u'"徹底したコスト削減 ÁÍŰŐÜÖÚÓÉ трирова"' ) == eval( '"徹底し >> たコスト削減 ÁÍŰŐÜÖÚÓÉ трирова"' ) >> True >> > When you feed your unicode data into eval(), it doesn't have any > encoding or decoding work to do. >

Re: eval and unicode

2008-03-21 Thread Laszlo Nagy
Hi Jonathan, I think I made it too complicated and I did not concentrate on the question. I could write answers to your post, but I'm going to explain it formally: >>> s = '\xdb' # This is a byte, without encoding specified. >>> s.decode('latin1') u'\xdb' # The above byte decoded in lat

Re: eval and unicode

2008-03-21 Thread Laszlo Nagy
> > Your problem is, I think, that you think the magic of decoding source > code from the byte sequence into unicode happens in exec or eval. It > doesn't. It happens in between reading the file and passing the > contents of the file to exec or eval. > I think you are wrong here. Decoding sourc

Re: eval and unicode

2008-03-25 Thread Laszlo Nagy
> I think your confusion comes from the use of the interactive mode. > It is not. The example provided in the original post will also work when you put then into a python source file. > PEP 263 doesn't really apply to the interactive mode, hence the > behavior in interactive mode is undefined,

StringIO + unicode

2008-03-25 Thread Laszlo Nagy
Is there a standard "in-memory file" interface for reading/writting unicode stings? Something like StringIO. E.g. this would be possible: - create UnicodeStringIO - write unicode strings into it - wite data (binary) string of UnicodeStringIO into a file ('wb' mode) and then later: - read the s

Re: eval and unicode

2008-03-25 Thread Laszlo Nagy
Martin v. Löwis wrote: >> eval() somehow decoded the passed expression. No question. It did not >> use 'ascii', nor 'latin2' but something else. Why is that? Why there >> is a particular encoding hard coded into eval? Which is that >> encoding? (I could not decide which one, since '\xdb' will be

Re: dynimac code with lambda function creation

2008-03-27 Thread Laszlo Nagy
Justin Delegard wrote: > So I am trying to pass an object's method call to a function that > requires a function pointer. I figured an easy way to do it would be to > create a lambda function that calls the correct method, but this is > proving more difficult than I imagined. > > Here is the fu

Re: How do I reconnect a disconnected socket?

2008-03-28 Thread Laszlo Nagy
> This is what I've got right now: > > #! /usr/bin/env python > import socket, string > sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > def doconn(): > sock.connect(("localhost", 1234)) > def dodiscon(): > sock.close() > doconn() > > doconn() > > while (1): > buffer

Re: How do I reconnect a disconnected socket?

2008-03-28 Thread Laszlo Nagy
> Yes, that is exactly what it means. > > >From the recv() man page: > > RETURN VALUE >These calls return the number of bytes received, or -1 if an error >occurred. The return value will be 0 when the peer has performed an >orderly shutdown. > > Mea cupla. :-) W

Bug in python [was: Fatal Python error: ceval: tstate mix-up]

2009-01-12 Thread Laszlo Nagy
Laszlo Nagy wrote: Meanwhile I'm trying to turn off threads in that program one by one. I just got this new type of error: Fatal Python error: PyThreadState_Delete: invalid tstate After some days, there are now answers to my question. I guess this is because nobody knows the answer. I th

Slow network?

2009-01-12 Thread Laszlo Nagy
Hi All, To make the long story short, I have a toy version of an ORB being developed, and the biggest problem is slow network speed over TCP/IP. There is an object called 'endpoint' on both sides, with incoming and outgoing message queues. This endpoint object has a socket assigned, with n

Re: Slow network?

2009-01-12 Thread Laszlo Nagy
It is very likely that nodelay is actually hurting you here. Using the select module and doing non-blocking IO will be faster than using threads for this as well. These sockets are non blocking and I'm using select.select indeed. Here is how it is implemented: def read_data(self,size): re

Re: Slow network?

2009-01-12 Thread Laszlo Nagy
You might also want to replace those 'pass' statements when smartqueue is empty or full with time.sleep() to avoid busy waiting. It won't do busy waiting, because read_str and write_str are using select.select and they will block without using CPU time, until data becomes available to read/wri

Re: Slow network?

2009-01-12 Thread Laszlo Nagy
You might also want to replace those 'pass' statements when smartqueue is empty or full with time.sleep() to avoid busy waiting. I misunderstood your post, sorry. My smartqueue class has a timeout parameter, and it can block for an item, or raise the Full/Empty exception after timeout exceeded

Re: Slow network?

2009-01-12 Thread Laszlo Nagy
Waiting for a response after each send will take longer than doing the sends and then the responses. Have you tried pinging the destination to see how long the round trip takes? Has your friend? My test application listens on 127.0.0.1. gand...@gandalf-desktop:~/Python/Lib/orb/examples/01_

Standard IPC for Python?

2009-01-13 Thread Laszlo Nagy
I would like to develop some module for Python for IPC. Socket programming howto recommends that for local communication, and I personally experienced problems with TCP (see my previous post: "Slow network"). I was looking for semaphores and shared memory, but it is not in the standard lib. I

Re: Standard IPC for Python?

2009-01-13 Thread Laszlo Nagy
The only reason to use shm over the sysv_ipc module is that shm supports versions of Python < 2.5. I'm not developing shm any further, so avoid using it if possible. Hmm, we are using FreeBSD, Ubuntu and Windows. Unfortunately - posix_ipc is broken under FreeBSD - sysv_ipc does not support me

Re: Standard IPC for Python?

2009-01-13 Thread Laszlo Nagy
I use Pyro. Has always been fast enough for me. It spares you the troubles of bloated XML-documents other RPC-mechanisms use. Of course it is RPC, not "only" IPC - so it comes with a tradeoff. But so far, it has been always fast enough for me. Unfortunately, I'm developing an ORB, and using

Re: Standard IPC for Python?

2009-01-13 Thread Laszlo Nagy
- posix_ipc is broken under FreeBSD A clarification: the module posix_ipc is *not* broken. It exposes FreeBSD's implementation of POSIX IPC which has broken semaphores (based on my experiments, anyway). The practical result for you is the same but the difference is very important to me as

Re: Standard IPC for Python?

2009-01-13 Thread Laszlo Nagy
I realize that lack of Windows support is a big minus for both of these modules. As I said, any help getting either posix_ipc or sysv_ipc working under Windows would be much appreciated. It sounds like you have access to the platform and incentive to see it working, so dig in if you like. M

Re: Standard IPC for Python?

2009-01-13 Thread Laszlo Nagy
I was suggesting getting posix_ipc or sysv_ipc to compile against a compatibility library (Cygwin?) under Windows. It sounds like you're proposing something totally different, no? OK I see. But probably I do not want to use Cygwin because that would create another dependency. I understand th

Re: Standard IPC for Python?

2009-01-14 Thread Laszlo Nagy
There are plenty of different IPC mechanisms available in multiprocessing. It is good for a special case: a tree of processes, forked from a main process. multiprocessing.Queue cannot be used as a general message queue between arbitrary processes. - mmap.mmap with 0 or -1 as the first argu

Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
I had this test program originally that sent message over TCP/IP. Messages where buffered two a Queue.Queue instances, one for incoming and one for outgoing. #1. endpoint.send_message(msg) -> endpoint.outgoing.put(msg) #2. endpoint._process_outgoing() is a thread, that does: endpoint.write_in

Re: Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
then the speed goes up to 64 messages/sec on windows and 500 messages/sec on Linux. Finally I could reach 1500 messages/sec without using the queue. If I comment out one line (use the queue instead of direct write into socket) then speed decreases to 40-60 messages/sec. I don't understand wh

Re: process/thread instances and attributes

2009-01-15 Thread Laszlo Nagy
Hey all, I have this concept I'm working on and here is the code... Problem is if you run this it doesn't terminate. I believe you can terminate it in the main process by calling a.stop() But I can't find a way for it to self terminate, ie: self.stop() As indicated by the code... I'm not sur

Re: Slow Queue.queue? (was: slow network)

2009-01-15 Thread Laszlo Nagy
I would try something like this inside _process_outgoing: while not self.stop_requested.isSet(): data_ok = False while not self.stop_requested.isSet(): if not self.outgoing.empty(): try:

Re: Dynamic Loading Modules

2009-01-18 Thread Laszlo Nagy
Riley Porter írta: Hello all, This is the first time I have posted to this group. That being said if I am in the wrong place for this kind of support please let me know. OK, So I am writing a log parsing program and wish to allow for the community to write "parsers". Basically, what I ha

socket.unbind or socket.unlisten? - socket.error: (48, 'Address already in use')

2009-01-27 Thread Laszlo Nagy
I have a program that uses socket.bind() and socket.listen() frequently. After that program stops, it is not able to bind() again for a while: File "/home/gandalf/Python/Lib/orb/accesspoints/srvtcp.py", line 27, in __init__ self.serversocket.bind((self.listen_address,self.port)) File "", l

Re: is python Object oriented??

2009-01-31 Thread Laszlo Nagy
M Kumar wrote: Object oriented languages doesn't allow execution of the code without class objects, what is actually happening when we execute some piece of code, is it bound to any class? Those who have time and consideration can help me There are many kinds of definitions for "object orient

Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Address already in use')

2009-01-31 Thread Laszlo Nagy
8<-- ... Setting the SO_REUSEADDR flag on POSIX fixes this problem (don't set it on Windows, though). Why not? I have been merrily setting it, and I have not noticed anything weird. (yet) Please see my original post. I specifically stated that I d

kinterbasdb + firebird 1.5 with python 2.6 ?

2009-02-03 Thread Laszlo Nagy
Does anyone know how to get firebird 1.5 driver (kinterbasdb) for FireBird 1.5? My problem: * python 2.6 already installed on a server * there is a firebird 1.5 database on the same server * I need to access it from python 2.6 Any thoughts? -- http://mail.python.org/mailman/listinfo

Re: kinterbasdb + firebird 1.5 with python 2.6 ?

2009-02-05 Thread Laszlo Nagy
Uwe Grauer írta: Laszlo Nagy wrote: Does anyone know how to get firebird 1.5 driver (kinterbasdb) for FireBird 1.5? My problem: * python 2.6 already installed on a server * there is a firebird 1.5 database on the same server * I need to access it from python 2.6 Any thoughts

Re: How to Write to csv file to create bulk address book

2008-12-07 Thread Laszlo Nagy
I am new to scripting, I am working on script which would create 'n' number address book entries into a csv file which would be used to import into a address book. I need suggestions for the same Please check out the 'csv' module. It comes with Python. Batteries included. :-) http://docs.

ORB for Python and PHP

2008-12-08 Thread Laszlo Nagy
We have a problem here. We have a website written in PHP. and many programs written in Python. The communication between the components is messy. os.system calls are mixed with popen, xml-rpc and others. We would like to make it consistent and portable. We would like to use free software. What

Re: ORB for Python and PHP

2008-12-09 Thread Laszlo Nagy
There are others but they do not support both Python and PHP. Should I implement my own ORB, or do you know a suitable solution? The whole purpose of an ORB ist that it is interoperable. So if you have a good python orb (I personally prefer OmniORB), and a good one for PHP - connect them.

psycopg2 and large queries

2008-12-18 Thread Laszlo Nagy
psycopg2 is said to be db api 2.0 compilant, but apparent it is buggy. By default, when I create a cursor with cur = conn.cursor() then it creates a cursor that will fetch all rows into memory, even if you call cur.fetchone() on it. (I tested it, see below.) I was looking for psycopg2 documenta

Re: Is this pythonic?

2008-12-18 Thread Laszlo Nagy
ipyt...@gmail.com wrote: x.validate_output(x.find_text(x.match_filename (x.determine_filename_pattern(datetime.datetime.now() Is it even good programming form? You should try LISP. :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: psycopg2 and large queries

2008-12-18 Thread Laszlo Nagy
Well, there are plenty of PostgreSQL modules around these days, and even if pyPgSQL isn't suitable, I'm sure that there must be one which can be made to work on Windows and to support server-side cursors. See here for more: http://wiki.python.org/moin/PostgreSQL I'm just looking for somethin

Re: psycopg2 and large queries

2008-12-18 Thread Laszlo Nagy
They do have a description attribute, but it is only populated after you fetch a row. eg try cur = conn.cursor(name='mycursor') cur.execute('select name from blah') cur.fetchone() print cur.description Oh, great. I should have known. Thanks. Maybe I can live with psycopg2, because combining

select.select and socket.setblocking

2008-12-30 Thread Laszlo Nagy
I'm using this method to read from a socket: def read_data(self,size): """Read data from connection until a given size.""" res = "" fd = self.socket.fileno() while not self.stop_requested.isSet(): remaining = size - len(res) if remaining<=0:

Python list's mail server in DNSBL ?

2008-12-30 Thread Laszlo Nagy
I got this message when I tried to send something to this list, through my ISP's SMTP server: This Message was undeliverable due to the following reason: Each of the following recipients was rejected by a remote mail server. The reasons given by the server are included to help you determine w

Re: Python list's mail server in DNSBL ?

2008-12-30 Thread Laszlo Nagy
Steve Holden wrote: Laszlo: Read the message again. There's nothing the list admins can do about this, you'll have to contact postmas...@chello.at to have them remove the blacklisting, since it's their server that's imposing it. Maybe it is my bad English but this part: Ask your > Mail-/DN

Fatal Python error: ceval: tstate mix-up

2009-01-09 Thread Laszlo Nagy
After upgrading my system, a program started to throw this error, and make a core dump: Fatal Python error: ceval: tstate mix-up Kernel log says: Jan 9 05:06:49 shopzeus kernel: pid 89184 (python), uid 1024: exited on signal 6 (core dumped) I found out that this can happen only when execu

Re: Fatal Python error: ceval: tstate mix-up

2009-01-09 Thread Laszlo Nagy
I could start "gdb python python.core" but don't know what it means. Unfortunately, there are no debugging symbols. %gdb /usr/local/bin/python python.core GNU gdb 6.1.1 [FreeBSD] Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and yo

Re: Fatal Python error: ceval: tstate mix-up

2009-01-09 Thread Laszlo Nagy
Meanwhile I'm trying to turn off threads in that program one by one. I just got this new type of error: Fatal Python error: PyThreadState_Delete: invalid tstate -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the perfect (OS independent) way of storing filepaths ?

2008-10-21 Thread Laszlo Nagy
However, the normal place to store settings on Windows is in the registry. Which becomes a single point of failure for the whole system. LOL :-) BTW famous big popular programs like firefox and thunderbird will store their configuration data under "Documents and Settings\Application

Re: Immutable object thread-safety

2008-10-26 Thread Laszlo Nagy
Also, the other question is the operation st = 'ThreadBWasHere' is atomic? I think this is the same question. And I believe it is not atomic, because it is actually rebinding a name. Consider this: a,b = b,a This will rebind both a and b. In order to be correct, it MUST happen in two phase

Re: Immutable object thread-safety

2008-10-26 Thread Laszlo Nagy
This will rebind both a and b. In order to be correct, it MUST happen in two phases: first calculate the right side, then do the rebind to the names on the left side. "rebind to the names" -> "rebind the names found on the left side, to the objects calculated from the expressions on the righ

try except question - serious foo bar question, and pulling my hair out :-)

2009-02-24 Thread Laszlo Nagy
Given this class below: import Queue import threading from sorb.util.dumpexc import dumpexc import waitablemixin PREFETCH_SIZE = 10 class Feeder(threading.Thread,waitablemixin.WaitableMixin): def __init__(self,connection_manager): self.cm = connection_manager self.expired_asin

Re: try except question - serious foo bar question, and pulling my hair out :-)

2009-02-24 Thread Laszlo Nagy
I assume stop_requested is an Event object. Maybe other thread cleared it? It was never set! -> nothing can clear it. -- http://mail.python.org/mailman/listinfo/python-list

Re: try except question - serious foo bar question, and pulling my hair out :-)

2009-02-24 Thread Laszlo Nagy
I assume stop_requested is an Event object. Maybe other thread cleared it? It was never set! -> nothing can clear it. In theory, it could be that a thread sets the event object. E.g.: #1. other thread calls stop_requested.set() #2. "while not self.stop_requested.isSet()" -- loop exists #3

Re: try except question - serious foo bar question, and pulling my hair out :-)

2009-02-24 Thread Laszlo Nagy
It seems impossible to me. The while loop should only exit if stop_requested becomes set, OR if an exception is raised. However, all exceptions are cought and logged. But there are no exceptions logged. And stop_requested is NOT SET. (see the last line in the log). What is happening here?

Re: try except question - serious foo bar question, and pulling my hair out :-)

2009-02-24 Thread Laszlo Nagy
Use this instead: import sys try: ??? except: e = sys.exc_value do_with(e) Only at the outermost block on your code, if ever... The fact that some exceptions don't inherit from Exception is on purpose -- usually you *dont* want to catch (and swallow) SystemExit (nor KeyboardInte

ValueError: filedescriptor out of range in select()

2009-03-17 Thread Laszlo Nagy
This is a long running process, written in Python. Only standard lib is used. This process accepts connections on TCP sockets, read/write data. After about one day, it starts throwing this when I try to connect: 2009-03-17 09:49:50,096 INFO .accesspoint0 ('127.0.0.1', 55510) connecting 2009-03-

Re: ValueError: filedescriptor out of range in select()

2009-03-17 Thread Laszlo Nagy
Hi Laszlo, Just a hunch -- are you leaking file handles and eventually running out? These file handles are for TCP sockets. They are accept()-ed, used and then thrown out. I guess after the connection was closed, the file handle is destroyed automatically. BTW here is the shutdown() method fo

Re: ValueError: filedescriptor out of range in select()

2009-03-17 Thread Laszlo Nagy
Here's an interesting post: http://mail.python.org/pipermail/python-list/2005-April/317442.html Thank you. I'll try socket.close() instead of socket.shutdown(). Or both. :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: ValueError: filedescriptor out of range in select()

2009-03-17 Thread Laszlo Nagy
For whatever reason, you're ending up with a lot of open files and/or sockets (and/or any other resource based on file descriptors). That results in new file descriptors having large values (>=1024). You cannot use select() with such file descriptors. Try poll() instead, or Twisted. ;) Poll

dbfpy - cannot store new record

2009-05-21 Thread Laszlo Nagy
Given this example program: import dbfpy def dbf_open(tblname): fpath = os.path.join(local.DB_DIR,tblname) f = file(fpath,"ab+") f.seek(0) tbl = dbf.Dbf(f) return tbl tbl = dbf_open("partners.dbf") rec = tbl.newRecord() rec["FIELDNAME1"] = 1 rec["FIELDNAME2"] = "Somebody" rec.stor

Re: dbfpy - cannot store new record

2009-05-21 Thread Laszlo Nagy
David Lyon írta: Hi, Try not opening the file in append mode (no "a+") Inside the logic, there is already a seek to the end of the file and the record counters at the start of the file need updating too. The first thing I tried is to use a filename instead of the file object but it didn't w

Re: dbfpy - cannot store new record

2009-05-21 Thread Laszlo Nagy
Here is the next problem. For boolean/logical fields, I can set their value to True/False easily. However, setting NULL seems impossible: rec = tbl.newRecord() rec["SOMEFIELD1"] = True # Works fine rec["SOMEFIELD2"] = False # Works fine rec["SOMEFIELD3"] = None # Will store False rec["SOMEFIELD3

Re: dbfpy - cannot store new record

2009-05-21 Thread Laszlo Nagy
Here is the next problem. For boolean/logical fields, I can set their value to True/False easily. However, setting NULL seems impossible: rec = tbl.newRecord() rec["SOMEFIELD1"] = True # Works fine rec["SOMEFIELD2"] = False # Works fine rec["SOMEFIELD3"] = None # Will store False rec["SOMEFIELD

Re: dbfpy - cannot store new record

2009-05-22 Thread Laszlo Nagy
dbfpy is very old code. Try setting up a CHAR(1) field and filling it with "Y" or "N" or "T" or "F".. indicating yes,no,true or false... Unfortunately, my task is to import records into a database that is used by an old foxpro program. I'm not allowed to change the database structure i

Re: Is there no single/uniform RDBMS access API module for Python ?

2008-05-11 Thread Laszlo Nagy
Banibrata Dutta írta: Hi, Again a noob question. Based on this URL http://wiki.python.org/moin/DatabaseInterfaces , is it correct to conclude that there is no RDBMS agnostic, single/uniform DB access API for Python ? Something in the lines of JDBC for Java, DBD for Perl etc. ? How is the

Re: Submitting data to HTTPS javascript

2008-05-14 Thread Laszlo Nagy
John Chandler wrote: I am trying to write a script to test certain functionality of a website that requires users to login. The login page is simple, a few pictures and two text bars (one for username and one for password). I tried logging in with webbrowser, but that did not work because the

Re: Recommended way to POST with cookies?

2008-05-15 Thread Laszlo Nagy
Gilles Ganault wrote: Hello According to Google, there seems to be several tools available, possibly deprecated, to download data from web pages by POSTing forms and save cookies to maintain state. I need to write a script under Windows with ActivePython 2.5.1.1 that would do this: 1.

Re: create window on panel

2008-05-15 Thread Laszlo Nagy
Jimmy wrote: Hi, all I have been trying to use wxPython to design a GUI that will be displayed on the panel on the top of desktop. that is when the program starts, it will dwell on the panel to display some dynamic information. can anyone tell me in wxPython how to do this? thanks! AFAIK it

Re: create window on panel

2008-05-15 Thread Laszlo Nagy
Thanks for your reply! I am using Linux+gnome. Actually, what I want is simply a text-region on the panel and display some dynamic information on it. Is it hard to do it ? Google is your friend! I searched for "gnome python panel" and the first hit was: http://www.onlamp.com/pub/a/python

Re: create window on panel

2008-05-15 Thread Laszlo Nagy
URL:http://www.daa.com.au/~james/software/pygtk/ / /It should be easy to read the docs, view the demo programs and create your own program. L thanks~ it seems attractive, however, I did not find much useful information :( http://www.pygtk.org/ -- full docs http://packages.ubuntu.com/

TPCServer and xdrlib

2008-05-16 Thread Laszlo Nagy
Hi All, I'm trying to write a multi threaded TPC server. I have used xmlrpc before for many purposes, but in this case this would not be efficient: - I have to send larger amounts of data, the overhead of converting to XML and parsing XML back would be too much pain - I have no clue how to

ply yacc lineno not working?

2008-05-16 Thread Laszlo Nagy
This is a fragment from my yacc file: import ply.yacc as yacc from lex import tokens from ast import * def p_msd(p): r"""msd : SCHEMA WORD LBRACE defs RBRACE """ p[0] = MSDSchema(p[2]) print p.lineno(5) # Line number of the right brace p[0].items = p[4] Here is a test input: "

Re: ply yacc lineno not working?

2008-05-16 Thread Laszlo Nagy
I'm sorry for the dumb question. I had to add these to the lexer: def t_comment(t): r"\#[^\n]*\n" t.lexer.lineno += 1 # We do not return anything - comments are ignored. # Define a rule so we can track line numbers def t_newline(t): r'\n+' t.lexer.lineno += len(t.value) Well, it

Re: TPCServer and xdrlib

2008-05-19 Thread Laszlo Nagy
It is possible to change the serialization used by Pyro http://pyro.sourceforge.net/manual/9-security.html#pickle to the the 'gnosis' XML Pickler. As I said earlier, I would not use XML. Just an example - I need to be able to transfer image files, word and excel documents. How silly it

Re: TPCServer and xdrlib

2008-05-19 Thread Laszlo Nagy
I'm trying to write a multi threaded TPC server. I have used xmlrpc How exactly did you come to the conclusion that your server must be multi threaded ? I don't think that it is important. But if you are interested: - yes, the server will probably be I/O bound, not CPU bound - I'm h

Re: TPCServer and xdrlib

2008-05-20 Thread Laszlo Nagy
- use simple file copying from a mounted network drive Untrustable clients should not mount out anything from my server. (Also, it is not a protocol. I need to communicate with a real program, not just copying files.) - use http (web server) I mentioned this before - don't know how to keep-a

Re: problem with import / namespace

2008-05-21 Thread Laszlo Nagy
ohad frand wrote: Hi I have a problem that the solution to it must be very simple but i couldnt fint it's answer in the internet so far (i searched for couple of days) the problme is as follows: i have two directories e.g. "\\1" and "\\2" in each directory i have two files with the same names

Re: problem with import / namespace

2008-05-21 Thread Laszlo Nagy
When you try to import a module, python starts to search for it. The was it does the search is very well defined. It mostly depends on the current directory and sys.path. You can read more about this here: "The was it" -> "The way it" - inside your app.py file either make sure that the curre

Re: problem with import / namespace

2008-05-21 Thread Laszlo Nagy
ohad frand wrote Hi Thanks for the answer. I probably didnt write the problem accurately but it is not as you described. (i already read before the section that you pointed and it didnt help me) the problem is that i dont want to import a file from different directory but only from the same di

Re: datetime.stdptime help

2008-05-28 Thread Laszlo Nagy
Out of curiosity -- just what zone /is/ "BDT"... The only thing that comes to mind is a type for "BST" (British Summer Time) I think you are right. This date string was taken from a .co.uk site. :-) My fault. It was a 3 letter code after a date, I was sure that it is a time zone. A

platypus in page header

2008-06-02 Thread Laszlo Nagy
Is it possible to use platypus in page header and footer? I need to create a document with long paragraphs but also I need to put tables and images in page header and multi line info in page footer with alignment etc. Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make one program connect to more than one TCP?

2008-06-04 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: The questions: I am using twisted to make program that can download IMAP email. after that, downloaded email is parsed, then posted to nntp server. my problem is how to make one progam connect to more than one tcp? Create more sockets, connect to the server multiple t

Re: How to kill a thread?

2008-06-06 Thread Laszlo Nagy
def run(self): while True: if exit_event.isSet(): # Thread exiting return try: data = q_in.get(timeout = .5)

<    1   2   3   4   5   >