Archive for August, 2008

Python Trouble Shooting

Posted on August 10, 2008. Filed under: MySQL, Python, Windows | Tags: , |

1. If you get data from mysql

After the mysql_connection.execute(“some sql”), then get the result by line =mysql_connection.fetchone(), and the results are listed by line[0], line[1], line[2] …..(not the “key”->”value” pair)

2. in wxPython, the toolbar should add toolbar.Realize()

If there is no Realize() at the end of the toolbar show segment, the button will not show

toolbar = self.CreateToolBar()
toolbar.AddTool(ID_ABC, wx.Bitmap(‘icons/icon.png’))
self.Bind(wx.EVT_TOOL, self.OnChangeDepth, id=ID_ABC)


pytz.UnknownTimeZoneError: ‘US/Central’ after py2exe in python 2.6

I noticed that the old version of pytz I was using compiled each timezone into a .pyc, and these would be included in the resulting for my programs. When I build against the new pytz, these files are no longer getting compiled to .pyc. Instead, when I check the pytz directory in, I see these files:

It appears that the zoneinfo directory is missing.

in file for the py2exe

import py2exe
‘py2exe’: {
‘packages’ : [‘matplotlib’, ‘pytz’],

The “packages” in “options” is very important.



DeprecationWarning: the sets module is deprecated

There are two methods:
4.1. python -W ignore::DeprecationWarning

4.2. in Python26\Lib\  comment line 83-85
#import warnings
#warnings.warn(“the sets module is deprecated”, DeprecationWarning,stacklevel=2)

5. Socket timeout in xmlrpclib

import xmlrpclib
import socket
socket.setdefaulttimeout(10)        #set the timeout to 10 seconds
x = xmlrpclib.ServerProxy('')

x.func_name(args)                   #times out after 10 seconds
socket.setdefaulttimeout(None)      #sets the default back


Read Full Post | Make a Comment ( None so far )

PHP trouble shooting

Posted on August 10, 2008. Filed under: MySQL, PHP |

1. In the php mysql related script:

After use “mysql_query”, if you want to get the real results array, you should call the function “mysql_fetch_assoc” or “mysql_fetch_row”. The result are “key”->”value” pairs where the “key” is the table column name in the mysql_query sentence.

Useful Links:

1.  _SERVER parameter

2. Getting the current full URL in PHP

3. PHP tip: How to convert a relative URL to an absolute URL

4. mb_strrchr()

5.Introduction to PHP Regex

6. urlencode and rawurlencode

Read Full Post | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...