Never mind. I just discovered that os.chmod requires 0755, not just 755.<br>V<br><br><div class="gmail_quote">On Tue, Oct 13, 2009 at 9:26 AM, Victor Subervi <span dir="ltr"><<a href="mailto:victorsubervi@gmail.com">victorsubervi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi;<br>I have the following code:<br><br> if 13 < x < 20:<br> y += 1<br>
w += 1<br> try:<br> getpic = "getpic" + str(w) + ".py"<br> try:<br>
os.remove(getpic)<br> except:<br> pass<br> code = """#! /usr/bin/python<br>import cgitb; cgitb.enable()<br>import MySQLdb<br>import cgi<br>import sys,os<br>
sys.path.append(os.getcwd())<br>from login import login<br>def pic():<br> user, passwd, db, host = login()<br> form = cgi.FieldStorage()<br> db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db)<br> cursor= db.cursor()<br>
sql = "select pic%s from productsX where id=%s;"<br> cursor.execute(sql)<br> content = cursor.fetchone()[0]<br> cursor.close()<br> print content<br>print 'Content-type: image/jpeg'<br>print<br>pic()<br>
print '</body></html>'""" % (str(w), str(w))<br> script = open(getpic, "w")<br> script.write(code)<br> print '<td><input type="hidden" name="%s" />\n' % str(x)<br>
print '<img src="%s"><br /><br /></td>\n' % (getpic)<br> os.chmod(getpic, 755)<br> count2 += 1<br> except:<br> pass<br>
<br>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?<br><br>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.<br>
TIA,<br><font color="#888888">Victor<br>
</font></blockquote></div><br>