p42 - started implementing autoimport.

renamed some files to match the future more precise splitting of processing and frontend code
changing from gitX to pX to match Gentoo portage's convention.

changed table design on feedback from ray but not yet the actual code - more coming shortly
This commit is contained in:
steffen123 2008-08-17 01:48:03 +01:00
parent 0f032bcc5e
commit e9d8b685ec
7 changed files with 144 additions and 18 deletions

View File

@ -7,4 +7,4 @@ tv-combinedStealFold=True
tv-combined2B3B=True tv-combined2B3B=True
tv-combinedPostflop=True tv-combinedPostflop=True
bulkImport-defaultPath=default bulkImport-defaultPath=default
tv-defaultPath=default hud-defaultPath=default

View File

@ -3,7 +3,8 @@ Everything is subject to change and especially the order will often change. Patc
alpha2 (release by 17Aug) alpha2 (release by 17Aug)
====== ======
auto-import implement gametypes.base/hiLo
seperate and improve instructions for update seperate and improve instructions for update
verify link in release notes verify link in release notes
split install instructions into OS-specific and OS-independent section. expand release creator to concatenate. split install instructions into OS-specific and OS-independent section. expand release creator to concatenate.
@ -16,6 +17,7 @@ ebuild: symlink doesnt work, USE gtk, more automation, update install-in-gentoo.
alpha3 alpha3
====== ======
export settings[hud-defaultInterval] to conf
fix up bg colours in tv fix up bg colours in tv
fill the fold to CB/2B/3B cache fields fill the fold to CB/2B/3B cache fields
verify the totalProfit cache field verify the totalProfit cache field
@ -33,7 +35,7 @@ printhand each and the 2/3 relevant printplayerflags respectively on ps-lhe-ring
before beta before beta
=========== ===========
change most cache fields to bigint to allow extremely big databases in excess of 2 or 4 million hands ?change most cache fields to bigint to allow extremely big databases in excess of 2 or 4 million hands per stake and position?
optionally make tv positional optionally make tv positional
gentoo ebuild: USE postgresql gentoo ebuild: USE postgresql
skins skins

View File

@ -136,6 +136,13 @@ The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
ring - ringgames aka cash games<br> ring - ringgames aka cash games<br>
tour - tournament incl SnG</P></TD> tour - tournament incl SnG</P></TD>
</TR> </TR>
<TR VALIGN=TOP>
<TD><P>base</P></TD>
<TD><P>char(4)</P></TD>
<TD><p>The underlying structure. valid entries:<br>
hold - Holdem and Omaha<br>
stud - Stud and Razz </P></TD>
</TR>
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD><P>category</P></TD> <TD><P>category</P></TD>
<TD><P>varchar(9)</P></TD> <TD><P>varchar(9)</P></TD>
@ -156,6 +163,14 @@ The program itself is licensed under AGPLv3, see agpl-3.0.txt</p>
cp=Cap Pot Limit<br> cp=Cap Pot Limit<br>
fl=Fixed Limit</P></TD> fl=Fixed Limit</P></TD>
</TR> </TR>
<TR VALIGN=TOP>
<TD><P>hiLo</P></TD>
<TD><P>char(1)</P></TD>
<TD><p>Whether the game is hi, lo or both. Valid Entries:<br>
h - High only<br>
l - Low only<br>
s - Hi/Lo Split</P></TD>
</TR>
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD><P>smallBlind</P></TD> <TD><P>smallBlind</P></TD>
<TD><P>int</P></TD> <TD><P>int</P></TD>

102
pyfpdb/GuiAutoImport.py Normal file
View File

