[Tutor] chain gangs revolt, film at 11
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Mon Aug 18 19:00:22 EDT 2003
On Mon, 18 Aug 2003, Kirk Bailey wrote:
> problem,, quoting from the error log:
>
> Traceback (innermost last):
> File "/www/www.tinylist.org/cgi-bin/wikinehesaed2.py", line 24, in ?
> os.execl(path+'/wikinehesa.py/'+pagename)
> File "/usr/local/lib/python1.5/os.py", line 169, in execl
> execv(file, args)
> OSError: [Errno 20] Not a directory
>
> Path is functioning flawlessly- see script listing to see how it is generated.
Hi Kirk,
A certain Tao verse comes to mind:
"""The wise programmer is told about Tao
and follows it. The average programmer
is told about Tao and searches for it.
The foolish programmer is told about Tao
and laughs at it.
If it were not for laughter, ther would be no Tao.
The highest sounds are hardest to hear.
Going forward is a way to retreat.
Great talent shows itself late in life.
Even a perfect program still has bugs.
The Tao is hidden beyond all understanding.
"""
The penultimate sentence is one I take to heart. *grin*
It's human nature to err, and it's not shameful to acknowledge that our
understanding about our programs is less than perfect. Going in with eyes
closed to certain possibilities might help us find a bug more quickly...
or it may lead us totally astray. Let's see what we can do to diagnose
the problem without making too many assumptions.
First, it seems that execl() is having a hard time getting at the
executable it's trying to execute. we should try checking to see if the
path that we're feeding into execl refers to a real file. We can check
this by adding an assertion:
complete_path = path + '/wikinehesa.py/' + pagename)
assert os.path.exists(complete_path), ("file %s does not exist" %
complete_path)
os.execl(complete_path)
... ok, wait a minute. If we take a closer look at the error message:
> Traceback (innermost last):
> File "/www/www.tinylist.org/cgi-bin/wikinehesaed2.py", line 24, in ?
> os.execl(path+'/wikinehesa.py/'+pagename)
> File "/usr/local/lib/python1.5/os.py", line 169, in execl
> execv(file, args)
> OSError: [Errno 20] Not a directory
we can guess that Python is trying to say: "I don't know about a directory
called path+'/wikinehesa.py/'+pagename." It's very likely that Python is
treating 'wikinhesa.py' as part of a path name.
Are you sure the path to your executable should include 'wikinehea.py/' +
pagename? I think you mean to ask the system to evaluate 'wikinehesa.py',
using pagename as an an additional argument to the 'wikinehesa.py'
program. If so, then
path + "/wikinehesa.py"
alone needs to be our executable argument.
If so, then we need to specity 'pagename' as part of the additional
parameters to execl(). Here is an example that execl()'ing a call to the
'ls' file listing utility:
###
[dyoo at tesuque dyoo]$ python
Python 2.2.1 (#1, Sep 3 2002, 14:52:01)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.execl('/bin/ls', '/bin/ls', '/home/dyoo/pubsearch')
build HACKING log
build.xml HISTORY maint
build.xml.~1.56.~ images program.properties
ChangeLog index.jsp program.properties~
ChangeLog.bak index.jsp.~1.16.~ program.properties.backup
css INSTALL program.properties.sample
CVS js
program.properties.sample.~1.12.~
data jsp README
DCB_1035496690787.log jspc_build README.~1.10.~
DCB_1054343490761.log jspc_src TODO
DCB_1060903313342.log jspc_srchome WEB-INF
doc jython
experimental lib
[dyoo at tesuque dyoo]$
###
Hope this helps!
More information about the Tutor
mailing list