Τη Πέμπτη, 29 Αυγούστου 2013 1:56:55 π.μ. UTC+3, ο χρήστης Steven D'Aprano έγραψε: > On Wed, 28 Aug 2013 06:11:13 -0700, Ferrous Cranus wrote: > > > > > This si what iam tryign now since the function ishish proposed wont help > > > me. > > > > I see that your apology for careless writing didn't last very long. > > > > [...] > > > except: > > > print( repr(e) ) > > > > What is the value of "e" here, and where is it defined? > > > > Let's look at the error in your log file: > > > > > > > [Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] print( > > > repr(e) ) [Wed Aug 28 13:08:27 2013] [error] [client 108.162.231.120] > > > NameError: name 'e' is not defined > > > > > > Did you bother to read the error before asking for help? > > > > Variable 'e' is not defined. Perhaps you should define it?
Yes indeed , that was a a syntax error by me: 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 except Exception as e: con.rollback() #something failed, rollback the entire transaction print( repr(e) ) outputs: [Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127] File "/home/nikos/public_html/cgi-bin/metrites.py", line 206, in <module> [Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127] cur.execute('''SELECT hits FROM counters WHERE url = %s''', page ) [Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127] File "/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py", line 108, in execute [Thu Aug 29 04:18:04 2013] [error] [client 108.162.229.127] query = query % escaped_args [Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154] File "/home/nikos/public_html/cgi-bin/metrites.py", line 206, in <module> [Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154] cur.execute('''SELECT hits FROM counters WHERE url = %s''', page ) [Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154] File "/usr/local/bin/python/lib/python3.3/site-packages/pymysql/cursors.py", line 108, in execute [Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154] query = query % escaped_args [Thu Aug 29 04:15:20 2013] [error] [client 141.101.98.154] TypeError: unsupported operand type(s) for %: 'bytes' and 'str' Now at least 'superhost.gr' displays the error when one by browser http://superhost.gr -- http://mail.python.org/mailman/listinfo/python-list