@ -0,0 +1,102 @@
#!/usr/bin/python
#Copyright 2008 Steffen Jobbagy-Felso
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as published by
#the Free Software Foundation, version 3 of the License.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in
#agpl-3.0.txt in the docs folder of the package.
import threading
import pygtk
pygtk.require('2.0')
import gtk
import fpdb_import
class GuiAutoImport (threading.Thread):
def browseClicked(self, widget, data):
"""runs when user clicks browse on auto import tab"""
#print "start of GuiAutoImport.browseClicked"
current_path=self.pathTBuffer.get_text(self.pathTBuffer.get_start_iter(), self.pathTBuffer.get_end_iter())
dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import",
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
#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
response = dia_chooser.run()
if response == gtk.RESPONSE_OK:
#print dia_chooser.get_filename(), 'selected'
self.pathTBuffer.set_text(dia_chooser.get_filename())
elif response == gtk.RESPONSE_CANCEL:
print 'Closed, no files selected'
dia_chooser.destroy()
#end def GuiAutoImport.browseClicked
def startClicked(self, widget, data):
"""runs when user clicks start on auto import tab"""
print "implement GuiAutoImport.startClicked"
#end def GuiAutoImport.browseClicked
def get_vbox(self):
"""returns the vbox of this thread"""
return self.mainVBox
#end def get_vbox
def __init__(self, settings, debug=True):
"""Constructor for GuiAutoImport"""
self.settings=settings
self.mainVBox=gtk.VBox(False,1)
self.mainVBox.show()
self.settingsHBox = gtk.HBox(False, 0)
self.mainVBox.pack_start(self.settingsHBox, False, True, 0)
self.settingsHBox.show()
self.intervalLabel = gtk.Label("Interval (ie. break) between imports in seconds:")
self.settingsHBox.pack_start(self.intervalLabel)
self.intervalLabel.show()
self.intervalTBuffer=gtk.TextBuffer()
self.intervalTBuffer.set_text(str(self.settings['hud-defaultInterval']))
self.intervalTView=gtk.TextView(self.intervalTBuffer)
self.settingsHBox.pack_start(self.intervalTView)
self.intervalTView.show()
self.pathHBox = gtk.HBox(False, 0)
self.mainVBox.pack_start(self.pathHBox, False, True, 0)
self.pathHBox.show()
self.pathLabel = gtk.Label("Path to auto-import:")
self.pathHBox.pack_start(self.pathLabel, False, False, 0)
self.pathLabel.show()
self.pathTBuffer=gtk.TextBuffer()
self.pathTBuffer.set_text(self.settings['hud-defaultPath'])
self.pathTView=gtk.TextView(self.pathTBuffer)
self.pathHBox.pack_start(self.pathTView, False, True, 0)
self.pathTView.show()
self.browseButton=gtk.Button("Browse...")
self.browseButton.connect("clicked", self.browseClicked, "Browse clicked")
self.pathHBox.pack_end(self.browseButton, False, False, 0)
self.browseButton.show()
self.startButton=gtk.Button("Start Autoimport")
self.startButton.connect("clicked", self.startClicked, "start clicked")
self.mainVBox.add(self.startButton)
self.startButton.show()
#end of GuiAutoImport.__init__

View File

@ -23,7 +23,7 @@ pygtk.require('2.0')
import gtk import gtk
import os #todo: remove this once import_dir is in fpdb_import import os #todo: remove this once import_dir is in fpdb_import
class import_threaded (threading.Thread): class GuiBulkImport (threading.Thread):
def import_dir(self): def import_dir(self):
"""imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it""" """imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it"""
self.path=self.inputFile self.path=self.inputFile

View File

@ -24,7 +24,7 @@ import MySQLdb
import fpdb_import import fpdb_import
import fpdb_db import fpdb_db
class table_viewer (threading.Thread): class GuiTableViewer (threading.Thread):
def hudDivide (self, a, b): def hudDivide (self, a, b):
if b==0: if b==0:
return "n/a" return "n/a"
@ -279,7 +279,7 @@ class table_viewer (threading.Thread):
self.filename_label.show() self.filename_label.show()
self.filename_tbuffer=gtk.TextBuffer() self.filename_tbuffer=gtk.TextBuffer()
self.filename_tbuffer.set_text(self.settings['tv-defaultPath']) self.filename_tbuffer.set_text(self.settings['hud-defaultPath'])
self.filename_tview=gtk.TextView(self.filename_tbuffer) self.filename_tview=gtk.TextView(self.filename_tbuffer)
self.settings_hbox.pack_start(self.filename_tview, True, True, padding=5) self.settings_hbox.pack_start(self.filename_tview, True, True, padding=5)
self.filename_tview.show() self.filename_tview.show()

View File

