Re: Difference between a library and a module...

2006-03-07 Thread Laszlo Zsolt Nagy
sophie_newbie wrote: OK this might seem like a retarded question, but what is the difference between a library and a module? If I do: import string am I importing a module or a library? I'm not a guru, but... I think that modules are things that live inside the Python language. In the

Re: Send email notification

2006-03-07 Thread Laszlo Zsolt Nagy
Ernesto wrote: Is there a special module for mail ? I'd like to send an email [to 'n' unique email addresses] from a python script. http://www.justfuckinggoogleit.com/search.pl?python+smtp -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert dictionary to HTTP POST

2006-03-05 Thread Laszlo Zsolt Nagy
The values of some inputs are encoded using html entities. How can I decode a string like Bessy#39;s cat in Bessy's cat? this snippet might help: http://effbot.org/zone/re-sub.htm#strip-html Thank you, worked like a charm. :-) Laszlo --

Re: Calculating md5 checksums.

2006-03-05 Thread Laszlo Zsolt Nagy
Rajesh Sathyamoorthy wrote: I tried the script and had to get a hexdigest to get the value provided My test: SimplyMEPIS-3.3.1-1.iso checksum: 41a19060d3bb37bd596708ba77964491 i got: 41a19060d3bb37bd596708ba77964491 Do people normally provide md5 checksum in a *hexadecimal string?

Convert dictionary to HTTP POST

2006-03-03 Thread Laszlo Zsolt Nagy
Hello, How can I convert a dictionary into a HTTP POST string? I have an example below, but this is not working correctly for special characters. ( ' and others). In other words, if I use Bessy's cat instead of Bessy then the http server will parse that to Bessy#39;s cat Probably the problem

Re: Convert dictionary to HTTP POST

2006-03-03 Thread Laszlo Zsolt Nagy
See urllib.urlencode(). No idea why they don't include it in urllib2 as well, but there you go. from urllib import urlencode urlencode({'a':' Simple string', 'b': '[EMAIL PROTECTED]*()_+='}) 'a=%26+%22Simple+string%22b=%3C%3E%21%40%23%24%25%5E%26%2A%28%29_%2B%3D' Hmm. urlencode is

Re: Convert dictionary to HTTP POST

2006-03-03 Thread Laszlo Zsolt Nagy
Well I don't understand what's encoding the apostrophe as an encoded entity anyway. That's only supposed to be done for HTML content, not form content. You are right. I was wrong. The problem was not with quote. It was reading out the VALUE of an INPUT from HTML source. How about an RE

Re: Numerical solver

2006-03-01 Thread Laszlo Zsolt Nagy
Robert Kern wrote: In [7]: scipy.optimize.fmin_cobyla? Type: function Base Class: type 'function' String Form:function fmin_cobyla at 0x4fff3b0 Namespace: Interactive File: /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/scipy-

Numerical solver

2006-02-28 Thread Laszlo Zsolt Nagy
Hello, I would like to use a numerical solver for a specific problem. My problem looks like this: 1. I have numeric constants, named A,B,C etc. 2. I have numeric variables, named x,y,z etc. 3. I have functions, like f1(x), f2(x), f3(x,y), f4(y) etc. 4. I have constraints like

Re: _bsddb on NetBSD

2006-01-17 Thread Laszlo Zsolt Nagy
Miki Tebeka wrote: Hello All, I can't seem to build Python2.4.2 with bsddb on NetBSD. bsddb seems to be missing from the pkg_add installation as well. Please look at the message that you get when you execute pkg_add -r python You will see that tkinter, bsddb, gdbm and some other libs are

Re: Developing a network protocol with Python

2005-12-15 Thread Laszlo Zsolt Nagy
Paul Rubin wrote: Laszlo Zsolt Nagy [EMAIL PROTECTED] writes: But how can I transfer pure python objects otherwise? Pyro also uses Pickle and it also transfers bytecode. Pyro in the past used pickle in an insecure way. I'd heard it had been fixed and I didn't realize it still uses

Re: Developing a network protocol with Python

2005-12-14 Thread Laszlo Zsolt Nagy
Try Pyro http://pyro.sourceforge.net before rolling your own Python-specific protocol. You are right. I wanted to use pyro before, because it is well tested and it has nice features. Unfortunately, it is not good for me. :-( I already have my own classes. My objects are in object ownership

Re: Developing a network protocol with Python

2005-12-14 Thread Laszlo Zsolt Nagy
Paul Rubin wrote: Laszlo Zsolt Nagy [EMAIL PROTECTED] writes: I already have my own classes. My objects are in object ownership trees, and they are referencing to each other (weakly and strongly). These classes have their own streaming methods, and they can be pickled safely. Standard

Re: Developing a network protocol with Python

2005-12-13 Thread Laszlo Zsolt Nagy
Tom Anderson wrote: I think to be effective, I need to use TCP_NODELAY, and manually buffered transfers. Why? Because of the big delays when sending small messages (size 1500 bytes). Personally, i'd steer clear of doing it like this, and try to use an existing, language-neutral

Re: instance + classmethod question

2005-12-12 Thread Laszlo Zsolt Nagy
Mike Meyer wrote: Laszlo Zsolt Nagy [EMAIL PROTECTED] writes: Is it possible to tell, which instance was used to call the classmethod that is currently running? Ok, I read through what got to my nntp server, and I'm still completely confused. A class method isn't necessarilry called

Developing a network protocol with Python

2005-12-12 Thread Laszlo Zsolt Nagy
Hello, I would like to develop a new network protocol, where the server and the clients are Python programs. I think to be effective, I need to use TCP_NODELAY, and manually buffered transfers. I would like to create a general messaging object that has methods like sendinteger recvinteger

instance + classmethod question

2005-12-11 Thread Laszlo Zsolt Nagy
Hello, Is it possible to tell, which instance was used to call the classmethod that is currently running? Background: I have a class called DatabaseConnection and it has a classmethod called process_create_tables. This method should create some database tables defined by a database

Re: instance + classmethod question

2005-12-11 Thread Laszlo Zsolt Nagy
method. All right, it is a ClassOrInstanceMethod. Amazing! Probably Python is the only language that is flexible enough to do this. :-) Thanks again! Laszlo Steven Bethard wrote: Laszlo Zsolt Nagy wrote: Hello, Is it possible to tell, which instance was used to call the classmethod

