IMAP4 SEARCH question

2006-12-08 Thread Laszlo Nagy
Hi, I'm using imaplib to access an IMAP4 server. I'm reading the IMAP4 specification, and I found something odd. The search command can be used in conjuction with date values. For example, I would like to search for messages that are older than 30 days. However, the IMAP4 specs does not def

Re: IMAP4 SEARCH question

2006-12-08 Thread Laszlo Nagy
Sorry, I found it: date= date-text / DQUOTE date-text DQUOTE date-day= 1*2DIGIT ; Day of month date-day-fixed = (SP DIGIT) / 2DIGIT ; Fixed-format version of date-day date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / "Jul" / "Aug" / "Sep" / "O

Re: IMAP4 SEARCH question

2006-12-08 Thread Laszlo Nagy
Laszlo Nagy wrote: Sorry, I found it: date= date-text / DQUOTE date-text DQUOTE date-day= 1*2DIGIT ; Day of month date-day-fixed = (SP DIGIT) / 2DIGIT ; Fixed-format version of date-day date-month = "Jan" / "Feb" / "Mar" / "Apr"

py-ldap question

2006-12-12 Thread Laszlo Nagy
Hello, I'm using the ldap module under Windows. This is the error that I get: import ldap l = ldap.initialize("ldaps://neptunus.msnet:636") l.simple_bind_s("cn=gandalf,ou=Users,dc=neptunus,dc=msnet","gandalf") l.search_s("ou=AddressBooks,dc=neptunus,dc=msnet", ldap.SCOPE_SUBTREE, "objectclass=

Re: py-ldap question

