[Tutor] ok, I want to read a dir.

Kirk Bailey deliberatus@my995internet.com
Thu, 27 Dec 2001 20:45:50 -0500


ok, this is improving, still WRONG, but much closer.

Here is the new version:

ns# list TLwebmgr.py
Listing of file TLwebmgr.py in
directory:/www/www.howlermonkey.net/cgi-bin

#!/usr/local/bin/python
#
# You must define the next lien for the WEB path to your server's web
directory!
# ALL web scripts must live in the cgi-bin UNDER this dir!
# THAT IS WHERE TL LIVES! /lists lives UNDER that dir in the tree!
#
webpath="http://www.howlermonkey.net/"
import string, sys, os, glob
#
CRLF="\r\n"
forminput=sys.stdin
filelist=[]
print "<html><head>Content-Type: text/html"             # HTML is
following
print "Content-Type: text/html"                         # HTML is
following
print                                                   # blank line,
end of headers
print " <TITLE>TinyList WebManager menu page</TITLE>"   # tells the
browser the title
print " <STYLE TYPE=\"text/css\">"
print " <!--  A { text-decoration: none; }  A:visited, A:hover,
A:active  text-decoration:none; } // -->"
print " </STYLE>" 
print " </head>"                                                # this
is the end of the head
print " <body bgcolor=\"#FFFFFF\" text=\"#000000\" links=\"0000FF\"
><blockquote><P>"
print " <center><h1>TinyList membership management
menu</h1></center><P><br>"
print "Here are all the lists we host here:<P>"
print "<hr width=60% align=\"center\"><P>"
#
def descriptor(filename):                       # Read 1st line in file
named.
        f1=open(filename,'r')                   #open the file named,
        info=string.strip(f1.readline())        # read the first line in
the file
        f1.close()                              # close the file
        return info                             # and exit returning the
1 line read
#

filelist = glob.glob('./lists/*.info')
#
for x in filelist:                              # filelist lists all the
available info files
        #
        print "<a href= \"" + webpath + "cgi-bin/commander.py?list=" + x
+  "\">" + x + "</a> ", descriptor(x) +'<P>'
#which means:
#      print 'a
href="http://www.howlermonkey.net/cgi-bin/commander.py?list=(listname)">
(description)<p>'
#
#
print "<hr width=60% align=\"center\"><P><br>"
print "Please click a name to read the entire description and to access
the form to subscribe or subscribe for that list.<P>
<br>"
print "<P><br><small><A href=\"http://www.tinylist.org/ \">Powered by
TinyList!</a></small><P><br></body></html>"

and it is in the server. Click this link to see it's output:
	http://www.howlermonkey.net/cgi-bin/TLwebmgr.py

and this one should let you view the current source code:
	http://www.howlermonkey.net/TLwebmgr.shtml

Now, the thing is working, but still supplies me with more than desired
in the text. I want to take this by the forlock and cut off the
extranious stuff, at least for display purposes.

I am taking the liberty of posting this also to tutor list.
 


"Michael P. Reilly" wrote:
> 
> On Thu, Dec 27, 2001 at 07:29:39PM -0500, Kirk Bailey wrote:
> > it got me this:
> >
> > Traceback (innermost last):
> >   File "./TLwebmgr.py", line 31, in ?
> >     filelist = fnmatch.filter(os.listdir('./lists'), "*.info")
> > AttributeError: filter
> > ns#
> >
> > AttributeError:  filter??? Hmmm?
> 
> The fnmatch.filter funciton was added only in Python 2.2.  The glob.glob1
> function I mentioned has been in Python since before 1.5.2.
> 
>   -Arcege
> 
> --
> +----------------------------------+-----------------------------------+
> | Michael P. Reilly                | arcege@speakeasy.net              |
> | Ailment info: http://www.speakeasy.org/~arcege/michaelwatch.html     |

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end


Within the sweep of his sword, Each man is an Ubar.

http://www.howlermonkey.net/
http://www.sacredelectron.org/