On 04/06/2013 14:57, Νικόλαος Κούρας wrote:
I' just tried to implment your idea by correcting file names as:

# Compute a set of current fullpaths
fullpaths = set()
path = "/home/nikos/www/data/apps/"

for root, dirs, files in os.walk(path):
        for fullpath in files:
                fullpaths.add( os.path.join(root, fullpath) )

                
# Load'em
for fullpath in fullpaths:
        try:
                # Check the presence of a file against the database and insert 
if it doesn't exist
                cur.execute('''SELECT url FROM files WHERE url = %s''', ( 
fullpath.encode('ISO-8859-7').decode('latin-1'), )
                data = cur.fetchone()        #URL is unique, so should only be 
one

This gave me this error:

root@nikos [~]# [Tue Jun 04 16:55:51 2013] [error] [client 46.12.95.59]   File 
"files.py", line 68
[Tue Jun 04 16:55:51 2013] [error] [client 46.12.95.59]     data = 
cur.fetchone()        #URL is unique, so should only be one
[Tue Jun 04 16:55:51 2013] [error] [client 46.12.95.59]        ^
[Tue Jun 04 16:55:51 2013] [error] [client 46.12.95.59] SyntaxError: invalid 
syntax
[Tue Jun 04 16:55:51 2013] [error] [client 46.12.95.59] Premature end of script 
headers: files.py
[Tue Jun 04 16:55:51 2013] [error] [client 46.12.95.59] File does not exist: 
/home/nikos/public_html/500.shtml


It seem that this approach overcame the error, won't you agree?
But i see no syntax error in the exact follow up line.

data = cur.fetchone()        #URL is unique, so should only be one


The syntax error is often in the preceeding line, typically because you're missed a closing bracket.

--
"Steve is going for the pink ball - and for those of you who are watching in black and white, the pink is next to the green." Snooker commentator 'Whispering' Ted Lowe.

Mark Lawrence

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to