Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'syntax': 0.04; 'insert': 0.05; 'error:': 0.07; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'root,': 0.09; 'try:': 0.09; 'missed': 0.12; 'compute': 0.16; 'files:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'set()': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.18; 'header:User- Agent:1': 0.23; 'error': 0.23; 'script': 0.25; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'idea': 0.28; "doesn't": 0.30; 'ball': 0.31; 'unique,': 0.31; 'file': 0.32; 'subject:from': 0.34; 'subject: (': 0.35; 'but': 0.35; 'skip:f 40': 0.36; 'next': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'files': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'black': 0.61; "you're": 0.61; 'invalid': 0.68; 'line,': 0.68; 'watching': 0.68; '8bit%:100': 0.72; 'as:': 0.81; 'correcting': 0.84; 'premature': 0.84; 'skip:/ 30': 0.84; 'white,': 0.84; 'received:89': 0.85 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Changing filenames from Greeklish => Greek (subprocess complain) Date: Tue, 04 Jun 2013 15:09:06 +0100 References: <2c425f2b-99de-4453-964e-c585f2043f71@googlegroups.com> <749e23ce-9b40-4ed4-aa6a-b06c2d7a1c24@googlegroups.com> <18755849-35bc-4925-811a-8f6f9fb5bf9c@googlegroups.com> <8c16324f-da12-44ff-bf2f-4ae56f9127c0@googlegroups.com> <51ac3bd6$0$11118$c3e8da3@news.astraweb.com> <51ad1cdd$0$11118$c3e8da3@news.astraweb.com> <306a22ea-fbf7-4097-af31-121a999957d6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-89-240-174-199.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 In-Reply-To: <306a22ea-fbf7-4097-af31-121a999957d6@googlegroups.com> X-Antivirus: avast! (VPS 130604-0, 04/06/2013), Outbound message X-Antivirus-Status: Clean X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370354937 news.xs4all.nl 15910 [2001:888:2000:d::a6]:32801 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46906 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