Re: How to ping in Python?

2005-12-07 Thread Laszlo Zsolt Nagy
Michael Schneider wrote: I telnet to port 13 (returns time) The problem is that most modern up-to-date servers use firewalls. They only open the ports that are absolutely necessary. Usually the time service is part of inetd, which is disabled by default, on most of the servers. PING ICMP may

Re: extract python install info from registry

2005-12-06 Thread Laszlo Zsolt Nagy
rbt wrote: On windows xp, is there an easy way to extract the information that Python added to the registry as it was installed? Using regedit.exe, look at the registry keys and values under HKEY_LOCAL_MACHINE\Software\Python If you need to know how to read the registry from Python: please

Re: extract python install info from registry

2005-12-06 Thread Laszlo Zsolt Nagy
There's more to it than that... isn't there? I've used _winreg and the win32 extensions in the past when working with the registry. I thought perhaps someone had already scripted something to extract this info. Ok, if you need to get all changes in the registry, you can use regdiff.

Re: windows installer problems

2005-12-06 Thread Laszlo Zsolt Nagy
[EMAIL PROTECTED] wrote: Hi, I'm trying to install Python on Windows 2000 Server using remote desktop. I log as a user that is in administrators group. Instalator starts, I select default installation directory, on the next screen with parts to install I click just next. Than blicks screen with

junk pointer ????

2005-12-06 Thread Laszlo Zsolt Nagy
Hi All, I got this while using Python 2.4 under FreeBSD 5.4: python in free(): warning: junk pointer, too high to make sense Segmentation fault (core dumped) What does it mean? Thanks, Les -- http://mail.python.org/mailman/listinfo/python-list

ZSI bug?

2005-12-05 Thread Laszlo Zsolt Nagy
Hi All, I'm trying to use ZSI (and SOAP) for the first time. I read somewhere that ZSI is the most compete SOAP implementation. I have ZSI-1.7 and PyXML-0.8.4. This very simple code: import ZSI fname = 'eBaySvc.wsdl' version = 421 url = 'http://developer.ebay.com/webservices/%s/%s' %

