Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:error': 0.03; 'subject:: [': 0.04; 'subject:file': 0.07; 'tries': 0.07; 'bytes,': 0.09; 'line:': 0.09; 'try:': 0.09; 'python': 0.11; 'template': 0.14; 'gonna': 0.16; 'skip:" 70': 0.16; 'subject:] [': 0.16; 'types,': 0.16; 'exception': 0.16; 'variable': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'propose': 0.24; 'url:moin': 0.24; 'handling': 0.26; 'query': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'url:wiki': 0.31; 'occurs': 0.31; 'unique,': 0.31; 'file': 0.32; 'text': 0.33; 'url:python': 0.33; 'call.': 0.33; 'actual': 0.34; 'convert': 0.35; 'but': 0.35; 'data,': 0.36; 'useful': 0.36; 'url:org': 0.36; 'should': 0.36; 'so,': 0.37; 'two': 0.37; 'needed': 0.38; 'to:addr :python-list': 0.38; 'legally': 0.39; 'quote': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'conversion': 0.61; 'url:about': 0.61; 'first': 0.61; 'therefore,': 0.64; 'between': 0.67; 'url:i': 0.72; 'url:jpg': 0.83; 'url:imgur': 0.84 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 28 Aug 2013 11:11:05 +0100 From: ishish To: Subject: Re: [error] [client 178.59.111.223] (2)No such file or directory: exec of In-Reply-To: <39be9227-c800-49a5-850d-f387c30d1e9d@googlegroups.com> References: <39be9227-c800-49a5-850d-f387c30d1e9d@googlegroups.com> X-Sender: ishish@domhain.de User-Agent: RoundCube Webmail/0.7.1 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: 118 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377684668 news.xs4all.nl 15879 [2001:888:2000:d::a6]:56450 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53121 Am 28.08.2013 10:48, schrieb Ferrous Cranus: >> >> I quote from a Python 3 Guide >> >> >> [http://python.about.com/od/python30/ss/30_strings_3.htm]: >> >> >> >> >> >> The two data types, str and bytes, are mutually exclusive. One >> >> >> cannot >> >> >> legally combine them into one call. With the distinction between >> >> >> text >> >> >> and data, therefore, comes the need to convert between them. >> >> >> >> >> >> >> >> > >> >> > So, in this line: >> >> > >> >> > cur.execute('''SELECT ID FROM counters WHERE url = %s''', page ) >> >> > >> >> > the variable 'page' needs conversion to what? >> >> > >> >> > all that is stores is the location of a file >> >> > >> >> > path = '/home/nikos/public_html/' >> >> > >> >> > page = form.getvalue('page') >> >> > >> >> > if not page and os.path.exists( file ): >> >> > # it is an html template >> >> > page = file.replace( path, '' ) >> >> > >> >> > So chnage it to what? >> >> > -- >> >> > What is now proved was at first only imagined! >> >> >> >> >> >> The error occurs in file >> >> >> "/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py", >> >> line 108, in execute >> >> query = query % escaped_args >> >> >> >> You can check the actual values and data types using: >> >> >> >> print repr(query) >> >> print type(query) >> >> >> >> print repr(escaped_args) >> >> print type(escaped_args) >> >> >> >> Always useful is a proper exception handling using try:/except: > > > hOW YOU MEAN PLEASE I TRY TO IMPLMENT WHAT YOU PROPOSE BUT I CANT. > > try: > #find the needed counter for the page URL > if os.path.exists( path + page ) or os.path.exists( cgi_path + page > ): > cur.execute('''SELECT ID FROM counters WHERE url = %s''', page ) > data = cur.fetchone() #URL is unique, so should only be one > > > print repr('''SELECT ID FROM counters WHERE url = %s''') > print type('''SELECT ID FROM counters WHERE url = %s''') > > print repr(escaped_args) > print type(escaped_args) > > I MEAN IF FAILS BEFORE IT TRIES TO GO INTO MY PRINT STAEMNT. > HOW AM I GONNA CPATURE THE QUERY? http://i.stack.imgur.com/jiFfM.jpg http://wiki.python.org/moin/HandlingExceptions