Merge branch 'master' of git://git.assembla.com/fpdb-gimick

This commit is contained in:
steffen123 2010-07-02 19:45:51 +02:00
commit 122eedcbb2
7 changed files with 243 additions and 56 deletions

View File

@ -0,0 +1,136 @@
Create MySqlPython windows installer for Python26
created by Gimick on 29th June 2010
The FPDB exe needs to build against the MySql-Python project. Unfortunately, for python 2.6 there is no official installer for windows, and none is ever likely to be provided.
Community builds are available, but to reduce third-party dependencies, we will build our own here.
This walkthrough is derived from excellent installation instructions here ... http://www.bcspcsonline.com/wiki/index.php?title=MySQL-5.1.34_Python-2.6_Module_Build_Instructions
Step 0 Get a fresh XP installation
----------------------------------
0.1/ Using XPhome 32bit
Step 1, VisualStudio 2008 express install
-----------------------------------------
1.1/ Get the ISO CD from here ... http://www.microsoft.com/express/Downloads/#2008-All
1.2/ Run and install Visual C++ only, don't bother with the additional packages offered
This package will run 30 days before registration is needed
Step 2, setup Mysql Server
--------------------------
2.1/ Install MySQL server runtime ... http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.34-win32.msi
Choose Typical, choose configure, choose Standard Configuration, choose all defaults, supply admin username/password.
Step 3, more installs
----------------------
3.1/ install the following in sequence (accept all default options) there should be no errors !
Python 2.6.5 ... http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi
7zip 914 ... http://sourceforge.net/projects/sevenzip/files/7-Zip/9.14/7z914.exe/download
Step 4, grab Mysql server Source
--------------------------------
4.1/ Download ... http://downloads.mysql.com/archives/mysql-5.1/mysql-noinstall-5.1.34-win32.zip
4.2/ Unpacking Desktop\mysqlsource (use 7zip)
4.3/ Copy the following source directories to the MySql installation:
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\data\* "c:\Program Files\MySQL\MySQL Server 5.1\data" /I/E/F/H
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\Embedded\* "c:\Program Files\MySQL\MySQL Server 5.1\Embedded" /I/E/F/H
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\include\* "c:\Program Files\MySQL\MySQL Server 5.1\include" /I/E/F/H
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\lib\* "c:\Program Files\MySQL\MySQL Server 5.1\lib" /I/E/F/H
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\mysql-test\* "c:\Program Files\MySQL\MySQL Server 5.1\mysql-test" /I/E/F/H
dos> xcopy Desktop\mysqlsource\mysql-5.1.34-win32\sql-bench\* "c:\Program Files\MySQL\MySQL Server 5.1\sql-bench" /I/E/F/H
4.4/ You can delete Destop\mysqlsource, is no longer needed.
Step 5, grab Mysql-python source
--------------------------------
5.1/ get download
MySql for python ... http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download
5.2/ extract MySQL-python-1.2.2 directory to the Desktop using 7zip
(note: use 7zip, open the gz, then open the tar, then extract the directory found inside there)
Desktop\MySQL-python-1.2.2 should now exist
Step 6, get python build tools
------------------------------
6.1/ get Easy Setup installer
Easy setup installer ... http://peak.telecommunity.com/dist/ez_setup.py
6.2/ Check the DEFAULT VERSION specified in Easy Setup and get the corresponding setuptools (version c11 in this case)
Setuptools version 11 ... http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
6.3/ Put both of these files into Desktop\MySQL-python-1.2.2, overwriting any existing files
Step 7, install the build tool
------------------------------
dos> cd Desktop\MySQL-python-1.2.2
dos> c:\Python26\python.exe ez_setup.py setuptools-0.6c11-py2.6.egg
Step 8, Tweak the configuration
-------------------------------
dos> cd Desktop\MySQL-python-1.2.2
8.1/ dos> write site.cfg
Change registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0
to registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1
8.2/ dos> write _mysql.c
Find the following lines
...
#include <windows.h>
#include <config-win.h>
...
Insert an additional winsock2 line
...
#include <winsock2.h>
#include <windows.h>
#include <config-win.h>
...
Step 9, build
-------------
dos> cd Desktop\MySQL-python-1.2.2
9.1/ dos> c:\python26\python.exe setup.py build
* Note: You will probably get a bunch of warnings and maybe a manifest error, these are ok as long as there are no errors in compiling or linking.
* Note: This will generate the "MySQL-python-1.2.2/build" folder
9.2/ dos> c:\python26\python.exe setup.py bdist_wininst
Step 10, done
-------------
10.1/ the \dist directory will contain MySQL-python-1.2.2.win32-py2.6.exe !!!!!
10.2/ rename to MySQL-python-1.2.2.win32-py2.6-fpdb0.20.exe