Re: IE Temporary Internet Files Python

2005-11-10 Thread Laszlo Zsolt Nagy
The script does not seem to work when used on Temporary Internet Files. Doesn't work well? What does it mean? Is there an exception raised? Les -- http://mail.python.org/mailman/listinfo/python-list

Re: html parser?

2005-10-19 Thread Laszlo Zsolt Nagy
Thorsten Kampe wrote: * Christoph Söllner (2005-10-18 12:20 +0100) right, that's what I was looking for. Thanks very much. For simple things like that BeautifulSoup might be overkill. import formatter, \ htmllib, \ urllib url = 'http://python.org' htmlp =

Re: html parser?

2005-10-18 Thread Laszlo Zsolt Nagy
Christoph Söllner wrote: Hi *, is there a html parser available, which could i.e. extract all links from a given text like that: a href=foo.php?param1=testBARimg src=none.gif/a a href=foo2.php?param1=testparam2=testBAR2/a and return a set of dicts like that: {

Outdated documentation

2005-10-17 Thread Laszlo Zsolt Nagy
Hi All, This is from the documentation of the dbhash module: Returns the key next key/value pair in a database traversal. The following code prints every key in the database |db|, without having to create a list in memory that contains them all: print db.first() for i in

Re: Need a spider library

2005-10-12 Thread Laszlo Zsolt Nagy
Fredrik Lundh wrote: Laszlo Zsolt Nagy wrote: The question: is there a good library for Python for extraction links and images out of (possibly malformed) HTML soucre code? http://www.crummy.com/software/BeautifulSoup/ Thanks a lot! This is just what I wanted. Why it is not part

Very dumb question

2005-10-12 Thread Laszlo Zsolt Nagy
I have a program with this code fragment: print len(data) print data[:50] raise SystemExit This prints: 20381 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN But if I change 50 to 51 print len(data) print data[:51] raise SystemExit then it prints 20381 !DOCTYPE html

Re: Very dumb question

2005-10-12 Thread Laszlo Zsolt Nagy
I assume the code snippets are exact copy/paste so this is not a typo (like print data[51:] ...) - and I can't reproduce it here... even with a string of 20381 characters. Yes, they were cut out. type(data) returns 'type str'. The data was downloaded from a website, it starts with !DOCTYPE

Re: Very dumb question

2005-10-12 Thread Laszlo Zsolt Nagy
i. e. a character after a 'carriage return' ('\r') overwrites part of the string which therefore doesn't seem to grow. Try print repr(data[:51]) to see what's really in your data string. Yes, that was it! Thanks for you help. I thought it will be something obvious. The server returned

Re: Send password over TCP connection

2005-10-11 Thread Laszlo Zsolt Nagy
dcrespo wrote: ¡Beautiful and elegant solution! Two copies of the password: one on the client, the other on the server. 1. Client wants to connect 2. Server generates a random_alphanumeric_string and sends it to the client 3. Both Client and Server creates a hash string from

Re: Send password over TCP connection

2005-10-11 Thread Laszlo Zsolt Nagy
Ignoring all the other issues, any solution which actually requires the password to be stored on the server is a bad solution. Administrators should not have access to user passwords, and in addition users should not be put in the position of having to trust your server-side security to keep

Re: Send password over TCP connection

2005-10-11 Thread Laszlo Zsolt Nagy
If you really want to do it right, use SRP, http://srp.stanford.edu. This is a bit offtopic here. I read the RFC and I do not see why SRP is not vulnerable to dictionary attacks. If I have a working client software then I can use it to reveal passwords. Isn't it a dictionary attack? Can you

Re: Send password over TCP connection

2005-10-11 Thread Laszlo Zsolt Nagy
Paul Rubin wrote: Laszlo Zsolt Nagy [EMAIL PROTECTED] writes: This is a bit offtopic here. I read the RFC and I do not see why SRP is not vulnerable to dictionary attacks. If I have a working client software then I can use it to reveal passwords. Isn't it a dictionary attack

Re: Send password over TCP connection

2005-10-11 Thread Laszlo Zsolt Nagy
If you're saying that people have no choice but to trust that their passwords, stored in the clear on the server of some idiot who didn't know better, are safe from casual administrator observation and safe from hackers stealing the password file, then you shouldn't be allowed anywhere near a

Re: Comparing lists

2005-10-10 Thread Laszlo Zsolt Nagy
Odd-R. wrote: I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and Y contains all the elements that are B but not in A. Z will then have the elements

Re: Send password over TCP connection

2005-10-10 Thread Laszlo Zsolt Nagy
How about an OTP (One Time Password) algorithm? It is described in RFC2289. http://www.faqs.org/rfcs/rfc2289.html I have a working implementation in Messlib. You can download it an look at the MessageSocket.SecureMessageSocket class. That is a modified version where a good random generator is

Re: Python's Performance

2005-10-08 Thread Laszlo Zsolt Nagy
Dave wrote: Hello All, I would like to gather some information on Python's runtime performance. As far as I understand, it deals with a lot of string objects. Does it require a lot string processing during program execution? How does it handle such time-consuming operations? Is there

Re: Help-log in to a web page

2005-10-06 Thread Laszlo Zsolt Nagy
Murugesh wrote: Hi all, I'm a newbie to python.I need to login to a webpage after supplying usename and password. import urllib sock = urllib.urlopen(http://xop-pc.main.com;) htmlSource = sock.read() sock.close() print

Class property (was: Class methods)

2005-10-06 Thread Laszlo Zsolt Nagy
Hughes, Chad O wrote: Is there any way to create a class method? I can create a class variable like this: Hmm, seeing this post, I have decided to implement a 'classproperty' descriptor. But I could not. This is what I imagined: class A(object): _x = 0 @classmethod def

Re: Help-log in to a web page

2005-10-06 Thread Laszlo Zsolt Nagy
I tried to view the source,it has, src=/em/cabo/images /t.gif height=80/tdtdtable align=center border=0 cellspacing=2 cellpadding=0tr id=username __xc_td align=right nowrapspan class=x8span title=Required class=xc*/spannbsp;*User Name/s pan/tdtd

Re: /usr/bin/env python, force a version

2005-10-06 Thread Laszlo Zsolt Nagy
[EMAIL PROTECTED] wrote: I've got a trouble, and i think that anybody there can help me I've got a python script which i distribute in somes packages for *nix. This script is full of python and need python 2.4 ! And i'd like to display a message when the user doesn't have a python2.4 version.

Re: /usr/bin/env python, force a version

2005-10-06 Thread Laszlo Zsolt Nagy
Roel Schroeven wrote: Laszlo Zsolt Nagy wrote: [EMAIL PROTECTED] wrote: I've got a trouble, and i think that anybody there can help me I've got a python script which i distribute in somes packages for *nix. This script is full of python and need python 2.4 ! And i'd like to display

Re: Class property

2005-10-06 Thread Laszlo Zsolt Nagy
Peter Otten wrote: Laszlo Zsolt Nagy wrote: I was trying for a while, but I could not implement a 'classproperty' function. Is it possible at all? You could define a normal property in the metaclass: The only way I could do this is: class MyXMetaClass(type): _x = 0 def

Re: Python, Mysql, insert NULL

2005-10-05 Thread Laszlo Zsolt Nagy
Python_it wrote: Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable string or NULL. Becaus i have a if statement: if

Re: Python, Mysql, insert NULL

2005-10-05 Thread Laszlo Zsolt Nagy
BTW, you did not write which driver are you using. Oh, you did. Sorry. :-( Import your DB module 'yourmodule' and then print yourmodule.paramstyle Description of paramstyle is also in PEP249: paramstyle String constant stating the type of parameter marker

Re: How to get the output from os.system() into a variable?

2005-10-05 Thread Laszlo Zsolt Nagy
alexLIGO wrote: Hi, I would like to execute some command in python on the bash, e.g. os.system('globus-job-run mike4.cct.lsu.edu/jobmanager-pbs -l /bin/date') and want the result of the output in a vector, so something like: result=python_command(' command_on_the_bash ') Is that possible?

Re: How to get the output from os.system() into a variable?

2005-10-05 Thread Laszlo Zsolt Nagy
result=python_command(' command_on_the_bash ') Is that possible? And how to do that? Check out the commands module. http://docs.python.org/lib/module-commands.html Hmm, I forgot this one. It is only working from UNIX, am I right? Les --

Re: change a value to NULL?

2005-10-05 Thread Laszlo Zsolt Nagy
Bell, Kevin wrote: I'm pulling a list of numbers from MS Excel, but occasionally if there is no data from excel, the value is an asterisk, but I need to make it null. What is the best way to do that? Thus far, I'm using: for value in myRange: try: intV = int(value)

Re: how to keep collection of existing instances and return one on instantiation

2005-10-05 Thread Laszlo Zsolt Nagy
I've removed all references to the object, except for the cache. Do I have to implement my own garbage collecting is or there some magical way of doing this within Python? I pretty much want to get rid of the cache as soon as there are no other references (other than the cache). Store weak

Re: Class methods

2005-10-05 Thread Laszlo Zsolt Nagy
Hughes, Chad O wrote: Is there any way to create a class method? I can create a class variable like this: ... Any ideas? Oh man, it has been a long time I have read such an disturbing question. RTMF here: http://docs.python.org/lib/built-in-funcs.html#l2h-14 Les --

Re: Class methods

2005-10-05 Thread Laszlo Zsolt Nagy
Oh man, it has been a long time I have read such an disturbing question. RTMF here: http://docs.python.org/lib/built-in-funcs.html#l2h-14 I feel I was a bit harsh. class A(object): x = 0 @classmethod def f(cls): cls.x += 1 print x is,cls.x A.f() x is 1

email module, redirecting to stdout

2005-10-04 Thread Laszlo Zsolt Nagy
Hello, I have this code: s = smtplib.SMTP() s.set_debuglevel(1) s.connect(host=smtp_host) s.set_debuglevel(0) log(Connected, sending e-mail) sys.stdout.flush() s.sendmail( consts.EMAIL_FROMADDRESS, [to],

Re: @staticmethod, backward compatibility?

2005-09-27 Thread Laszlo Zsolt Nagy
Neal Becker wrote: How can I write code to take advantage of new decorator syntax, while allowing backward compatibility? I almost want a preprocessor. #if PYTHON_VERSION = 2.4 @staticmethod ... Since python 2.4 will just choke on @staticmethod, how can I do this? Decorators are there

Re: Problem subclassing (Newbie)

2005-09-24 Thread Laszlo Zsolt Nagy
Then I have an instance of class Button called obj. My probelm is that the test isinstance(obj, Widget) resturns False! You must have a typo somewhere. Please try this little test program. class Widget(object): ... pass ... class Button(Widget): ... pass ... b = Button()

Re: Indexed variables

2005-09-22 Thread Laszlo Zsolt Nagy
a1=a2=0 def f(x): if x == a1: a1 = a1 + 1 elif x == a2: a2 = a2 + 1 Now if I call f with f(a2) only a1, of course, is incremented because the if-clause does only check for the value of the input and the values of a1 and a2 are identical. So how do I define the function

Re: Indexed variables

2005-09-22 Thread Laszlo Zsolt Nagy
If you really want to change an actual parameter inside an object, then inside a function, I mean -- http://mail.python.org/mailman/listinfo/python-list

Re: win32 service and time.sleep()

2005-09-20 Thread Laszlo Zsolt Nagy
rbt wrote: I have a win32 service written in Python. It works well. It sends a report of the status of the machine via email periodically. The one problem I have is this... while trying to send an email, the script loops until a send happens and then it breaks. Should it be unable to send, it

Where is my exception

2005-09-20 Thread Laszlo Zsolt Nagy
I have this code in a wxWidgets program: class HtmlHintWindow(wx.Frame): def __init__(self,pos,hint,config): global _current_hint_window # Determine the size of the screen self.screensize = wx.ClientDisplayRect()[2:] # Calculate the size of the hint ;-)

Re: testing a website from python

2005-09-20 Thread Laszlo Zsolt Nagy
M.N.A.Smadi wrote: hi; I just want to test that a given website is up or not from a python script. I thought of using wget as an os command. Any better ideas? urllib http://www.python.org/doc/current/lib/module-urllib.html If you only want to test if the HTTP port is open or not:

Re: Where is my exception

2005-09-20 Thread Laszlo Zsolt Nagy
The program prints out point 1 but it does not print point 2. What am I missing? Sorry from all. I should have been looked at the processor before I posted. There is no exception. It was an infinite loop inside the try block, but it was called from an event handler. I did not notice that

Re: Python Doc Problem Example: os.path.split

2005-09-18 Thread Laszlo Zsolt Nagy
is the doc writer, trying to write the doc with some austereness, but is confused about the behavior of split, or confused about expressing it? Did his pretension fucked him up? Dear Xah Lee, The Python community is very sorry because we have a very bad documentation. You are right. The

Re: How to clear screen in Python interactive shell mode?

2005-09-16 Thread Laszlo Zsolt Nagy
A. L. wrote: In Python interactive mode, is there some function acting like 'clear' command in bash? Could somebody here give some advice? Under Linux/UNIX system (on x86 at least) you can use the CTRL+L combination to clear the screen. I do not now similar for Windows and MACs. Les --

Re: Self reordering list in Python

2005-09-16 Thread Laszlo Zsolt Nagy
I wonder why you don't use a dictionary? The only time I used a move-front algorithm I stored algorithms and had to evaluate a condition to select the correct algo. That means no constant search key was available for accessing the correct one. In case of an image list I would implement a

Self reordering list in Python

2005-09-15 Thread Laszlo Zsolt Nagy
Hello, Do you know how to implement a really efficient self reordering list in Python? (List with a maximum length. When an item is processed, it becomes the first element in the list.) I would like to use this for caching of rendered images. Of course I could implement this in pure

Distutils question

2005-09-08 Thread Laszlo Zsolt Nagy
How how can I install my .mo files from a distutil script into its default location? sys.prefix + os.sep + 'share' + os.sep + 'locale' -- http://mail.python.org/mailman/listinfo/python-list

Re: popen in thread on QNX

2005-09-08 Thread Laszlo Zsolt Nagy
Jacek Popławski wrote: 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

Re: popen in thread on QNX

2005-09-08 Thread Laszlo Zsolt Nagy
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 :) Ok, but can't your main

Distutils extension proposal (was: Re: Distutils question)

2005-09-08 Thread Laszlo Zsolt Nagy
Peter Hansen wrote: How how can I install my .mo files from a distutil script into its default location? sys.prefix + os.sep + 'share' + os.sep + 'locale' I can't answer the first question, but the latter should be written this way instead os.path.join(sys.prefix, 'share',

The right way to do i18n

2005-09-07 Thread Laszlo Zsolt Nagy
Hello, I wonder if there is a standard for making i18n in Python projects. I have several Python projects that are internationalized. I also have Python packages with i18n. But it is still not clean to me what is the recommended way to do it. Currently, I use a module called

Re: simple question: $1, $2 in py ?

2005-09-05 Thread Laszlo Zsolt Nagy
Oh, yes. Right : ) It feels that I miss-looked it. thank You very much for an advice : ) Also try the OptParse module. http://www.python.org/doc/2.4/lib/module-optparse.html It handles the GNU/POSIX syntax very well. Les -- http://mail.python.org/mailman/listinfo/python-list

