Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   An error when i switched from python v2.6.6 => v3.2.3 (http://www.velocityreviews.com/forums/t958447-an-error-when-i-switched-from-python-v2-6-6-v3-2-3-a.html)

33 03-07-2013 08:18 AM

An error when i switched from python v2.6.6 => v3.2.3
 
Today i switched to Python v3.2.3 on my remote web server at HostGator.
My cgi-script which it works at python v2.6.6 now produces theses errors:

--> -->
Traceback (most recent call last):
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 171, in execute
r = self._query(query)
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 330, in _query
rowcount = self._do_query(q)
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 294, in _do_query
db.query(q)
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "metrites.py", line 211, in <module>
cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (htmlpage,) )
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 184, in execute
self.errorhandler(self, exc, value)
File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass(errorvalue)
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1")

Even cursor.execute changes in python v3 ?

What are these errors about?

33 03-07-2013 09:06 AM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
Any ideas about the error please?

I can assure you all the statemnt are correct ebcause they work in python v2.6.6

33 03-07-2013 11:27 AM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
, 7 2013 11:06:27 .. UTC+2, 33 :
> Any ideas about the error please?
>
>
>
> I can assure you all the statemnt are correct ebcause they work in pythonv2.6.6


can someone help this issue so my webiste will get back on working plz?

Michael Ross 03-07-2013 11:51 AM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
On Thu, 07 Mar 2013 12:27:03 +0100, Νίκος Γκρ33κ <nikos.gr33k@gmail.com>
wrote:

> Τη **μπτη, 7 Μαρτίου 2013 11:06:27 π.μ. UTC+2, ο χρήστης Νίκος Γκρ33κ
> *γραψε:
>> Any ideas about the error please?
>>
>>
>>
>> I can assure you all the statemnt are correct ebcause they work in
>> python v2.6.6

>
> can someone help this issue so my webiste will get back on working plz?


MySQLdb is python 2 only.
"MySQL-3.23 through 5.0 and Python-2.3 through 2.7 are currently
supported. Python-3.0 will be supported in a future release."

Maybe try this one:
https://pypi.python.org/pypi/mysql-c...r-python/1.0.9

Alternatively,
forget about subprocess.check_output,
call your metrites.py with os.system('python metrites.py some-temp-file')
and have it write its output to some-temp-file,
and read some-temp-file back into your template?


33 03-07-2013 12:25 PM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
, 7 2013 1:51:42 .. UTC+2, Michael Ross :
> On Thu, 07 Mar 2013 12:27:03 +0100, 33 <nikos..gr33k@gmail.com>
>
> wrote:
>
>
>
> > , 7 2013 11:06:27 .. UTC+2, 33

>
> > :

>
> >> Any ideas about the error please?

>
> >>

>
> >>

>
> >>

>
> >> I can assure you all the statemnt are correct ebcause they work in

>
> >> python v2.6.6

>
> >

>
> > can someone help this issue so my webiste will get back on working plz?

>
>
>
> MySQLdb is python 2 only.
>
> "MySQL-3.23 through 5.0 and Python-2.3 through 2.7 are currently
>
> supported. Python-3.0 will be supported in a future release."
>
>
>
> Maybe try this one:
>
> https://pypi.python.org/pypi/mysql-c...r-python/1.0.9
>
>
>
> Alternatively,
>
> forget about subprocess.check_output,
>
> call your metrites.py with os.system('python metrites.py some-temp-file')
>
> and have it write its output to some-temp-file,
>
> and read some-temp-file back into your template?


Yes its better for me to give upon python3 for the moment being, because all that hassle was for makeing the subprocess command run.

Now i just followed your advice and tried:

elif htmlpage.endswith('.py'):
htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')

but produced error tells me that:

template undefined, htmldata = -1, counter = ' <center><a href="mailto:support@superhost.gr"> ...st.gr/?show=stats"><font color=cyan> 0 </td>\n\t\t '