View File

@ -20,6 +20,16 @@ pygtk 2.16.0 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.16/pygtk-
pycairo 1.8.6 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/pycairo-1.8.6.win32-py2.6.exe
pyGobject 2.20.0 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.20/pygobject-2.20.0.win32-py2.6.exe
py2exe 0.6.9 ... http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.6.exe/download
psycopg2 ... http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.2.1.win32-py2.6-pg8.4.3-release.exe
(Note: stickpeople is the offical repository, not a community build)
1.2/ MySQL
MySQL-python-1.2.2.win32-py2.6-fpdb0.20.exe ... http://www.mediafire.com/file/zjyljynz2mz/MySQL-python-1.2.2.win32-py2.6-fpdb0.20.exe
This is an intaller built from source by gimick. There are no official mysql-python2.6 build for windows.
Community builds are also available from some developers. see www.codegood.com for example.
Step 2 Setup GTK
@ -61,13 +71,15 @@ Step 4 Get the fpdb GIT tree
4.1/ Best to take a copy to work with; following steps will assume that the fpdb folder is on the Desktop
Step 5 Put MSVCP90.dll temporarily into the fpdb folder
-------------------------------------------------------
#Step 5 Put MSVCP90.dll temporarily into the fpdb folder
#-------------------------------------------------------
py2exe will check for MSVCP90.dll. The version installed by python2.6.5runtime is not in the path, so we will put it in place TEMPORARILY. This will/must be removed manually once the exe has been created, as we do not have a licence to redistribute.
Search for MSVCP90.dll (should be found in C:\WINDOWS\WinSxS\...
copy this file TEMPORARILY to the Desktop\fpdb\pyfpdb folder
###### Step 5 no longer required as py2exe is instructed not to include the visualc/c++ dll's
#
#py2exe will check for MSVCP90.dll. The version installed by python2.6.5runtime is not in the path, so we will put it in place #TEMPORARILY. This will/must be removed manually once the exe has been created, as we do not have a licence to redistribute.
#
#Search for MSVCP90.dll (should be found in C:\WINDOWS\WinSxS\...
#copy this file TEMPORARILY to the Desktop\fpdb\pyfpdb folder
Step 6 Run py2exe to generate fpdb.exe
--------------------------------------
@ -84,17 +96,29 @@ c:\GTK
6.3/ If there are no errors reported, it has probably worked, we will test soon.
Step 7 Delete C++runtime
------------------------
Build notes:
This is really really important, this file must NOT be distributed, so get rid of it now to avoid issues.
There is a warning "c:\Python26\lib\site-packages\py2exe\build_exe.py:16: DeprecationWarning: the sets module is deprecated import sets". This is probably coming from mysql-python see here https://bugs.launchpad.net/python-mysqldb/+bug/338387
7.1/ in Desktop\fpdb\pyfpdb\ remove the file msvcp90.dll
There is a warning about dll's not included "umath.pyd - c:\Python26\lib\site-packages\numpy\core\umath.pyd" - reason for this is not understood at present. (Umath is apparently included in the built package).
#Step 7 Delete C++runtime
#------------------------
#
###### Step 7 is no longer required (see step 5 for reason)
#
#This is really really important, this file must NOT be distributed, so get rid of it now to avoid issues.
#
#7.1/ in Desktop\fpdb\pyfpdb\ remove the file msvcp90.dll
#
Step 8 Drag out the completed bundle
------------------------------------
py2exe creates a new folder for the created software bundle, drag this out to the desktop for ease of working
py2exe creates a new folder for the created software bundle, drag this out to the desktop for ease of working.
As far as I know you cannot rerun the build if the fpdb-yyyymmdd-exe exists in the tree, so dragging this out
also allows the build to re-run at step 6.
8.1/ Drag Desktop\fpdb\pyfpdb\fpdb-yyyymmdd-exe to Desktop\
@ -107,11 +131,8 @@ Step 9 Initial run
9.3/ Double click run_fpdb.bat
9.4/ check the contents of pyfpdb\fpdb.exe.log, deal with any errors thrown
Step 10 drum roll.......
------------------------
10.1/ hopefully, fpdb will run
10.2/ Try out a few options, deal with any errors reported
9.5/ hopefully, fpdb will run
9.6/ Try out a few options, deal with any errors reported
Observe that the msvcp90.dll was provided by the python runtime package, so we don't have to install the separate package from Microsoft. End-users will, however need the dependency.

View File

@ -32,11 +32,12 @@ import Configuration
import string
class GuiAutoImport (threading.Thread):
def __init__(self, settings, config, sql):
def __init__(self, settings, config, sql, parent):
self.importtimer = 0
self.settings = settings
self.config = config
self.sql = sql
self.parent = parent
imp = self.config.get_import_parameters()
@ -138,6 +139,8 @@ class GuiAutoImport (threading.Thread):
#dia_chooser.set_current_folder(pathname)
dia_chooser.set_filename(current_path)
#dia_chooser.set_select_multiple(select_multiple) #not in tv, but want this in bulk import
dia_chooser.set_destroy_with_parent(True)
dia_chooser.set_transient_for(self.parent)
response = dia_chooser.run()
if response == gtk.RESPONSE_OK:

View File

@ -23,6 +23,7 @@ import os
import sys
import traceback
from time import *
from datetime import datetime
#import pokereval
try:
@ -48,11 +49,12 @@ import Charset
class GuiGraphViewer (threading.Thread):
def __init__(self, querylist, config, debug=True):
def __init__(self, querylist, config, parent, debug=True):
"""Constructor for GraphViewer"""
self.sql = querylist
self.conf = config
self.debug = debug
self.parent = parent
#print "start of GraphViewer constructor"
self.db = Database.Database(self.conf, sql=self.sql)
@ -334,21 +336,41 @@ class GuiGraphViewer (threading.Thread):
def exportGraph (self, widget, data):
if self.fig is None:
return # Might want to disable export button until something has been generated.
dia_chooser = gtk.FileChooserDialog(title="Please choose the directory you wish to export to:",
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
#TODO: Suggest path and filename to start with
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OK,gtk.RESPONSE_OK))
dia_chooser.set_destroy_with_parent(True)
dia_chooser.set_transient_for(self.parent)
try:
dia_chooser.set_filename(self.exportFile) # use previously chosen export path as default
except:
pass
response = dia_chooser.run()
if response == gtk.RESPONSE_OK:
self.exportDir = dia_chooser.get_filename()
print "DEBUG: self.exportDir = %s" %(self.exportDir)
elif response == gtk.RESPONSE_CANCEL:
if response == gtk.RESPONSE_CANCEL:
print 'Closed, no graph exported'
dia_chooser.destroy()
return
# generate a unique filename for export
now = datetime.now()
now_formatted = now.strftime("%Y%m%d%H%M%S")
self.exportFile = dia_chooser.get_filename() + "/fpdb" + now_formatted + ".png"
dia_chooser.destroy()
#TODO: Check to see if file exists
#NOTE: Dangerous - will happily overwrite any file we have write access too
#TODO: This asks for a directory but will take a filename and overwrite it.
self.fig.savefig(self.exportDir, format="png")
#print "DEBUG: self.exportFile = %s" %(self.exportFile)
self.fig.savefig(self.exportFile, format="png")
#display info box to confirm graph created
diainfo = gtk.MessageDialog(parent=self.parent,
flags=gtk.DIALOG_DESTROY_WITH_PARENT,
type=gtk.MESSAGE_INFO,
buttons=gtk.BUTTONS_OK,
message_format="Graph created")
diainfo.format_secondary_text(self.exportFile)
diainfo.run()
diainfo.destroy()
#end of def exportGraph