@ -24,8 +24,9 @@ import gtk
import fpdb_db import fpdb_db
import fpdb_simple import fpdb_simple
import import_threaded import GuiBulkImport
import table_viewer import GuiTableViewer
import GuiAutoImport
class fpdb: class fpdb:
def tab_clicked(self, widget, tab_name): def tab_clicked(self, widget, tab_name):
@ -250,10 +251,12 @@ class fpdb:
if self.settings['os']=="windows": if self.settings['os']=="windows":
self.settings['bulkImport-defaultPath']="C:\\Program Files\\PokerStars\\HandHistory\\filename.txt" self.settings['bulkImport-defaultPath']="C:\\Program Files\\PokerStars\\HandHistory\\filename.txt"
self.settings['tv-defaultPath']="C:\\Program Files\\PokerStars\\HandHistory\\filename.txt" self.settings['hud-defaultPath']="C:\\Program Files\\PokerStars\\HandHistory\\"
else: else:
self.settings['bulkImport-defaultPath'] = os.path.expanduser("~") + "/.wine/drive_c/Program Files/PokerStars/HandHistory/filename.txt" self.settings['bulkImport-defaultPath'] = os.path.expanduser("~") + "/.wine/drive_c/Program Files/PokerStars/HandHistory/filename.txt"
self.settings['tv-defaultPath'] = os.path.expanduser("~")+"/.wine/drive_c/Program Files/PokerStars/HandHistory/filename.txt" self.settings['hud-defaultPath'] = os.path.expanduser("~")+"/.wine/drive_c/Program Files/PokerStars/HandHistory/"
self.settings['hud-defaultInterval']=30
for i in range(len(lines)): for i in range(len(lines)):
if lines[i].startswith("db-backend="): if lines[i].startswith("db-backend="):
@ -284,9 +287,9 @@ class fpdb:
elif lines[i].startswith("bulkImport-defaultPath="): elif lines[i].startswith("bulkImport-defaultPath="):
if lines[i][23:-1]!="default": if lines[i][23:-1]!="default":
self.settings['bulkImport-defaultPath']=lines[i][23:-1] self.settings['bulkImport-defaultPath']=lines[i][23:-1]
elif lines[i].startswith("tv-defaultPath="): elif lines[i].startswith("hud-defaultPath="):
if lines[i][15:-1]!="default": if lines[i][15:-1]!="default":
self.settings['tv-defaultPath']=lines[i][15:-1] self.settings['hud-defaultPath']=lines[i][16:-1]
elif lines[i].startswith("#"): elif lines[i].startswith("#"):
pass #comment - dont parse pass #comment - dont parse
else: else:
@ -324,16 +327,20 @@ class fpdb:
#end def tab_abbreviations #end def tab_abbreviations
def tab_auto_import(self, widget, data): def tab_auto_import(self, widget, data):
print "todo: implement tab_auto_import" """opens the auto import tab"""
new_aimp_thread=GuiAutoImport.GuiAutoImport(self.settings)
self.threads.append(new_aimp_thread)
aimp_tab=new_aimp_thread.get_vbox()
self.add_and_display_tab(aimp_tab, "Auto Import")
#end def tab_auto_import #end def tab_auto_import
def tab_bulk_import(self, widget, data): def tab_bulk_import(self, widget, data):
"""opens a tab for bulk importing""" """opens a tab for bulk importing"""
#print "start of tab_bulk_import" #print "start of tab_bulk_import"
new_import_thread=import_threaded.import_threaded(self.db, self.settings['bulkImport-defaultPath']) new_import_thread=GuiBulkImport.GuiBulkImport(self.db, self.settings['bulkImport-defaultPath'])
self.threads.append(new_import_thread) self.threads.append(new_import_thread)
bulk_tab=new_import_thread.get_vbox() bulk_tab=new_import_thread.get_vbox()
self.add_and_display_tab(bulk_tab, "bulk import") self.add_and_display_tab(bulk_tab, "Bulk Import")
#end def tab_bulk_import #end def tab_bulk_import
def tab_main_help(self, widget, data): def tab_main_help(self, widget, data):
@ -349,7 +356,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
def tab_table_viewer(self, widget, data): def tab_table_viewer(self, widget, data):
"""opens a table viewer tab""" """opens a table viewer tab"""
#print "start of tab_table_viewer" #print "start of tab_table_viewer"
new_tv_thread=table_viewer.table_viewer(self.db, self.settings) new_tv_thread=GuiTableViewer.GuiTableViewer(self.db, self.settings)
self.threads.append(new_tv_thread) self.threads.append(new_tv_thread)
tv_tab=new_tv_thread.get_vbox() tv_tab=new_tv_thread.get_vbox()
self.add_and_display_tab(tv_tab, "table viewer") self.add_and_display_tab(tv_tab, "table viewer")
@ -363,7 +370,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event) self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy) self.window.connect("destroy", self.destroy)
self.window.set_title("Free Poker DB - version: alpha1+, git41") self.window.set_title("Free Poker DB - version: alpha1+, p42")
self.window.set_border_width(1) self.window.set_border_width(1)
self.window.set_size_request(1020,400) self.window.set_size_request(1020,400)
self.window.set_resizable(True) self.window.set_resizable(True)
@ -376,7 +383,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
( "/Main/sep1", None, None, 0, "<Separator>" ), ( "/Main/sep1", None, None, 0, "<Separator>" ),
( "/Main/_Quit", "<control>Q", self.quit, 0, None ), ( "/Main/_Quit", "<control>Q", self.quit, 0, None ),
( "/_Import", None, None, 0, "<Branch>" ), ( "/_Import", None, None, 0, "<Branch>" ),
( "/Import/_Import Files and Directories", "<control>I", self.tab_bulk_import, 0, None ), ( "/Import/_Bulk Import", "<control>B", self.tab_bulk_import, 0, None ),
( "/Import/_Auto Import (todo)", "<control>A", self.tab_auto_import, 0, None ), ( "/Import/_Auto Import (todo)", "<control>A", self.tab_auto_import, 0, None ),
( "/Import/Auto _Rating (todo)", "<control>R", self.not_implemented, 0, None ), ( "/Import/Auto _Rating (todo)", "<control>R", self.not_implemented, 0, None ),
( "/_Viewers", None, None, 0, "<Branch>" ), ( "/_Viewers", None, None, 0, "<Branch>" ),