whay htmldata reeturn the value '-1' when os.sytem is executed?

33 03-07-2013 12:25 PM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
, 7 2013 1:51:42 .. UTC+2, Michael Ross :
> On Thu, 07 Mar 2013 12:27:03 +0100, 33 <nikos..gr33k@gmail.com>
>
> wrote:
>
>
>
> > , 7 2013 11:06:27 .. UTC+2, 33

>
> > :

>
> >> Any ideas about the error please?

>
> >>

>
> >>

>
> >>

>
> >> I can assure you all the statemnt are correct ebcause they work in

>
> >> python v2.6.6

>
> >

>
> > can someone help this issue so my webiste will get back on working plz?

>
>
>
> MySQLdb is python 2 only.
>
> "MySQL-3.23 through 5.0 and Python-2.3 through 2.7 are currently
>
> supported. Python-3.0 will be supported in a future release."
>
>
>
> Maybe try this one:
>
> https://pypi.python.org/pypi/mysql-c...r-python/1.0.9
>
>
>
> Alternatively,
>
> forget about subprocess.check_output,
>
> call your metrites.py with os.system('python metrites.py some-temp-file')
>
> and have it write its output to some-temp-file,
>
> and read some-temp-file back into your template?


Yes its better for me to give upon python3 for the moment being, because all that hassle was for makeing the subprocess command run.

Now i just followed your advice and tried:

elif htmlpage.endswith('.py'):
htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')

but produced error tells me that:

template undefined, htmldata = -1, counter = ' <center><a href="mailto:support@superhost.gr"> ...st.gr/?show=stats"><font color=cyan> 0 </td>\n\t\t '

whay htmldata reeturn the value '-1' when os.sytem is executed?

Michael Ross 03-07-2013 01:06 PM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
On Thu, 07 Mar 2013 13:25:58 +0100, Νίκος Γκρ33κ <nikos.gr33k@gmail.com>
wrote:

> Τη **μπτη, 7 Μαρτίου 2013 1:51:42 μ.μ. UTC+2, ο χρήστης Michael Ross
> *γραψε:
>> On Thu, 07 Mar 2013 12:27:03 +0100, Νίκος Γκρ33κ <nikos.gr33k@gmail.com>
>>
>> wrote:
>>
>>
>>
>> > Τη **μπτη, 7 Μαρτίου 2013 11:06:27 π.μ. UTC+2, ο χρήστης Νίκος Γκρ33κ

>>
>> > *γραψε:

>>
>> >> Any ideas about the error please?

>>
>> >>

>>
>> >>

>>
>> >>

>>
>> >> I can assure you all the statemnt are correct ebcause they work in

>>
>> >> python v2.6.6

>>
>> >

>>
>> > can someone help this issue so my webiste will get back on working