View File

@ -145,14 +145,12 @@ class PokerStars(HandHistoryConverter):
mg = m.groupdict()
# translations from captured groups to fpdb info strings
Lim_Blinds = { '0.04': ('0.01', '0.02'), '0.10': ('0.02', '0.05'), '0.20': ('0.05', '0.10'),
'0.80': ('0.20', '0.40'),
'0.50': ('0.10', '0.25'), '1.00': ('0.25', '0.50'), '2.00': ('0.50', '1.00'),
'2': ('0.50', '1.00'), '4': ('1.00', '2.00'), '6': ('1.00', '3.00'),
'4.00': ('1.00', '2.00'), '6.00': ('1.00', '3.00'), '10.00': ('2.00', '5.00'),
'20.00': ('5.00', '10.00'), '30.00': ('10.00', '15.00'), '60.00': ('15.00', '30.00'),
'100.00': ('25.00', '50.00'),'200.00': ('50.00', '100.00'),'400.00': ('100.00', '200.00'),
'1000.00': ('250.00', '500.00')}
'0.40': ('0.10', '0.20'), '0.50': ('0.10', '0.25'), '1.00': ('0.25', '0.50'),
'2.00': ('0.50', '1.00'), '2': ('0.50', '1.00'), '4' : ('1.00', '2.00'),
'4.00': ('1.00', '2.00'), '6': ('1.00', '3.00'), '6.00': ('1.00', '3.00'),
'10.00': ('2.00', '5.00'), '20.00': ('5.00', '10.00'), '30.00': ('10.00', '15.00'),
'60.00': ('15.00', '30.00'), '100.00': ('25.00', '50.00'), '200.00': ('50.00', '100.00'),
'400.00': ('100.00', '200.00'), '1000.00': ('250.00', '500.00')}
limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' }
games = { # base, category
@ -197,7 +195,6 @@ class PokerStars(HandHistoryConverter):
log.error("determineGameType: Raising FpdbParseError")
raise FpdbParseError("Lim_Blinds has no lookup for '%s'" % mg['BB'])
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
return info
def readHandInfo(self, hand):

View File

@ -114,7 +114,7 @@ import Database
import Configuration
import Exceptions
VERSION = "0.20-pre1"
VERSION = "0.20-pre3"
class fpdb:
@ -499,7 +499,7 @@ class fpdb:
response = self.dia_confirm.run()
if response == gtk.RESPONSE_YES:
#FIXME these progress messages do not seem to work
#FIXME these progress messages do not seem to work in *nix
lbl = gtk.Label(" Rebuilding Indexes ... ")
self.dia_confirm.vbox.add(lbl)
lbl.show()
@ -848,6 +848,7 @@ class fpdb:
def quit(self, widget, data=None):
# TODO: can we get some / all of the stuff done in this function to execute on any kind of abort?
#FIXME get two "quitting normally" messages, following the addition of the self.window.destroy() call
print "Quitting normally"
# TODO: check if current settings differ from profile, if so offer to save or abort
try:
@ -856,6 +857,8 @@ class fpdb:
except _mysql_exceptions.OperationalError: # oh, damn, we're already disconnected
pass
self.statusIcon.set_visible(False)
self.window.destroy() # explicitly destroy to allow child windows to close cleanly
gtk.main_quit()
def release_global_lock(self):
@ -867,7 +870,7 @@ class fpdb:
def tab_auto_import(self, widget, data=None):
"""opens the auto import tab"""
new_aimp_thread = GuiAutoImport.GuiAutoImport(self.settings, self.config, self.sql)
new_aimp_thread = GuiAutoImport.GuiAutoImport(self.settings, self.config, self.sql, self.window)
self.threads.append(new_aimp_thread)
aimp_tab=new_aimp_thread.get_vbox()
self.add_and_display_tab(aimp_tab, "Auto Import")
@ -918,7 +921,7 @@ This program is licensed under the AGPL3, see agpl-3.0.txt in the fpdb installat
def tabGraphViewer(self, widget, data=None):
"""opens a graph viewer tab"""
new_gv_thread = GuiGraphViewer.GuiGraphViewer(self.sql, self.config)
new_gv_thread = GuiGraphViewer.GuiGraphViewer(self.sql, self.config, self.window)
self.threads.append(new_gv_thread)
gv_tab = new_gv_thread.get_vbox()
self.add_and_display_tab(gv_tab, "Graphs")
@ -990,14 +993,10 @@ This program is licensed under the AGPL3, see agpl-3.0.txt in the fpdb installat
menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
menuItem.connect('activate', self.dia_about)
self.statusMenu.append(menuItem)
# do not allow quit - if any transient (popup) windows are open (rebuild cache, rebuild index etc)
# quit from the tray causes a very very unclean shutdown, lockup of python process and failure to release global lock.
# fpdb window must be re-opened and the windows closed to quit
# menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT)
# menuItem.connect('activate', self.quit)
# self.statusMenu.append(menuItem)
menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT)
menuItem.connect('activate', self.quit)
self.statusMenu.append(menuItem)
self.statusIcon.connect('popup-menu', self.statusicon_menu, self.statusMenu)
self.statusIcon.set_visible(True)
@ -1045,7 +1044,7 @@ This program is licensed under the AGPL3, see agpl-3.0.txt in the fpdb installat
self.window.present()
def info_box(self, str1, str2):
diapath = gtk.MessageDialog( parent=self.window, flags=0, type=gtk.MESSAGE_INFO
diapath = gtk.MessageDialog( parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_INFO
, buttons=(gtk.BUTTONS_OK), message_format=str1 )
diapath.format_secondary_text(str2)
response = diapath.run()
@ -1053,7 +1052,7 @@ This program is licensed under the AGPL3, see agpl-3.0.txt in the fpdb installat
return response
def warning_box(self, str, diatitle="FPDB WARNING"):
diaWarning = gtk.Dialog(title=diatitle, parent=self.window, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
diaWarning = gtk.Dialog(title=diatitle, parent=self.window, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
label = gtk.Label(str)
diaWarning.vbox.add(label)

View File

@ -63,6 +63,10 @@ Py2exe script for fpdb.
#
# libgobject-2.0-0.dll
# libgdk-win32-2.0-0.dll
#
# Now updated to work with python 2.6 + related dependencies
# See walkthrough in packaging directory for versions used
# Updates to this script have broken python 2.5 compatibility (gio module, msvcr71 references now msvcp90)
import os
@ -77,7 +81,9 @@ from datetime import date
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
if os.path.basename(pathname).lower() in ("msvcp71.dll", "dwmapi.dll"):
#VisC++ runtime msvcp71.dll removed; py2.6 needs msvcp90.dll which will not be distributed.
#dwmapi appears to be vista-specific file, not XP
if os.path.basename(pathname).lower() in ("dwmapi.dll"):
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
@ -145,12 +151,13 @@ setup(
],
'excludes' : ['_tkagg', '_agg2', 'cocoaagg', 'fltkagg'], # surely we need this? '_gtkagg'
'dll_excludes': ['libglade-2.0-0.dll', 'libgdk-win32-2.0-0.dll'
,'libgobject-2.0-0.dll'],
,'libgobject-2.0-0.dll', 'msvcr90.dll', 'MSVCP90.dll', 'MSVCR90.dll','msvcr90.dll'],
}
},
# files in 2nd value in tuple are moved to dir named in 1st value
data_files = [('', ['HUD_config.xml.example', 'Cards01.png', 'logging.conf', '../docs/readme.txt'])
#data_files updated for new locations of licences + readme nolonger exists
data_files = [('', ['HUD_config.xml.example', 'Cards01.png', 'logging.conf', '../agpl-3.0.txt', '../fdl-1.2.txt', '../THANKS.txt'])
,(dist_dir, [r'..\run_fpdb.bat'])
,( dist_dir + r'\gfx', glob.glob(r'..\gfx\*.*') )
# line below has problem with fonts subdir ('not a regular file')
@ -174,7 +181,7 @@ dest = dest.replace('\\', '\\\\')
os.rename( 'pyfpdb', dest )
print "Enter directory name for GTK 2.14 (e.g. c:\code\gtk_2.14.7-20090119)\n: ", # the comma means no newline
print "Enter directory name for GTK (e.g. c:\code\gtk_2.14.7-20090119)\n: ", # the comma means no newline
gtk_dir = sys.stdin.readline().rstrip()
@ -223,6 +230,8 @@ pyfpdb/share/locale
pyfpdb/share/man
pyfpdb/share/themes/Default
Please double-check that msvcr90.dll is NOT in the distribution tree
Use 7-zip to zip up the distribution and create a self extracting archive and that's it!
"""