epydoc CLI and many files

2005-09-05 Thread Laszlo Zsolt Nagy
Hello, I have a problem under Windows. I use the cli.py program included with epydoc. I wrote a small program that lists all of my modules after the cli. Something like this: cli.py --html --inheritance=grouped module1.py module2.py module3.py .. The problem is that now I have so many

pexpect.exitstatus not working?

2005-09-01 Thread Laszlo Zsolt Nagy
This function: def scp(from_path,to_path,pwd): Copy a file with scp. cmd = '/bin/csh -c scp -q %s %s ; echo XXX' %(from_path,to_path) print cmd child = pexpect.spawn(cmd) child.expect('Password:') child.sendline(pwd) child.expect('XXX') return child.exitstatus

Re: pexpect.exitstatus not working?

2005-09-01 Thread Laszlo Zsolt Nagy
Laszlo Zsolt Nagy wrote: This function: def scp(from_path,to_path,pwd): Copy a file with scp. cmd = '/bin/csh -c scp -q %s %s ; echo XXX' %(from_path,to_path) print cmd child = pexpect.spawn(cmd) child.expect('Password:') child.sendline(pwd) child.expect('XXX

Re: FileIO problem

2005-08-24 Thread Laszlo Zsolt Nagy
Try this: gclas = raw_input(What is the class:) def Princlas(): count = 0 while count != 1000: count = count + 1 return Admin forceclass %s %s % ( count , gclas ) #asks for file name a = raw_input(What is new file name:) out_file = open(a,w) #this is the input of text

Re: zlib + Windows 32 service problem (ImportError)

2005-08-17 Thread Laszlo Zsolt Nagy
| | C:\Python24;C:\Python24\DLLs;c:\Python24\Lib\site-packages\win32;c:\oracle\product\10.1.0\db_1\bin;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin\client;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program | Files\Common

sys.path and win32 services (was: importerror)

2005-08-17 Thread Laszlo Zsolt Nagy
Why do you think str() is needed here? Because I'm not sure if sys.path was overwritten or changed. Some bad modules could overwrite sys.path with another list. I know I'm paranoid. :-) Possibly because sys.path can start with '' which is interpreted as the current directory. Perhaps when

