From e9d8b685ec0cc9dcfd57d355746f0e3d05e9e1b8 Mon Sep 17 00:00:00 2001
From: steffen123
Date: Sun, 17 Aug 2008 01:48:03 +0100
Subject: [PATCH] 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
---
docs/default.conf | 2 +-
docs/known-bugs-and-planned-features.txt | 6 +-
docs/tabledesign.html | 15 +++
pyfpdb/GuiAutoImport.py | 102 ++++++++++++++++++
.../{import_threaded.py => GuiBulkImport.py} | 2 +-
pyfpdb/{table_viewer.py => GuiTableViewer.py} | 4 +-
pyfpdb/fpdb.py | 31 +++---
7 files changed, 144 insertions(+), 18 deletions(-)
create mode 100644 pyfpdb/GuiAutoImport.py
rename pyfpdb/{import_threaded.py => GuiBulkImport.py} (99%)
rename pyfpdb/{table_viewer.py => GuiTableViewer.py} (99%)
diff --git a/docs/default.conf b/docs/default.conf
index d2e095d8..531f30da 100644
--- a/docs/default.conf
+++ b/docs/default.conf
@@ -7,4 +7,4 @@ tv-combinedStealFold=True
tv-combined2B3B=True
tv-combinedPostflop=True
bulkImport-defaultPath=default
-tv-defaultPath=default
+hud-defaultPath=default
diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt
index af68054d..edf1469a 100644
--- a/docs/known-bugs-and-planned-features.txt
+++ b/docs/known-bugs-and-planned-features.txt
@@ -3,7 +3,8 @@ Everything is subject to change and especially the order will often change. Patc
alpha2 (release by 17Aug)
======
-auto-import
+implement gametypes.base/hiLo
+
seperate and improve instructions for update
verify link in release notes
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
======
+export settings[hud-defaultInterval] to conf
fix up bg colours in tv
fill the fold to CB/2B/3B cache fields
verify the totalProfit cache field
@@ -33,7 +35,7 @@ printhand each and the 2/3 relevant printplayerflags respectively on ps-lhe-ring
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
gentoo ebuild: USE postgresql
skins
diff --git a/docs/tabledesign.html b/docs/tabledesign.html
index 33030de0..46b905a7 100644
--- a/docs/tabledesign.html
+++ b/docs/tabledesign.html
@@ -136,6 +136,13 @@ The program itself is licensed under AGPLv3, see agpl-3.0.txt
ring - ringgames aka cash games
tour - tournament incl SnG
+
+ base |
+ char(4) |
+ The underlying structure. valid entries:
+ hold - Holdem and Omaha
+ stud - Stud and Razz |
+
category |
varchar(9) |
@@ -156,6 +163,14 @@ The program itself is licensed under AGPLv3, see agpl-3.0.txt
cp=Cap Pot Limit
fl=Fixed Limit
+
+ hiLo |
+ char(1) |
+ Whether the game is hi, lo or both. Valid Entries:
+ h - High only
+ l - Low only
+ s - Hi/Lo Split |
+
smallBlind |
int |
diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py
new file mode 100644
index 00000000..e0bf4e98
--- /dev/null
+++ b/pyfpdb/GuiAutoImport.py
@@ -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 .
+#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__
diff --git a/pyfpdb/import_threaded.py b/pyfpdb/GuiBulkImport.py
similarity index 99%
rename from pyfpdb/import_threaded.py
rename to pyfpdb/GuiBulkImport.py
index 74bb5878..279337c8 100644
--- a/pyfpdb/import_threaded.py
+++ b/pyfpdb/GuiBulkImport.py
@@ -23,7 +23,7 @@ pygtk.require('2.0')
import gtk
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):
"""imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it"""
self.path=self.inputFile
diff --git a/pyfpdb/table_viewer.py b/pyfpdb/GuiTableViewer.py
similarity index 99%
rename from pyfpdb/table_viewer.py
rename to pyfpdb/GuiTableViewer.py
index 164e47b6..345333a0 100644
--- a/pyfpdb/table_viewer.py
+++ b/pyfpdb/GuiTableViewer.py
@@ -24,7 +24,7 @@ import MySQLdb
import fpdb_import
import fpdb_db
-class table_viewer (threading.Thread):
+class GuiTableViewer (threading.Thread):
def hudDivide (self, a, b):
if b==0:
return "n/a"
@@ -279,7 +279,7 @@ class table_viewer (threading.Thread):
self.filename_label.show()
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.settings_hbox.pack_start(self.filename_tview, True, True, padding=5)
self.filename_tview.show()
diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py
index 65dd7c64..2bb9fa42 100755
--- a/pyfpdb/fpdb.py
+++ b/pyfpdb/fpdb.py
@@ -24,8 +24,9 @@ import gtk
import fpdb_db
import fpdb_simple
-import import_threaded
-import table_viewer
+import GuiBulkImport
+import GuiTableViewer
+import GuiAutoImport
class fpdb:
def tab_clicked(self, widget, tab_name):
@@ -250,10 +251,12 @@ class fpdb:
if self.settings['os']=="windows":
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:
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)):
if lines[i].startswith("db-backend="):
@@ -284,9 +287,9 @@ class fpdb:
elif lines[i].startswith("bulkImport-defaultPath="):
if lines[i][23:-1]!="default":
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":
- self.settings['tv-defaultPath']=lines[i][15:-1]
+ self.settings['hud-defaultPath']=lines[i][16:-1]
elif lines[i].startswith("#"):
pass #comment - dont parse
else:
@@ -324,16 +327,20 @@ class fpdb:
#end def tab_abbreviations
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
def tab_bulk_import(self, widget, data):
"""opens a tab for bulk importing"""
#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)
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
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):
"""opens a table viewer tab"""
#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)
tv_tab=new_tv_thread.get_vbox()
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.connect("delete_event", self.delete_event)
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_size_request(1020,400)
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, "" ),
( "/Main/_Quit", "Q", self.quit, 0, None ),
( "/_Import", None, None, 0, "" ),
- ( "/Import/_Import Files and Directories", "I", self.tab_bulk_import, 0, None ),
+ ( "/Import/_Bulk Import", "B", self.tab_bulk_import, 0, None ),
( "/Import/_Auto Import (todo)", "A", self.tab_auto_import, 0, None ),
( "/Import/Auto _Rating (todo)", "R", self.not_implemented, 0, None ),
( "/_Viewers", None, None, 0, "" ),