>> plz?
>>
>>
>>
>> MySQLdb is python 2 only.
>>
>> "MySQL-3.23 through 5.0 and Python-2.3 through 2.7 are currently
>>
>> supported. Python-3.0 will be supported in a future release."
>>
>>
>>
>> Maybe try this one:
>>
>> https://pypi.python.org/pypi/mysql-c...r-python/1.0.9
>>
>>
>>
>> Alternatively,
>>
>> forget about subprocess.check_output,
>>
>> call your metrites.py with os.system('python metrites.py
>> some-temp-file')
>>
>> and have it write its output to some-temp-file,
>>
>> and read some-temp-file back into your template?

>
> Yes its better for me to give upon python3 for the moment being, because
> all that hassle was for makeing the subprocess command run.
>
> Now i just followed your advice and tried:
>
> elif htmlpage.endswith('.py'):
> htmldata = os.system('/usr/bin/python ./metrites.py
> /data/files/htmltemp')
>
> but produced error tells me that:
>
> template undefined, htmldata = -1, counter = ' <center><a
> href="mailto:support@superhost.gr"> ...st.gr/?show=stats"><font
> color=cyan> 0 </td>\n\t\t '
>
> whay htmldata reeturn the value '-1' when os.sytem is executed?


Because
"On Unix, the return value is the exit status of the process encoded in
the format specified for wait()."

It's in the documentation for os.system.
Which you should have read before asking here.

You may not intend it like that,
but if you ask any and all errors here, you effectively ask the list to
develop the software for you.

Seriously this is beyond the scope of volunteer help for a commercial site.
I'm bailing out.

33 03-07-2013 01:22 PM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
Please tell me at least if i ahve any syntax error in this line:

htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')

please man its essential for my website to work otherwise 3 scripts i wrotewould not be able to produce proper html output that then i need to appenda string after them. her si what i want to do:

if htmlpage.endswith('.html'):
f = open( "/home/nikos/www/" + htmlpage )
htmldata = f.read()
elif htmlpage.endswith('.py'):
htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')


counter = ''' <center><a href="mailto:support@superhost.gr"> <img src="/data/images/mail.png"> </a>
<center><table border=2 cellpadding=2 bgcolor=black>
<td><font color=lime> </td>
<td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d </td>
''' % data[0]


template = htmldata + counter
print( template )

======================

Please just that i like to do it myself ut i cant, i wont ask anyhting else..

33 03-07-2013 01:22 PM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
Please tell me at least if i ahve any syntax error in this line:

htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')

please man its essential for my website to work otherwise 3 scripts i wrotewould not be able to produce proper html output that then i need to appenda string after them. her si what i want to do:

if htmlpage.endswith('.html'):
f = open( "/home/nikos/www/" + htmlpage )
htmldata = f.read()
elif htmlpage.endswith('.py'):
htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')


counter = ''' <center><a href="mailto:support@superhost.gr"> <img src="/data/images/mail.png"> </a>
<center><table border=2 cellpadding=2 bgcolor=black>
<td><font color=lime> </td>
<td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d </td>
''' % data[0]


template = htmldata + counter
print( template )

======================

Please just that i like to do it myself ut i cant, i wont ask anyhting else..

Chris Angelico 03-07-2013 01:43 PM

Re: An error when i switched from python v2.6.6 => v3.2.3
 
On Fri, Mar 8, 2013 at 12:22 AM, 33 <nikos.gr33k@gmail.com> wrote:
> Please tell me at least if i ahve any syntax error in this line:
>
> htmldata = os.system('/usr/bin/python ./metrites.py /data/files/htmltemp')
>
> please man its essential for my website to work otherwise 3 scripts i wrote would not be able to produce proper html output


Yes, there is. The variable name at the beginning is wrong. To
understand why, look at the documentation for os.system().

If it's essential for your web site, why not pay someone to do the work foryou?

You want free support AND you're not willing to put effort into your
questions. That's a bad combination. The sloppiness of your writing,
coupled with a clear lack of preliminary research (eg checking the
docs), suggests that you do not value the end result; you expect
someone else to do everything, to wave a magic wand and voila, your
web site works. That isn't how the world works.

Quoting from http://www.catb.org/esr/faqs/smart-questions.html
> == Before you ask ==
> Prepare your question. Think it through. Hasty-sounding questions get
> hasty answers, or none at all. The more you do to demonstrate that having
> put thought and effort into solving your problem before seeking help, the
> more likely you are to actually get help.

....
> == Write in clear, grammatical, correctly-spelled language ==
> ... If you can't be bothered to do that, we can't be bothered to pay attention.
> Spend the extra effort to polish your language. It doesn't have to be stiff or
> formal - in fact, hacker culture values informal, slangy and humorous
> language used with precision. But it has to be precise; there has to be
> some indication that you're thinking and paying attention.
> ... if you write like a semi-literate boob you will very likely be ignored.


ChrisA


All times are GMT. The time now is 05:46 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.