Never mind. I just discovered that os.chmod requires 0755, not just 755. V On Tue, Oct 13, 2009 at 9:26 AM, Victor Subervi <victorsube...@gmail.com>wrote:
> Hi; > I have the following code: > > if 13 < x < 20: > y += 1 > w += 1 > try: > getpic = "getpic" + str(w) + ".py" > try: > os.remove(getpic) > except: > pass > code = """#! /usr/bin/python > import cgitb; cgitb.enable() > import MySQLdb > import cgi > import sys,os > sys.path.append(os.getcwd()) > from login import login > def pic(): > user, passwd, db, host = login() > form = cgi.FieldStorage() > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > sql = "select pic%s from productsX where id=%s;" > cursor.execute(sql) > content = cursor.fetchone()[0] > cursor.close() > print content > print 'Content-type: image/jpeg' > print > pic() > print '</body></html>'""" % (str(w), str(w)) > script = open(getpic, "w") > script.write(code) > print '<td><input type="hidden" name="%s" />\n' % str(x) > print '<img src="%s"><br /><br /></td>\n' % (getpic) > os.chmod(getpic, 755) > count2 += 1 > except: > pass > > Forgive the empty except :) The problem is that the os.chmod command > doesn't work. It's obviously in the right directory, because the script > correctly writes there. What do? > > On another note, I find it interesting that the above revised code does in > fact get that darned image to finally post correctly. It appears that this > python server insists on my calling a function...that I can't simply code it > out without defining a function. Never run into that before. > TIA, > Victor >
-- http://mail.python.org/mailman/listinfo/python-list