2006-12-12 Thread Laszlo Nagy
By the way, I already tried the set_option function, but I still get the same error. import ldap import local ldap.set_option(ldap.OPT_X_TLS_ALLOW,1) ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,0) ldap.set_option(ldap.OPT_X_TLS_CERTFILE,local.LDAP_CACERTFILE) ldap.set_option(ldap.OPT_X_TLS_CACE

Validate XML against a set of XSD files, with Python

2006-12-12 Thread Laszlo Nagy
Do you know an open source lib that can do $subject? Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list

Re: Validate XML against a set of XSD files, with Python

2006-12-13 Thread Laszlo Nagy
> Fast google query, uncheked, leads to: > > - XSV: http://www.ltg.ed.ac.uk/~ht/xsv-status.html > I tried this before. Unfortunately, xsv is not officially supported on my system (FreeBSD 6.1) :-( > - libxml : http://codespeak.net/lxml/ > Probably this is what I need to use. (However, I

SPE website down?

2006-12-14 Thread Laszlo Nagy
The home page of SPE (Stani's editor) is not available. http://pythonide.stani.be/ Is there a mailing list for this editor? Where should I ask questions about it? Where can I report bugs and make suggestions? Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list

Stani's Python Editor - questions

2006-12-20 Thread Laszlo Nagy
Hello, I was trying to get answers for these. SPE homepage was down. Then I found it on berlios (http://developer.berlios.de/forum/forum.php?forum_id=12695) but no one answered since 5 days. In fact nobody seems to write in anything to that forum, I presume it is dead. I have no other choic

Re: rsync for python?

2006-12-21 Thread Laszlo Nagy
nienfeng írta: > Hi, everyone > > I want to build rsync server that can run in linux and windows, and > configure by python. So I'm looking for something like rsync for python. > I find rsync.py and pysync. But rsync.py looks like a client mode, > it can't be a rsync server, is it? Can py

Re: Stani's Python Editor - questions

2006-12-21 Thread Laszlo Nagy
>> 1. How can I navigate between opened files? Usually I open 10 or more >> files at the same time. There is no way to quickly scroll the tabs and >> select the one that I want. Tabs simply run out of my screen. >> > > Normally with ctrl-tab, ctrl-shift-tab, ctrl-f6 ctrl-shift-f6 (at least

Re: How to return a simple variable from a function (still newbie) ?

2006-12-28 Thread Laszlo Nagy
> You should also think long and hard about *why* you want to return a > value from a function by modifying an input parameter instead of just > using the return statement. The "return by modifying an input parameter" > approach comes from C where that's the only way to return more than one > valu

Re: db access

2006-12-28 Thread Laszlo Nagy
king kikapu írta: > Hey Martin, > > thanks for the fast reply! > > I have already seen that link and i just downloaded the pyodbc module > but isn't Python already containing a "built-in" odbc module so to > allow for db communication ?? > There is no built-in ODBC module. We all know that Pytho

wsdl2py question

2007-01-02 Thread Laszlo Nagy
Hi All! I just installed ZSI and tried to generate client code for a wsdl. Here is the exception I got: Traceback (most recent call last): File "/usr/local/bin/wsdl2py", line 9, in ? wsdl2py() File "/usr/local/lib/python2.4/site-packages/ZSI/generate/commands.py", line 222, in wsdl2py

Re: find a .py path

2007-01-05 Thread Laszlo Nagy
hg i'rta: > Hi, > > Is there an easy way for a script being executed (from anywhere) to know > where is is ... something in os.path ? > __file__ You can also use os.argv[0] but that is not the same... Laszlo -- http://mail.python.org/mailman/listinfo/python-list

Re: find a .py path

2007-01-05 Thread Laszlo Nagy
hg írta: > hg wrote: > > >> Hi, >> >> Is there an easy way for a script being executed (from anywhere) to know >> where is is ... something in os.path ? >> >> Thanks, >> >> hg >> > > oops: os.path.abspath(sys.argv[0]) > Be aware with this. It is different when you do /usr/bin/python pr

Re: importing / loading a module / class dynamically

2007-01-05 Thread Laszlo Nagy
> .../.../../plugin/name1/name1.py > > .../.../../plugin/namen/namen.py > > > I block at the beginning and tried this (test.py is a real file) > s = 'test.py' eval ('import ' + s) import test.py # This is invalid import test # This MAY be valid import name1.name1 #

Re: importing / loading a module / class dynamically

2007-01-05 Thread Laszlo Nagy
hg írta: > hg wrote: > > >> Hi, >> >> I have the following problem. >> >> I find in a directory hierarchy some files following a certain sets of >> rules: >> >> .../.../../plugin/name1/name1.py >> >> .../.../../plugin/namen/namen.py >> >> each file will in turn have a class with the same na

Re: Just Getting Started with Python on MS XP Pro

2007-01-05 Thread Laszlo Nagy
W. Watson wrote: > What do I download to use Python with MX XP Pro on an ASUS 4 year old > motherboard? I would guess a good book source for starters would be the > O'Reilly book. > You mean Microsoft XP Pro? For a beginner, the motherboard does not really matter. First of all, you should do

Re: importing / loading a module / class dynamically

2007-01-05 Thread Laszlo Nagy
> Thanks, > > What I am doing is adding plugin support to PyCrust ... so I'm looking for a > mechanism where anyone can develop a plugin and have it loaded by pycrust. > > the .py was a typo > > > why the "...Have at least an empty plugin/name1/__init__.py file..." ? > When you do import plug

Re: program deployment

2007-01-05 Thread Laszlo Nagy
> hehehe, but what I am thinking: Is it somehow possible to _really_ hide > the source from being viewed by other persons when using python? Not > that I want to do that ( I am an Open Source friend ), but that might > get others that rely on that (commercial) to use python for more > projects as

Re: (newbie) Is there a way to prevent "name redundancy" in OOP ?

2007-01-05 Thread Laszlo Nagy
Stef Mientki wrote: > Not sure I wrote the subject line correct, > but the examples might explain if not clear > > > *** first attempt *** > class pin: >def __init__ (self): > self.Name = 'Unknown Pin' > > aap = pin() # create an instance > aap.Name = 'aap'# set it's n

Re: Parallel Python

2007-01-08 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: > Has anybody tried to run parallel python applications? > It appears that if your application is computation-bound using 'thread' > or 'threading' modules will not get you any speedup. That is because > python interpreter uses GIL(Global Interpreter Lock) for internal > bo

Re: xmlrpc and auth-digest

2007-01-08 Thread Laszlo Nagy
Thomas Liesner írta: > Hi all, > > this may have been asked before, but as a newbie with xmlrpc i can't > find any suitable info on that. Sorry. > I am trying to write a simple xmlrpc-client in python and the server i > am trying to receive data from requires http auth digest. > The info on xmlrpcl

Re: How to write temporary data to file?

2007-01-09 Thread Laszlo Nagy
Thomas Ploch írta: > Hi folks, > > I have a data structure that looks like this: > > d = { > 'url1': { > 'emails': ['a', 'b', 'c',...], > 'matches': ['d', 'e', 'f',...] > }, > 'url2': {... > } > > This dictionary will get _very_ big, so I want to write

Re: A simple array in Python

2007-01-09 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: > Hi, > > I have the following enum - > > class State: > Fire = 0 > Water = 1 > Earth = 2 > > And I want a variable which holds a value for each of these states, > something like - > class State: Fire = 0 Water = 1 Earth = 2 m

Re: Question about using "with"

2007-01-09 Thread Laszlo Nagy
> > 591 > ./cat.py cat.py >File "./cat.py", line 6 > with open(sys.argv[nn]) as f: > ^ > SyntaxError: invalid syntax > 592 > > > This example came from http://docs.python.org/tut/node10.html down in > section 8.7 > > Am I missing something? > Are you using python 2.5? The

Re: how to clean sys.path

2007-01-09 Thread Laszlo Nagy
> > So far, I know only the command >>>sys.path.append(r'c:etc...'), but how > to delete or insert at the beginning of the list, I know not. > You can delete a slice. For example, del sys.path[2:5] More about slicing: http://docs.python.org/ref/slicings.html sys.path is a regular list. L

Re: Non-blocking keyboard read

2007-06-26 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: > I am writing a curses application, but the getch() does not seem to > give me all I want. Of course, if I press "d", it returns an ord("d") > and so on. But I want to be able to detect whether alt, shift or ctrl > has been pressed also. Shift is normally covered by return

Re: Reading a file and resuming reading.

2007-05-25 Thread Laszlo Nagy
Karim Ali wrote: > Hi, > > Simple question. Is it possible in python to write code of the type: > > - > while not eof <- really want the EOF and not just an empty line! > readline by line > end while; > - > > What I am using now is the im

pexpect/termios error: Inappropriate ioctl for device

2007-05-31 Thread Laszlo Nagy
Hi All, I have a python program that downloads database backups from a remote server, and tries to replace the local database with the downloaded backup. The database is a PostgreSQL server and my program calls the pg_restore command with the aid of the wonderful pexpect module. Everything wo

Re: advice about `correct' use of decorator

2007-08-16 Thread Laszlo Nagy
Gerardo Herzig wrote: > Hi all. I guess i have a conceptual question: > Im planing using a quite simple decorator to be used as a conditional > for the execution of the function. I mean something like that: > > @is_logued_in > def change_pass(): > bla > bla > > And so on for all the other

Re: advice about `correct' use of decorator

2007-08-17 Thread Laszlo Nagy
>> >> Are you developing a website or a GUI program? >> >> > It will be used in a web development. It is an important point? Yes, I think. Unless you use AJAX. :-) Most web sites work this way: user clicks -> request to server -> process on server -> response I would rather enclose the whole han

Re: Problem with directory recursion!

2007-08-17 Thread Laszlo Nagy
> > Does anyone see anything immediately suspicious about the code? Yes. os.walk does the recursion for you. Either you should use os.listdir instead of os.walk, or use os.walk ONCE and iterate over the results. I prefer to use the former because usually I do not remember how os.walk works. Re

Re: Encryption and hashing

2007-08-17 Thread Laszlo Nagy
> For who knows any of criptography I comment that you can use > algorithms as secure as Rijndael, Twofish, or Serpent with the CFB > cipher mode. And for hash you can use RIPEMD, SHA-2 or WHIRLPOOL. > As I recall, PyCrypto can also use these, and many others. And it can also do RSA. > And the

Re: Encryption and hashing

2007-08-18 Thread Laszlo Nagy
> These are the algorithms supported in the last version of PyCrypto: > > $ ls pycrypto-2.0.1/src/ > AES.c Blowfish.c DES.cIDEA.c > RIPEMD.c winrand.c > ARC2.ccast5.c _dsa.c MD2.c > _rsa.c XOR.c > ARC4.cCAST.c

Re: 2 python questions!

2007-09-06 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: > Hi python community! > First question has to do with threading support. There is the > following simple case: > I have a dictionnary that gets it's values -which are url's-from a > function. Sort of > > dictionnary['1'] = "http://www.google.com"; > dictionnary['2'] = "h

Re: library to launch program in linux

2007-09-06 Thread Laszlo Nagy
Grant Edwards wrote: > On 2007-09-06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >> I'm a new user. What library should I use so that I can launch >> program in linux using python? Thank you in advance. >> > > subprocess > Hmm, there are some others. Here is a list: os.system os.p

Question about PEP 8

2007-09-10 Thread Laszlo Nagy
Hi All, Here is what I read in PEP 8: > Package and Module Names > > Modules should have short, all-lowercase names. Underscores can be used > in the module name if it improves readability. Python packages should > also have short, all-lowercase names, although the use o

I want py2exe not to create library.zip

2007-09-12 Thread Laszlo Nagy
Hi, I want py2exe not to create library.zip. My reason is that the installed program will be a self updating program, and it must be able to download changes (newer python source files) from the server. So the files should not be in library.zip. I tried the --bundle option but apparently it

Re: I want py2exe not to create library.zip

2007-09-13 Thread Laszlo Nagy
>> I want py2exe not to create library.zip. >> > > setup ( >[...] >options = {"py2exe": {"skip_archive":1}} > ) > Cool! Just what I needed. Where it is documented? Ah, in the source. :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: I want py2exe not to create library.zip

2007-09-13 Thread Laszlo Nagy
> That is correct. People want less files to distribute not more. People > complain on py2exe list that it doesn't create a single .EXE file. Don't > try to update the program via patching "pieces". Wrap everything in a proper > installer (I use and highly recommend Inno Setup). It can hand

wx.ToplevelWindow.SetIcon: Native MS Windows error dialog pops up in wxPython app, no exception raised, no stack trace

2007-09-13 Thread Laszlo Nagy
Hello, I wrote a small program that works uses wxPython. The same application works on Linux and Windows. When I start it from MS Windows, I see this error message appearing each time I open a window: --- Warehouseclient Error --- Can't load im

Re: wx.ToplevelWindow.SetIcon: Native MS Windows error dialog pops up in wxPython app, no exception raised, no stack trace

2007-09-13 Thread Laszlo Nagy
> See main.py of the Demo, line 1129. img2py is in the following default > location: > C:\Python24\Lib\site-packages\wx-2.8-msw-unicode\wxPython\tools > > Without seeing how you create the image, it's hard to troubleshoot, > but I would guess that you have an absolute path that you're using in

Find the path of a running .py program

2007-03-12 Thread Laszlo Nagy
Hi All! There was a thread here, more than a month ago. It was about finding the path of a .py file. I suggested os.abspath(__file__). Others told that sys.argv[0] is better. I was not sure why I did not like that solution. Now I ran into the problem again, and I now I remember what is the

Re: ZSI, SOAP and .NET web services - problem

2007-03-22 Thread Laszlo Nagy
> I tried to use different library - SOAPpy, but I couldn't. It requires > fpconst library which cannot be installed because its server does not > respond at all. What a shit... > I concur! When I tried to use ZSI the first time, it turned out it has no support for attachments. Next time I it

Re: SimpleXMLRPCServer and Threading

2007-03-29 Thread Laszlo Nagy
Jeff McNeil wrote: > This is off of memory so I apologize if I don't get all of the details right. > > The base SimpleXMLRPCServer uses TCPServer as it's server component > and SimpleXMLXMLRPCRequestHandler as it's handler. The handler is a > subclass of BaseHTTPRequestHandler, which itself doesn't

Windows service and pyc files

2007-04-04 Thread Laszlo Nagy
Hello, I have a win32 service written in Python that starts a plain application, written in Python. The win32 service tries to launch the application in a while loop and logs the return value of the os.system call. That's all. The application is a simple Python program that connects to an ht

Re: calling super()

2007-04-04 Thread Laszlo Nagy
> And here's the error message I get: > > Traceback (most recent call last): > File "e:/PyEN/inherit.py", line 16, in > N = NewPage(); > File "e:/PyEN/inherit.py", line 12, in __init__ > super(NewPage, self).__init__(); > TypeError: super() argument 1 must be type, not classobj > S

Re: calling super()

2007-04-04 Thread Laszlo Nagy
Jarek Zgoda wrote: >> Hello, I have been trying to call the super constructor from my >> derived class but its not working as expected. See the code: >> >> class HTMLMain: >> def __init__(self): >> self.text = ""; >> print(self.text); >> def __del__(self): >> self.te

Re: Windows service and pyc files

2007-04-05 Thread Laszlo Nagy
> > Have you tried the subprocess module for this rather than os.system? > You might be able to pipe errors to a file with it. You might be able > to use the traceback module for more verbose error catching too. > Okay, I'm tried this instead of os.system: def dumpexc(e): import sys,traceback,

Re: Windows service and pyc files

2007-04-05 Thread Laszlo Nagy
> When I call spawn() from a service, this is written into the logfile: > > 2007-04-05 17:52:53,828 INFO .Spawner Spawing > ['C:\\Python25\\lib\\site-packages\\win32\\PythonService.exe', > 'T:\\Python\\Projects\\Test\\Application.py'] > 2007-04-05 17:52:53,828 ERROR .Spawner Traceback (most rece

Re: Windows service and pyc files

2007-04-05 Thread Laszlo Nagy
>> 1. subprocess.Popen cannot redirect stderr and stdout when called from a >> win32 service. This is not documented, and makes debugging almost >> impossible. >> > > Without the patch menctioned in my previous message, you must redirect all > stdin, stdout AND stderr (because the child can

Re: Windows service and pyc files

2007-04-05 Thread Laszlo Nagy
> With a bit of guessing, I think I've found what's happening. > Since you don't provide a value for stdin, None is used. Inside > subprocess.py, method _get_handles, line 670, GetStdHandle *may* return > None; in that case _make_inheritable fails. > If you print the value of p2cread in line 6

convert html entities into real chars

2007-04-10 Thread Laszlo Nagy
Hi, I would like to have a function that can convert '>' into '>', '&' into '&' etc. I could not find how to do it easily (I have a code snippet for the opposite). Thanks, Laszlo -- http://mail.python.org/mailman/listinfo/python-list

Re: convert html entities into real chars

2007-04-10 Thread Laszlo Nagy
> I would like to have a function that can convert '>' into '>', > '&' into '&' etc. I could not find how to do it easily (I have a > code snippet for the opposite). Found it, sorry def convertentity(m): """Convert a HTML entity into normal string (ISO-8859-1)""" if m.group(1)=='#':

Re: calling super()

2007-04-11 Thread Laszlo Nagy
John Clark wrote: > Please be aware that super() has it's own set of gotchas - it's not as clean > as you would hope. For more info: http://fuhm.org/super-harmful/ > > (I'm not the author, I was referred to this article while struggling with > wxPython and super()) > This was interesting! I'm u

Re: ValueError: too many values to unpack

2007-04-11 Thread Laszlo Nagy
fscked írta: > Trying to use CSV to read in a line with 11 fields and I keep getting > this error. I have googled a bit and have been unable to figure it out. > > Probably you have more than 11 values in some (or all) of the rows in the CSV file. Try this code: L = (1,2,3,4,5) a1,a2,a3 = L If

Re: how to pickle objects for database storage?

2007-04-11 Thread Laszlo Nagy
krishnakant Mane írta: > hello, > I have a strange but very interesting requirement? > provided that a database can provide for an object data type like > binary large object (blob), can I store a pickeled python object in > it? > Why not? > I know oracle has blob and clob and believe that mysql

Re: how to pickle objects for database storage?

2007-04-11 Thread Laszlo Nagy
Laszlo Nagy írta: > krishnakant Mane írta: > >> hello, >> I have a strange but very interesting requirement? >> provided that a database can provide for an object data type like >> binary large object (blob), can I store a pickeled python object in >> it? >

Re: ValueError: too many values to unpack

2007-04-11 Thread Laszlo Nagy
> Hmm, well I have counted the fields in the CSV and verified there are > only 11. Here is the offending code: > > Try this instead: lineno = 0 for values in csvreader: try: lineno += 1 boxid, mac, activated, hw_ver, sw_ver, heartbeat, name, address,phone, country, ci

Re: Inconsistent result from urllib.urlopen

2007-04-12 Thread Laszlo Nagy
> Any ideas why I don't get the same result from the python script as I > do from a web browser? This problem seems to be a recent > development. The scripts I wrote like this worked fine for a while > and then stopped working within the past couple of weeks. > Maybe it has to do something wi

gdbm objects not iterable?

2007-10-03 Thread Laszlo Nagy
Hi All, gdbm objects have a "firstkey" and a "nextkey" method. So if I want iterate through the keys (which I often do) then I have to do this: def itergdbmkeys(gdbm_obj): key = gdbm_obj.firstkey() if key is None: raise StopIteration yield key while True: key =

Re: gdbm objects not iterable?

2007-10-03 Thread Laszlo Nagy
>> >> I know that this is a very small change, but it can make gdbm objects >> look more like dictionaries. >> >> Please make comments. :-) >> >> > What you would need is a method to *create and return* a generator, and > it's the generator that should have the next() method. Otherwise you

Re: gdbm objects not iterable?

2007-10-03 Thread Laszlo Nagy
>> E.g. I would not allow to change the keys of the gdbm object during >> iteration. I'm not sure how to detect "end of iteration" though. >> >> (Maybe I misunderstood your question.) >> >> > All I meant was that it's essential to trap this condition. > Dictionary size change is easy to d

Re: Static variable vs Class variable

2007-10-09 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: > Hi. > > I've got a question on the differences and how to define static and > class variables. AFAIK, class methods are the ones which receives the > class itself as an argument, while static methods are the one which > runs statically with the defining class. > > Hence,

Re: Static variable vs Class variable

2007-10-09 Thread Laszlo Nagy
> Your question "is variable a > static or class variable?" has no real answer. After running the > increment() method on a descendant class, e.g. Child1 will rebind the > name Child1.a, creating a new name in the namespace of the class. So the > variable Foo.a is still there, but you are acce

Re: Static variable vs Class variable

2007-10-09 Thread Laszlo Nagy
Steven D'Aprano wrote: > On Tue, 09 Oct 2007 19:23:37 +0200, Diez B. Roggisch wrote: > > >> Your believes aside, this is simply wrong. The statement >> >> a += x >> >> always leads to a rebinding of a to the result of the operation +. >> > > Not true. > Hmm. Or you can write __iadd__ to

Re: Static variable vs Class variable

2007-10-10 Thread Laszlo Nagy
Steven D'Aprano írta: > On Tue, 09 Oct 2007 21:25:38 +0200, Laszlo Nagy wrote: > > >> a = 1 >> a+= 1 # The compiler will probably optimize this and the Python bytecode >> interpreter will not rebind 'a' here, just increment the integer in >> me

Re: gdbm troubles.

2007-10-11 Thread Laszlo Nagy
Shriphani wrote: > dictionary = gdbm.open('dictionary','c') > dictionary['Ellipsize'] = 'Openbox' > dictionary.get('Ellipsize') > Try this: print dictionary['Ellipsize'] del dictionary['Ellipsize'] gdbm objects are similar to builtin dictionaries. By the way, they are not iterable, but they

Re: Problem with PEXPECT in Python

2007-10-23 Thread Laszlo Nagy
> > > > > cmd ='scp'+' '+source_file+' '+user+'@'+ip+':'+desti_path > You might wanna try to login with a public/private key pair, then scp won't ask for a password. -- http://mail.python.org/mailman/listinfo/python-list

Re: context managers and generators

2007-01-12 Thread Laszlo Nagy
> I'm still thinking there is a better way to do it, and would appreciate > any ideas. > Everything can be implemented with goto and arrays. http://entrian.com/goto/ :-P -- http://mail.python.org/mailman/listinfo/python-list

Re: closing a "forever" Server Socket

2007-01-22 Thread Laszlo Nagy
alessandro írta: > thanks > > infact the server_forever() method is only a serve() method inside an > infinite loop. > > many thanks again, > Here is a snipped that show a "software terminateable threading TCP socker server". The "server" object is a SocketServer instance, server_stopped is a

Re: closing a "forever" Server Socket

2007-01-22 Thread Laszlo Nagy
alessandro írta: > Oh my God! it's really so complicated? > > 3 modules (threading, SocketServer, select) only for design a way to > shutdown a TCP server > ...but they told me that python was easy... :) > I believe that SockerServer was created for testing purposes, although there are some

Re: mmap caching

2007-01-22 Thread Laszlo Nagy
> In fact, memory that is read in because of mmap should *never* cause > a MemoryError. This is certainly not true. You can run out of virtual address space by reading data from a memory mapped file. > Python calls MapViewOfFile when mmap.mmap is invoked, > at which point the operating commits t

Re: mmap caching

2007-01-22 Thread Laszlo Nagy
> It's around 400MB. As I said, I cannot reproduce the MemoryError > locally since I have 1GB physical space but IIRC the user who reported > it had less. Actually I am less concerned about whether a MemoryError > is raised or not in this case and more about the fact that even if > there's no exce

urllib2 question

2007-01-23 Thread Laszlo Nagy
Hi All, I would like to save a URL into a file. I need to manage cookies and use my own HTTP headers so I'm using urllib2 and a custom openerdirector. Here is a code fragment: while True: data = openerdirector.read(1024)

Re: Two dimensional lists

2007-01-25 Thread Laszlo Nagy
> # shouldn't I be able to fill the lists simply by pointing to a location? > > matrix[a_idx, p_idx] = 0x219 # and so on? > Lists are not matrices. For example: L = [ [1,2,3], ['a','b','c'], 10 ] print L[1][2] # Prints 'c', you will like this syntax but... print L[2][5] # TypeError: 10 is not

Re: Random passwords generation (Python vs Perl) =)

2007-01-29 Thread Laszlo Nagy
NoName írta: > Hmmm.. > In the Perl example password generates after user hit ENTER not > continously like in Python you wrote... :) > > i want see various ways to generate passwords even if they some > indirect like using BASE64 > I copied this from a recipe, I do not remember which one. I li

Re: Python tools to manipulate JARs ?

2007-01-31 Thread Laszlo Nagy
Andy Dingley írta: > I run build processes for a Java shop using Python (and some Ant). > > Would anyone care to suggest favoured tools for manipulating the > innards of JARs? Or do I just treat them as plain zipfiles and get > stuck right in there? > > Mainly I'm trying to query lists of classes a

Re: Newbie question: replacing nulls in CSV with preceding value

2007-02-01 Thread Laszlo Nagy
> import csv > citynew='' > reader = csv.DictReader(open("/home/mwaite/test/test2.csv", "rb")) > for row in reader: > row['CITY'] == citynew > else: > citynew=row['CITY'] > > The logic here -- in this case trying to fill in the city information > -- would seem to work, but I'm not sure. An

_ssl.pyd is buggy?

2007-02-13 Thread Laszlo Nagy
Hello, I wrote a small program that uses xmlrpc over https. It should work as a win32 application and as a win32 service too. There is a file called Processor.py that contains the main thread of the program. It is called from two files: win32_Application.py and win32_Service.py. The applic

Re: _ssl.pyd is buggy?

2007-02-13 Thread Laszlo Nagy
> I was using _ssl.pyd to upload files to DAV server over ssl and > found it to be a problem. I upgraded to Python 2.5 and the problem > was fixed. I don't know if it is the same problem that is affecting > you, but I couldn't get it to work on 2.4. > > FYI, Larry > I just installed Python 2

Re: _ssl.pyd is buggy?

2007-02-13 Thread Laszlo Nagy
> Services usually run under the LOCAL_SERVICE account, which is rather > limited on what it is allowed to do (It has no access to network shares, > by example). Perhaps this is afecting your program. > I'm sorry, it is not. My service only uses the standard output, writes into different f

metaclasses (beginner question)

2007-02-21 Thread Laszlo Nagy
Hello, I would like to create a hierarchy classes, where the leaves have a special attribute called "producer_id". In addition, I would like to have a function that can give me back the class assigned to any producer_id value. I tried to implement this with a metaclass, but I failed. Pleas

Re: metaclasses (beginner question)

2007-02-21 Thread Laszlo Nagy
> Without looking into the details -- the (subclass of) type is meant to be > the class of the class, or the other way round, your normal classes are > instances of (a subclass of) type. You determine the factory Python uses to > make a class by adding > > __metaclass__ = factory > > to the class

Re: pydoc - generating HTML docs from string input

2007-11-07 Thread Laszlo Nagy
[EMAIL PROTECTED] wrote: > Has anyone ever tried mucking with pydoc to the point where you can > get it to give you output from a string input? For example I'd like > to give it a whole module to generate documentation for but all within > a string: > > #little sample > > module_code=''' > """Modu

Re: Python-URL! - weekly Python news and links (Nov 12)

2007-11-12 Thread Laszlo Nagy
Gabriel Genellina wrote: > QOTW: "AOP is a programming paradigm in the same way indie is a genre of > film." - Carl Banks > http://groups.google.com/group/comp.lang.python/msg/224e922a3e1a8638 > I was following links and hit PEP 246 here: http://www.python.org/dev/peps/pep-0246/ On that

Re: Override method name and original method access

2007-11-12 Thread Laszlo Nagy
Donn Ingle wrote: > In an unusual twist of code I have a subclass which overrides a method but > it also needs to call the original method: > > class One: > def add (self, stuff): > self.stuff.append(stuff) > > class Two(One): > def __init__(self, otherstuff): > (otherstuff) #otherstuff must

Re: Transfer socket connection between programs

2007-11-12 Thread Laszlo Nagy
JamesHoward wrote: > Does anyone know any method to have one program, acting as a server > transfer a socket connection to another program? I looked into > transferring the connection via xml rpc to no avail. It seems to be a > problem of getting access to a programs private memory space and > gi

Re: imaplib unexpected error

2007-11-12 Thread Laszlo Nagy
KeefTM wrote: > Hello, I am getting an odd error when trying to establish an IMAP > connection: > > File "/Library/Frameworks/Python.framework/Versions/2.4//lib/python2.4/ > imaplib.py", line 904, in _get_response > raise self.abort("unexpected response: '%s'" % resp) > imaplib.abort: unexpecte

Re: Issue with wxPython GUI

2007-11-12 Thread Laszlo Nagy
> > *New Problem: *I am opening and executing a script from the GUI. The > script has a many log messages, > which it posts on some shared memory. The GUI reads the messages from > the shared memory, > in the Idle loop. But the script is huge and so the logging is not > run-time. > Rather this

Re: Issue with wxPython GUI

2007-11-13 Thread Laszlo Nagy
tarun írta: > Hi Laszlo Nagy, > > Thanks a lot. > But the issue over here is that how will the child thread acknowledge > the main thread that it has completed its task. For this I'll have to > set some flag in the child thread and poll for it in the main thread. >

Re: Issue with wxPython GUI

2007-11-13 Thread Laszlo Nagy
tarun wrote: > Thanks a lot Laszlo Nagy, > > I used the following and it worked. I thought this is a producer/consumer scenario, this is why I suggested the Queue class. But now I see that you only want to compute one value in your thread and stop it afterwards. In fact using a wx.P

Re: Creating Installer or Executable in Python

2007-11-14 Thread Laszlo Nagy
DanielJohnson wrote: > I have a small project which has around 10 .py files and I run this > project using command line arguments. I have to distribute this > project to somebody. > > I was wondering how can I make an executable or some kind of > installer, so that end user doesn't need to compile

Re: Volume id

2007-11-15 Thread Laszlo Nagy
Gabor Urban wrote: > Hi, > > I have a problem, which may be trivial, but I could not find an answer. > > I have to write a Python script, which does a directory tree walking > on given mounted disk. But I do need to extract the volume id, > somehow. And that's the problem. An additional issue, t

Re: how to figure out if python was used as a cgi script

2007-11-15 Thread Laszlo Nagy
ce wrote: > hi, > > is there a way to figure out which scripting language was used in a > cgi. I used to watch extensions (i.e. py, pl, asp or php) nowadays i > hardly see any extensions and really it is hard to find out anything > from the generated HTML or even the HTML being sent out through the

Re: securing a python execution environment...

2007-11-19 Thread Laszlo Nagy
Chris Withers wrote: > Hi All, > > I'm trying to build a secure execution environment for bits of python > for two reasons: > > - to allow users of the system to write scripts in python without > circumventing the application's security model > > - to allow the system to have an environment where

Re: securing a python execution environment...

2007-11-19 Thread Laszlo Nagy
Alberto Berti wrote: > maybe using import hooks? > > http://www.python.org/dev/peps/pep-0302/ > > I don't think so. Anyone can hook the import statement. And this is just one reason. Some objects are built in. For example, file(). How can you restrict file creation? I believe that there is no

Re: How to add a Decorator to a Class Method

2007-11-20 Thread Laszlo Nagy
> Thanks those answers make sense. But for this function if defined > outside the class: > > >> def pre(fn): >> def new_func(*args, **kwargs): >> print "'hi'" >> fn(*args, **kwargs) >> return new_func >> > > Can new_func reference self? Would self just be one of t

<    1   2   3   4   5   >