PDA

View Full Version : Python 1.5.1 problems


sheila
03-19-2001, 01:50 AM
I'm working with the core install of Python 1.5.1 in a telnet session. At the prompt, in my home directory, I typed
$python

an interpreter session is shown below:


Python 1.5.1 (#1, Sep[nbsp][nbsp]3 1998, 22:51:17)[nbsp][nbsp][GCC 2.7.2.3] on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import smtplib
>>> To="sheila@thinkspot.net"
>>> From ="webmaster@thinkspot.net"
>>> mssg='''To:sheila@thinkspot.net
... From:webmaster@thinkspot.net
... Subject: testing
...
... This is a test.
... The end.'''
>>> server=smtplib.SMTP("thinkspot.net")
>>> server.sendmail(From, To, mssg)
Traceback (innermost last):
[nbsp][nbsp]File &quot;<stdin>&quot;, line 1, in ?
[nbsp][nbsp]File &quot;/usr/lib/python1.5/smtplib.py&quot;, line 252, in sendmail
[nbsp][nbsp][nbsp][nbsp](code,resp)=self.rcpt(each)
[nbsp][nbsp]File &quot;/usr/lib/python1.5/smtplib.py&quot;, line 176, in rcpt
[nbsp][nbsp][nbsp][nbsp]self.putcmd(&quot;rcpt&quot;,&quot;to: %s&quot; % recip)
[nbsp][nbsp]File &quot;/usr/lib/python1.5/smtplib.py&quot;, line 102, in putcmd
[nbsp][nbsp][nbsp][nbsp]self.send(str)
[nbsp][nbsp]File &quot;/usr/lib/python1.5/smtplib.py&quot;, line 94, in send
[nbsp][nbsp][nbsp][nbsp]self.sock.send(str)
socket.error: (32, 'Broken pipe')
>>>


So far as I can tell, from my experience with Python 2.0 and from reading the 1.5.1 docs published Aug. 1998, which can be found here:
http://www.python.org/doc/1.5.1p1/

This should work.

The documentation for the 1.5.1 smtplib module is here:
http://www.python.org/doc/1.5.1p1/lib/module-smtplib.html

I was able to successfully execute such a session under my home install of Python 2.0 and under my install of 2.0 here at FQ. And when I compare the documenation for the smtplib module in versions 1.5.1 and 2.0 of Python, there seems to be no difference between the commands and syntax in the modules.

2.0 smtplib docs are here (for comparison):
http://www.python.org/doc/current/lib/module-smtplib.html

Here is my successful 2.0 interpreter session:

[thinker@FQ-Nine:~ ]$ python2
Python 2.0 (#1, Jan 15 2001, 01:09:04)
[GCC 2.7.2.3] on linux2
Type &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
>>> import smtplib
>>> To = &quot;sheila@thinkspot.net&quot;
>>> From = &quot;webmaster@thinkspot.net&quot;
>>> mssg = '''To: sheila@thinkspot.net
... From: webmaster@thinkspot.net
... Subject: testing
...
... This is a test.
... The end.'''
>>> server = smtplib.SMTP(&quot;thinkspot.net&quot;)
>>> server.sendmail(From, To, mssg)
{}
>>> server.quit()
>>>


I'm trying to execute scripts under 1.5.1 for the time being, but this isn't working for me. smtplib module doesn't appear to work as documented.

Terra
03-19-2001, 03:49 AM
I have marked this down as a bug and will look into it further when I have a chance...

Since this is not a critical server component, it may take me a couple weeks to get to it as there are some very pressing server issues taking priority right now...

Please use the alternate method that you've found to work until a solution can be found for the above core python module...

--
Terra
--The only thing I really remember is how to count to 20 in German--
FutureQuest

sheila
03-19-2001, 11:42 AM
The &quot;alternative method&quot; that I've found to work???

If you mean, using my custom 2.0 install, I would. But I'm not really trying to work from the command line. I want to run cgi scripts, and I'm having trouble with the permissions/paths/something and can't get them to run as cgi scrpts. (I have gotten my 2.0 to work as .qmail scripts and from the command line. It just won't import modules when running as a cgi script.)

(See this aota thread:
http://www.aota.net/ubb/Forum3/HTML/001564-1.html )

Per support e-mail, I have tried
make sure you can run the simplest of &quot;Hello World&quot;
scripts with our core Python 1.5.x - and then your 2.x...
Which I can do. Here it is with 1.5.1:
http://www.thinkspot.net/cgi-bin/pytestscript151.py
and here it is in 2.0:
http://www.thinkspot.net/cgi-bin/pytestscript.py

The next step, is to try importing some module. I choose the os module and print out all the environment variables. In 1.5.1:
http://www.thinkspot.net/cgi-bin/pytestscriptenviron151.py

However, I can't do it in 2.0, because that requires importing a module, and my 2.0 can't find the modules under cgi, although it works fine from the command line and fine as a .qmail script. The analagous script is on the server, though. Just drop the 151 from the URL above, if you'd like to see a 500 Internal Server error.

If you do, then I'll have another entry in the error logs that says something like this:

%response
%stderr
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Traceback (most recent call last):
File &quot;pytestscriptenviron.py&quot;, line 3, in ?
import os
ImportError: No module named os


Per support e-mail:

I would advise that you double check all permissions on the
directory leading to the python interpreter and module library...

and I have done this. As a last resort, last night, I had this bright idea:

Back in January, I installed Python-2.0 in my xthinkspot directory. This was necessary so that the .qmail files would work with Python and have permission to run the scripts. (And I thank you for the tip you gave me at the time, on where to install/file-permissions/directories.) So, last night, I thought, hey, maybe I need to set the permissions so that Python-2.0 grants group permission the same as owner permission ??? (Since I am not owner of the directory where it is installed, but only a member of the group.) so everything that was 755 I changed to 775 and everything that was 644 I changed to 664.

I did this, because I believe that cgi scripts run under my own userID? Correct?

I don't know if that was stupid or what. I wish I could say that it worked. Oh, well.

I know you aren't required to provide support for my Python-2.0 install. But, the reason I installed 2.0 in the first place, back in January, was because I couldn't get the 1.5.1 scripts to work, because I was using (or trying to use) the smtplib module. Only, I was such a beginner in Python at the time, that I figured my scripts were wrong, and not that the 1.5.1 installation was wrong. Heck, I didn't know why my scripts wouldn't work. So I went to the trouble to install 2.0 and pay for extra disk space, and my scripts worked! (they were .qmail invoked).

By that point, I had an idea that 1.5.1 had a problem, although I didn't file a support request, since I'd found another way to get around the problems I was having at that time. But I did forward a copy of the following Usenet post that I made to comp.lang.pythong to you, fyi only:


To: spamtrap@futurequest.net
Subject: (fwd) Re: File I/O, rfc822, and stdin/stdout
From: Sheila King <sheila@thinkspot.net>
Date: Mon, 15 Jan 2001 11:21:04 -0800

Terra,

I'm forwarding to you the following post that I made to the newsgroup
comp.lang.python. Just FYI, since I know you would be interested in this type
of thing. Python 1.5.1 supposedly has the features I was trying to use, but
they apparently don't work as advertised. I was running 1.5.2 on my home
computer...

Sheila King
sheila@thinkspot.net

Newsgroups: comp.lang.python
Subject: Re: File I/O, rfc822, and stdin/stdout
Message-ID: <lsh66tcjb1tik18vv6adusknkbbrb83nlo@4ax.com>
References: <m9b26t8f11lvfjg8a59fo8nfdcl1ro9art@4ax.com>
Date: Mon, 15 Jan 2001 19:03:11 GMT

This situation has been brought to resolution. The script I was having trouble
with before, quoted below, is now working on my web host, with the MTA
invoking it. I have installed Python 2.0 and am using that now. The web host
only had Python 1.5.1, and I believe that may have been the problem.

Of course, I've had to change the path of the script to point to my install of
Python 2.0.

On Sun, 14 Jan 2001 06:35:28 GMT, Sheila King <sheila@thinkspot.net> wrote in
comp.lang.python in article <m9b26t8f11lvfjg8a59fo8nfdcl1ro9art@4ax.com>:

:Of course, the problem with the above script, is it doesn't give me any easy
:way of handling the message headers, for filtering purposes.
:
:So, I now tried to combine them, into a script that would be of more use to
:me:
:----------------------------------------
:#! /usr/bin/python
:
:import sys, rfc822
:
:raw_message = sys.stdin
:
:inheaders=rfc822.Message(raw_message)
:body=raw_message.read()
:
:þrint inheaders
:þrint
:þrint body
:----------------------------------------
:
:Supposedly, it should read from stdin, retrieve the headers and body
:separately, and then write them to stdout. But I'm getting no e-mail
:delivered.

I would also like to thank Eric Rahmig, who went to a great deal of trouble to
write a similar script, which will actually be of great use to me, as I work
to my final goal. Here is my adaptation of his script:

-----------------------------------------
#! /my/path/to/Python-2.0/python

import rfc822, sys

origheaders=rfc822.Message(sys.stdin, 0)

for h in origheaders.headers:
[nbsp][nbsp][nbsp][nbsp][nbsp]print h,

print
for line in sys.stdin.readlines():
[nbsp][nbsp][nbsp][nbsp][nbsp]print line,
print
print
print &quot;This message was passed through a Python script&quot;
print
-----------------------------------------

He sent me some assistance through e-mail.
The above script is invoked on my system through a .qmail file, with the
following contents:
------------------------------------------
|/my/path/to/Python-2.0/python /my/path/to/scriptname.py
------------------------------------------

The script reads in the e-mail from stdin, and then puts it back out to
stdout, adding a short tag. The point is, now I will be able to do what I
want: analyze the headers and decide how to handle the mails.

Thanks to all for their assistance.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/


I don't know what the solution to this problem is. I understand that:
(a) you aren't required to support my 2.0 install
(b) you don't have time for this issue anyway, because of more pressing issues.
&copy; I should use 1.5.1 core tool. (But it doesn't work--so you've flagged it and will fix it eventually.)

I guess this just means, that Sheila is SOL. :(

Please don't suggest that I work with a different language. I have already invested many hours and the price of a few books on Python. I am planning on using it for several projects. It is easy to learn, and very powerful (does all that Perl can do and more, and LOTS easier to read the code).

FWIW, after numerous attempts at assistance from the Python community, who are baffled by the fact that my 2.0 scripts work everywhere on your machine except when run as a cgi script, I can only conclude that it is a problem with the paths/permissions that is peculiar to the FQ servers. I know I only have a basic understanding of paths/permissions, but I can't see anything that I am doing wrong, here. :([nbsp][nbsp]:([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp] :([nbsp][nbsp]

sheila
03-19-2001, 02:33 PM
I have found some sort of work-around for the path problems that I was having with Python-2.0.

When I get a chance, I will post the solution here:
http://www.aota.net/ubb/Forum3/HTML/001564-1.html

sheila
03-19-2001, 07:46 PM
And now for the groveling:

I hearby issue a public apology to Master Terra, for ever doubting his wise ways, and for insinuating that FQ would have some wacky kind of server set up.

I should have known, being the luser ... er ... I mean, lowly user, that I am, that the mistake was on my part. Yeah, verily, I am not worthy to host my site here at FQ, nor to hit the &quot;delete key&quot; on Master Terra's keyboard.

Short version: I didn't install the package properly.

More details here:
http://www.aota.net/ubb/Forum3/HTML/001564-1.html

Terra
03-19-2001, 08:15 PM
I'm glad to see that you got your library loading routines sorted out...

gcc 2.7.2.3 is one of the most solid and stable compilers in the whole gnu compiler series with egcs 2.91.66 coming in a very close second...[nbsp][nbsp]The main problem in the C++ area is dealing with the STL templates and Rope libraries - that matured somewhat in the egcs series...[nbsp][nbsp]Nonetheless, Python compiles perfectly with gcc 2.7.2.3 as I'm sure the 'configure' program does the right thing...

The old '--prefix=' problem seems to have reared it's ugly head...[nbsp][nbsp]This single 'configure' statement is often one of the most overlooked, but incredibly important when compiling for local installs...[nbsp][nbsp]Even in system core, I'm am always in the habit to explicitly defining this config option 'just in case'...

Overall, I see your last bug hunting to be the same as non gun-toting duck hunting...[nbsp][nbsp]Send the dogs into the brush to flush out all the ducks, and then snapshot them with your camera...[nbsp][nbsp]Sometimes problem isolation is a very frustrating ordeal, no matter which level your working at...

The most important ideology is to just &quot;STOP&quot; and &quot;THINK&quot;...[nbsp][nbsp]Get up and walk away from it - find something else to do - distract yourself...[nbsp][nbsp]Most likely the behaviorism of &quot;WHY&quot; will make itself apparent soon enough, and many times will lead all the way back to the beginning...[nbsp][nbsp]Most of my problem solving is like the number guessing game (1 to 100), except I employ one extreme...

study (100)
jump to 1
if not found
[nbsp][nbsp]jump to 50 for mid point reference
then from here
walk to 25[nbsp][nbsp](don't jump or you'll miss something along the way)
or
walk to 75
whenever you start to feel your getting close then
crawl

eventually you will narrow it down while collecting blues clues along the way...

The above is not meant to insult anyones intelligence - just my informal methods of how I solve multi-server multi-{sub}system problems and isolate them down fairly quickly...

And finally, is the core Python 1.5.1 smtplib still broke - or did your eureka fix that as a byproduct?

--
Terra
--Stop, Drop, and Roll--
FutureQuest

sheila
03-19-2001, 08:34 PM
1.5.1 smtplib is still broke. I just tested it from the command line, with same results as shown above.

I believe it was broken from the beginning, before I ever even thought about installing 2.0. It was because I couldn't get my mail scripts to work when I first started learning Python, and working with FQ's core install, that I even got the idea to install 2.0.

Terra
03-19-2001, 11:04 PM
I pulled the 'smtplib' Python libraries from RASMUS and dropped them into NINE core library...

I ran the test shown above and it now succeeds...

Please retest your results on NINE and let me know if it works for you now...

--
Terra
sysAdmin
FutureQuest

sheila
03-19-2001, 11:47 PM
It appears to be working now. RASMUS has Python 1.5.2, huh?

Terra
03-19-2001, 11:57 PM
RASMUS core is based on RedHat-6.2, NINE can't use the stock RH Python 1.5.2 due to glibc incompatibilities...

Plans are already underway to remedy this problem all servers prior to PHOENIX, which was the glibc crossover point...

--
Terra
--Designing how to turn 5 servers upside down and inside out without anyone noticing--
FutureQuest