Re: zlib + Windows 32 service problem (ImportError)

2005-08-16 Thread Laszlo Zsolt Nagy
vincent wehren wrote: Laszlo Zsolt Nagy [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] | Sorry, I realized that the import zlib was not executed from my | (working) service. | So here is the question: why can't I use zlib from a win32 service? Is | there any way to make

Windows 32 service problem (ImportError)

2005-08-15 Thread Laszlo Zsolt Nagy
Hi All! I have a running service (a small web server) implemented in python, running as a win32 service. I wrote another program that is very similar to the web server but I cannot start the service. From the event log, I can read this traceback: - Python could not import the

zlib + Windows 32 service problem (ImportError)

2005-08-15 Thread Laszlo Zsolt Nagy
Sorry, I realized that the import zlib was not executed from my (working) service. So here is the question: why can't I use zlib from a win32 service? Is there any way to make it working? - Python could not import the service's module File

Re: About size of Unicode string

2005-06-06 Thread Laszlo Zsolt Nagy
Frank Abel Cancio Bello wrote: Hi all! I need know the size of string object independently of its encoding. For example: len('123') == len('123'.encode('utf_8')) while the size of '123' object is different of the size of '123'.encode('utf_8') More: I need send in HTTP request a string.

Re: idiom for constructor?

