[error] [client 178.59.111.223] (2)No such file or directory: exec of
Ferrous Cranus
nikos.gr33k at gmail.com
Wed Aug 28 05:48:13 EDT 2013
Τη Τρίτη, 27 Αυγούστου 2013 6:22:32 μ.μ. UTC+3, ο χρήστης ishish έγραψε:
> Am 27.08.2013 16:04, schrieb Ferrous Cranus:
>
> > Στις 27/8/2013 4:59 μμ, ο/η ishish έγραψε:
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189] Error
>
> >>> in
>
> >>> sys.excepthook:
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189]
>
> >>> ValueError: underlying buffer has been detached
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189]
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189]
>
> >>> Original
>
> >>> exception was:
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189]
>
> >>> Traceback
>
> >>> (most recent call last):
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189] File
>
> >>> "/home/nikos/public_html/cgi-bin/metrites.py", line 169, in
>
> >>> <module>
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189]
>
> >>> cur.execute('''SELECT ID FROM counters WHERE url = %s''', page )
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189] File
>
> >>>
>
> >>>
>
> >>> "/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py",
>
> >>> line 108, in execute
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189]
>
> >>> query
>
> >>> = query % escaped_args
>
> >>> [Tue Aug 27 13:02:57 2013] [error] [client 110.202.175.189]
>
> >>> TypeError: unsupported operand type(s) for %: 'bytes' and 'str'
>
> >>
>
> >> 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?
More information about the Python-list
mailing list