2005-06-01 Thread Laszlo Zsolt Nagy
Mac wrote: Is there a nice Python idiom for constructors which would expedite the following? class Foo: def __init__(self, a,b,c,d,...): self.a = a self.b = b self.c = c self.d = d ... I would like to keep the __init__ parameter list explicit, as is, rather than passing in

Re: idiom for constructor?

2005-06-01 Thread Laszlo Zsolt Nagy
You could try: class Foo: def __init__(self,a,b,c,d): args = locals() for arg in args.keys(): if name!='self': self.__dict__[arg] = args[arg] Should be: if arg!='self' Also it is not perfect. For example: class Foo: def __init__(self,a,b,c,d):

Manipulating mailboxes

2005-05-23 Thread Laszlo Zsolt Nagy
Hi All, I need to create a daemon that sits on a server and forwards some e-mails. (Well not only that, it needs to change header information before forwarding and also insert messages into a database). The mailbox module is fine but I do not see a way to delete/add messages - it is ready

Re: Manipulating mailboxes

2005-05-23 Thread Laszlo Zsolt Nagy
Maksim Kasimov wrote: change header information, insert messages into a database, delete/add messages, should not store passwords for all users, ... and any things else you wish to do - if your OS is UNIX - just forward mail messages of some users to your python script (you don't need to write

minidom and DTD

2005-05-23 Thread Laszlo Zsolt Nagy
Hi All, How can I put the !DOCTYPE collection SYSTEM recipes.dtd thing into an XML created by xml.dom.minidom? Of course I can parse the generated XML file and insert the DOCTYPE string but there must be a standard way to do this... Best, Laci 2.0 --

Re: minidom and DTD

2005-05-23 Thread Laszlo Zsolt Nagy
Martin v. Löwis wrote: Laszlo Zsolt Nagy wrote: How can I put the !DOCTYPE collection SYSTEM recipes.dtd thing into an XML created by xml.dom.minidom? You should put a DocumentType node into your DocumentNode, and pass a qualifiedName of collection and a systemId of recipes.dtd

Re: EpyDoc problem

2005-05-19 Thread Laszlo Zsolt Nagy
EpyDoc is hosted in Sourceforge. This alone may answer your question about a bug-tracker: http://sourceforge.net/tracker/?atid=405618group_id=32455func=browse Well, I wrote to the bug tracker some days ago but no answer so far. -- http://mail.python.org/mailman/listinfo/python-list

Re: super() and automatic method combination

2005-05-18 Thread Laszlo Zsolt Nagy
I have the impression that this is supposed to call the f method in both A and B, so it should print Not really true. The first parameter of 'super' should be a type, not an instance. A B C or maybe B A C depending on the resolution order. However, it only calls A.f and not

Re: super() and automatic method combination

2005-05-18 Thread Laszlo Zsolt Nagy
The trick is that C.f only calls A.f, but A.f needs to end up calling B.f when it is used in a C. I believe your response only applies to single inheritance. For classes with muliple bases classes, you need to call the base methods one by one. BTW I prefer to call the base methods in this

Re: super() and automatic method combination

2005-05-18 Thread Laszlo Zsolt Nagy
Which is fine so long as nobody else tries to add further subclasses later: class C(B): ... class Mine(AB,C): ... Mine().f() Using super throughout this works (it calls f in Mine, AB, A, C, B, and then Base), but your explicit call to the base classes means that if you don't call C.f()

Re: EpyDoc problem

2005-05-18 Thread Laszlo Zsolt Nagy
Looks like it is a problem with wxWidgets. There is no problem if I do not import wx. How to overcome this problem? Currently I cannot document modules that import wx. :-( I found the answer on the wxPython-users list. It is disappointing that the standard documentation tool has no support.

EpyDoc problem

2005-05-17 Thread Laszlo Zsolt Nagy
Hello, I would like to create documentation for my lib using EpyDoc. I do not see how to report bugs on the EpyDoc home page. When I try to create documentation, I get this error: Internal error: Expected a pointer Unhandled exception in thread started by function document at 0x00A44C30 At

Re: EpyDoc problem

2005-05-17 Thread Laszlo Zsolt Nagy
At the end of the traceback: wx\_misc.py line 3665, in _eq_ return _misc_.DateTime.__eq__(*args) TypeError: Expected a pointer I have no clue what does it mean but I guess it is an EpyDoc bug. Does anyone ran into the same problem? Any ideas? Looks like it is a problem with wxWidgets.

Re: Python instances

2005-04-20 Thread Laszlo Zsolt Nagy
Guess i shouldn't think of the __init__(self) function as a constructor then. __init__ is THE constructor in Python -- _ Laszlo Nagy web: http://designasign.biz IT Consultantmail: [EMAIL

Re: Faster os.walk()

2005-04-20 Thread Laszlo Zsolt Nagy
fuzzylollipop wrote: I am trying to get the number of bytes used by files in a directory. I am using a large directory ( lots of stuff checked out of multiple large cvs repositories ) and there is lots of wasted time doing multiple os.stat() on dirs and files from different methods. Do you need

Re: logging to two files

2005-04-20 Thread Laszlo Zsolt Nagy
Tor Erik Sønvisen wrote: Hi Have the following code: import logging logging.basicConfig(level = logging.DEBUG, format = '[%(levelname)-8s %(asctime)s] %(message)s', filename = 'rfs.log', filemode = 'w') When

Re: modules and namespaces

2005-04-19 Thread Laszlo Zsolt Nagy
However it doesn't work until I import the string module into m1 and m2 modules. I found in the manual that imported modules will be searched in the container module first. Is it more efficient to import the string module into main and m1 and m2 than importing only into m1 and m2? I bet the

  1   2   >