Merge branch 'master' of git://git.assembla.com/free_poker_tools

Conflicts:

	pyfpdb/fpdb_import.py
This commit is contained in:
Worros 2009-02-11 16:40:33 +09:00
commit dcee1c6d28
15 changed files with 287 additions and 265 deletions

View File

@ -1,3 +1,7 @@
This file is badly out of date, but I'm going to leave it here for now. :)
More up-to-date information is on the wiki: http://fpdb.wiki.sourceforge.net/
REB 30-Jan-2009
Everything is subject to change and the order does not indicate priority. Patches for any of these or other features are very welcome, see readme-overview.txt for contacts. Everything is subject to change and the order does not indicate priority. Patches for any of these or other features are very welcome, see readme-overview.txt for contacts.
Please also see db-todo.txt Please also see db-todo.txt

View File

@ -1,3 +1,7 @@
This file is badly out of date, but I'm going to leave it here for now. :)
More up-to-date information is on the wiki: http://fpdb.wiki.sourceforge.net/
REB 30-Jan-2009
Hi, Hi,
This document is to serve as a little overview (later: full technical doc) for current and prospective developers with: This document is to serve as a little overview (later: full technical doc) for current and prospective developers with:
a) introduction into the code structure a) introduction into the code structure

View File

@ -1,3 +1,8 @@
This file is badly out of date, but I'm going to leave it here for now. :)
More up-to-date information is on the wiki: http://fpdb.wiki.sourceforge.net/
REB 30-Jan-2009
Summary Summary
======= =======
A database program to track your online poker games, the behaviour of the other players and your winnings/losses. Supports Holdem, Omaha, Stud and Razz for cash games as well as SnG and MTT tournaments with more possibly coming in the future. Some of this is not yet working though, please see status.txt and known-bugs-and-planned-features.txt A database program to track your online poker games, the behaviour of the other players and your winnings/losses. Supports Holdem, Omaha, Stud and Razz for cash games as well as SnG and MTT tournaments with more possibly coming in the future. Some of this is not yet working though, please see status.txt and known-bugs-and-planned-features.txt

View File

@ -1,3 +1,7 @@
This file is badly out of date, but I'm going to leave it here for now. :)
More up-to-date information is on the wiki: http://fpdb.wiki.sourceforge.net/
REB 30-Jan-2009
Before you do this make sure you setup the dependencies, the database, user, tables and config file. Before you do this make sure you setup the dependencies, the database, user, tables and config file.
Running it Running it

View File

@ -1,3 +1,7 @@
This file is badly out of date, but I'm going to leave it here for now. :)
More up-to-date information is on the wiki: http://fpdb.wiki.sourceforge.net/
REB 30-Jan-2009
For all support please note that the tables WILL be changed, almost certainly without keeping backwards compatibility. Therefore you should keep your history files after import so you can re-import when necessary. Should you lose history files and need a "database updater" let me know. For all support please note that the tables WILL be changed, almost certainly without keeping backwards compatibility. Therefore you should keep your history files after import so you can re-import when necessary. Should you lose history files and need a "database updater" let me know.
If support for another site/game would encourage you to help with this software please let me know at steffen@sycamoretest.info. If support for another site/game would encourage you to help with this software please let me know at steffen@sycamoretest.info.

View File

@ -1,7 +1,7 @@
# Copyright 1999-2008 Gentoo Foundation # Copyright 1999-2008 Gentoo Foundation
# Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them. # Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them.
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha8_p137.ebuild,v 1.0 2008/10/17 steffen@sycamoretest.info Exp $ # $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-0.10.ebuild,v 1.0 2009/1/30 steffen@sycamoretest.info Exp $
NEED_PYTHON=2.3 NEED_PYTHON=2.3

View File

@ -1,62 +0,0 @@
# Copyright 1999-2008 Gentoo Foundation
# Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha8_p137.ebuild,v 1.0 2008/10/17 steffen@sycamoretest.info Exp $
NEED_PYTHON=2.3
#inherit distutils
MY_P="fpdb-${PV}"
DESCRIPTION="A database program to track your online poker games"
HOMEPAGE="https://sourceforge.net/projects/fpdb/"
SRC_URI="mirror://sourceforge/fpdb/${MY_P}.tar.bz2"
LICENSE="AGPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
#note: this should work on other architectures too, please send me your experiences
IUSE=""
RDEPEND="virtual/mysql
dev-python/mysql-python
>=x11-libs/gtk+-2.10
dev-python/pygtk
dev-python/numpy
dev-python/matplotlib"
DEPEND="${RDEPEND}"
src_install() {
DIRINST="${D}usr/share/games/fpdb/"
mkdir -p "${DIRINST}"
cp -R * "${DIRINST}" || die
DIRBIN="${D}usr/games/bin/"
mkdir -p "${DIRBIN}"
#echo "pathes"
#echo "${DIRINST}pyfpdb/fpdb.py"
#echo "${DIRBIN}fpdb.py"
#echo
echo "cd /usr/share/games/fpdb/pyfpdb/ && python fpdb.py" > "${DIRBIN}fpdb" || die
chmod 755 "${DIRBIN}fpdb" || die
}
#src_test() {
#}
pkg_postinst() {
elog "Fpdb has been installed and can be called by executing /usr/games/bin/fpdb"
elog "You need to perform a couple more steps manually."
elog "Please also make sure you followed instructions from previous emerges, in particular make sure you configured mysql and set a root pw for it"
elog "Now run this command to connect to MySQL: mysql --user=root --password=yourPassword"
elog "In the mysql command line interface you need to type these two lines (make sure you get the ; at the end)"
elog "In the second line replace \"newPassword\" with a password of your choice"
elog "CREATE DATABASE fpdb;"
elog "GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;"
elog "Finally copy the default config file from ${DIRINST}docs/default.conf to ~/.fpdb/ for every user that is to use fpdb."
elog "You will need to edit the default.conf, in particular you need to replace the password with what you entered in the \"GRANT ALL...\""
elog "Finally run the GUI and click the menu database -> recreate tables"
elog "That's it! See our webpage at http://fpdb.sourceforge.net for more documentation"
elog " "
}

View File

@ -1,22 +0,0 @@
#!/bin/sh
#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.
rm regression-test/*.found.txt
rm regression-test/*.pyc
rm pyfpdb/*.pyc
git-add--interactive

View File

@ -1,4 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2008 Steffen Jobbagy-Felso # Copyright 2008 Steffen Jobbagy-Felso
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
@ -15,54 +16,53 @@
# In the "official" distribution you can find the license in # In the "official" distribution you can find the license in
# agpl-3.0.txt in the docs folder of the package. # agpl-3.0.txt in the docs folder of the package.
import threading # Standard Library modules
import fpdb_simple import os
import fpdb_import from time import time
# pyGTK modules
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk import gtk
import os #todo: remove this once import_dir is in fpdb_import
from time import time
class GuiBulkImport (threading.Thread): # fpdb/FreePokerTools modules
import fpdb_simple
import fpdb_import
import fpdb_db
import Configuration
class GuiBulkImport():
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
self.importer.addImportDirectory(self.path) self.importer.addImportDirectory(self.path)
self.importer.setCallHud(False) self.importer.setCallHud(False)
starttime = time() starttime = time()
(stored, dups, partial, errs, ttime) = self.importer.runImport() (stored, dups, partial, errs, ttime) = self.importer.runImport()
print "GuiBulkImport.import_dir done: Stored: %d Dupllicates: %d Partial: %d Errors: %d in %s seconds - %d/sec" %(stored, dups, partial, errs, ttime, (stored/ttime)) print 'GuiBulkImport.import_dir done: Stored: %d Duplicates: %d Partial: %d Errors: %d in %s seconds - %d/sec'\
% (stored, dups, partial, errs, ttime, stored / ttime)
def load_clicked(self, widget, data=None): def load_clicked(self, widget, data=None):
# get the dir to import from the chooser
self.inputFile = self.chooser.get_filename() self.inputFile = self.chooser.get_filename()
self.handCount=self.hand_count_tbuffer.get_text(self.hand_count_tbuffer.get_start_iter(), self.hand_count_tbuffer.get_end_iter()) # get the import settings from the gui and save in the importer
if (self.handCount=="unlimited" or self.handCount=="Unlimited"): self.importer.setHandCount(int(self.spin_hands.get_text()))
self.importer.setHandCount(0) self.importer.setMinPrint(int(self.spin_hands.get_text()))
self.importer.setQuiet(self.chk_st_st.get_active())
self.importer.setFailOnError(self.chk_fail.get_active())
self.importer.setThreads(int(self.spin_threads.get_text()))
self.importer.setHandsInDB(self.n_hands_in_db)
cb_model = self.cb.get_model()
cb_index = self.cb.get_active()
if cb_index:
self.importer.setDropIndexes(cb_model[cb_index][0])
else: else:
self.importer.setHandCount(int(self.handCount)) self.importer.setDropIndexes("auto")
self.errorFile="failed.txt"
self.minPrint=self.min_print_tbuffer.get_text(self.min_print_tbuffer.get_start_iter(), self.min_print_tbuffer.get_end_iter())
if (self.minPrint=="never" or self.minPrint=="Never"):
self.importer.setMinPrint(0)
else:
self.importer.setMinPrint=int(self.minPrint)
self.quiet=self.info_tbuffer.get_text(self.info_tbuffer.get_start_iter(), self.info_tbuffer.get_end_iter())
if (self.quiet=="yes"):
self.importer.setQuiet(False)
else:
self.importer.setQuiet(True)
self.failOnError=self.fail_error_tbuffer.get_text(self.fail_error_tbuffer.get_start_iter(), self.fail_error_tbuffer.get_end_iter())
if (self.failOnError=="no"):
self.importer.setFailOnError(False)
else:
self.importer.setFailOnError(True)
self.lab_info.set_text("Importing")
if os.path.isdir(self.inputFile): if os.path.isdir(self.inputFile):
self.import_dir() self.import_dir()
else: else:
@ -71,86 +71,142 @@ class GuiBulkImport (threading.Thread):
self.importer.runImport() self.importer.runImport()
self.importer.clearFileList() self.importer.clearFileList()
def get_vbox(self): self.lab_info.set_text("Import finished")
"""returns the vbox of this thread"""
return self.vbox
#end def get_vbox
def run (self):
print "todo: implement bulk import thread"
#end def run
def __init__(self, db, settings, config): def __init__(self, db, settings, config):
self.db=db self.db = db # this is an instance of fpdb_db
self.settings = settings self.settings = settings
self.config = config self.config = config
self.importer = fpdb_import.Importer(self,self.settings, config) self.importer = fpdb_import.Importer(self, self.settings,
config)
self.vbox=gtk.VBox(False,1) self.vbox = gtk.VBox(False, 0)
self.vbox.show() self.vbox.show()
self.chooser = gtk.FileChooserWidget() self.chooser = gtk.FileChooserWidget()
self.chooser.set_filename(self.settings['bulkImport-defaultPath']) self.chooser.set_filename(self.settings['bulkImport-defaultPath'])
#chooser.set_default_response(gtk.RESPONSE_OK)
#self.filesel.ok_button.connect_object("clicked", gtk.Widget.destroy, self.filesel)
self.vbox.add(self.chooser) self.vbox.add(self.chooser)
self.chooser.show() self.chooser.show()
# Table widget to hold the settings
self.table = gtk.Table(rows = 3, columns = 5, homogeneous = False)
self.vbox.add(self.table)
self.table.show()
self.settings_hbox = gtk.HBox(False, 0) # checkbox - print start/stop?
self.vbox.pack_end(self.settings_hbox, False, True, 0) self.chk_st_st = gtk.CheckButton('Print Start/Stop Info')
self.settings_hbox.show() self.table.attach(self.chk_st_st, 0, 1, 0, 1, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
self.chk_st_st.show()
self.chk_st_st.set_active(True)
self.hand_count_label = gtk.Label("Hands to import per file") # label - status
self.settings_hbox.add(self.hand_count_label) self.lab_status = gtk.Label("Hands/status print:")
self.hand_count_label.show() self.table.attach(self.lab_status, 1, 2, 0, 1, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
self.lab_status.show()
self.lab_status.set_justify(gtk.JUSTIFY_RIGHT)
self.hand_count_tbuffer=gtk.TextBuffer() # spin button - status
self.hand_count_tbuffer.set_text("unlimited") status_adj = gtk.Adjustment(value=100, lower=0, upper=300, step_incr=10, page_incr=1, page_size=0) #not sure what upper value should be!
self.hand_count_tview=gtk.TextView(self.hand_count_tbuffer) self.spin_status = gtk.SpinButton(adjustment=status_adj, climb_rate=0.0, digits=0)
self.settings_hbox.add(self.hand_count_tview) self.table.attach(self.spin_status, 2, 3, 0, 1, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
self.hand_count_tview.show() self.spin_status.show()
self.min_hands_label = gtk.Label("Status every") # label - threads
self.settings_hbox.add(self.min_hands_label) self.lab_threads = gtk.Label("Number of threads:")
self.min_hands_label.show() self.table.attach(self.lab_threads, 3, 4, 0, 1, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
self.lab_threads.show()
self.lab_threads.set_sensitive(False)
self.lab_threads.set_justify(gtk.JUSTIFY_RIGHT)
self.min_print_tbuffer=gtk.TextBuffer() # spin button - threads
self.min_print_tbuffer.set_text("never") threads_adj = gtk.Adjustment(value=0, lower=0, upper=10, step_incr=1, page_incr=1, page_size=0) #not sure what upper value should be!
self.min_print_tview=gtk.TextView(self.min_print_tbuffer) self.spin_threads = gtk.SpinButton(adjustment=threads_adj, climb_rate=0.0, digits=0)
self.settings_hbox.add(self.min_print_tview) self.table.attach(self.spin_threads, 4, 5, 0, 1, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
self.min_print_tview.show() self.spin_threads.show()
self.spin_threads.set_sensitive(False)
# checkbox - fail on error?
self.chk_fail = gtk.CheckButton('Fail on error')
self.table.attach(self.chk_fail, 0, 1, 1, 2, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
self.chk_fail.show()
self.toggles_hbox = gtk.HBox(False, 0) # label - hands
self.vbox.pack_end(self.toggles_hbox, False, True, 0) self.lab_hands = gtk.Label("Hands/file:")
self.toggles_hbox.show() self.table.attach(self.lab_hands, 1, 2, 1, 2, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
self.lab_hands.show()
self.lab_hands.set_justify(gtk.JUSTIFY_RIGHT)
self.info_label = gtk.Label("Print start/end info:") # spin button - hands to import
self.toggles_hbox.add(self.info_label) hands_adj = gtk.Adjustment(value=0, lower=0, upper=10, step_incr=1, page_incr=1, page_size=0) #not sure what upper value should be!
self.info_label.show() self.spin_hands = gtk.SpinButton(adjustment=hands_adj, climb_rate=0.0, digits=0)
self.table.attach(self.spin_hands, 2, 3, 1, 2, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
self.spin_hands.show()
self.info_tbuffer=gtk.TextBuffer() # label - drop indexes
self.info_tbuffer.set_text("yes") self.lab_drop = gtk.Label("Drop indexes:")
self.info_tview=gtk.TextView(self.info_tbuffer) self.table.attach(self.lab_drop, 3, 4, 1, 2, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
self.toggles_hbox.add(self.info_tview) self.lab_drop.show()
self.info_tview.show() self.lab_drop.set_justify(gtk.JUSTIFY_RIGHT)
self.fail_error_label = gtk.Label("Fail on error:") # ComboBox - drop indexes
self.toggles_hbox.add(self.fail_error_label) self.cb = gtk.combo_box_new_text()
self.fail_error_label.show() self.cb.append_text('auto')
self.cb.append_text("don't drop")
self.cb.append_text('drop')
self.cb.set_active(0)
self.table.attach(self.cb, 4, 5, 1, 2, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
self.cb.show()
self.fail_error_tbuffer=gtk.TextBuffer() # label - info
self.fail_error_tbuffer.set_text("no") self.lab_info = gtk.Label()
self.fail_error_tview=gtk.TextView(self.fail_error_tbuffer) self.table.attach(self.lab_info, 0, 4, 2, 3, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
self.toggles_hbox.add(self.fail_error_tview) self.lab_info.show()
self.fail_error_tview.show()
self.load_button = gtk.Button("Import") #todo: rename variables to import too # button - Import
self.load_button.connect("clicked", self.load_clicked, "Import clicked") self.load_button = gtk.Button('Import') # todo: rename variables to import too
self.toggles_hbox.add(self.load_button) self.load_button.connect('clicked', self.load_clicked,
'Import clicked')
self.table.attach(self.load_button, 4, 5, 2, 3, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK)
self.load_button.show() self.load_button.show()
threading.Thread.__init__ ( self ) # see how many hands are in the db and adjust accordingly
print "initialised new bulk import thread (not actually a thread yet)" db_parms = config.get_db_parameters('fpdb')
#end class import_threaded db.connect(db_parms['db-backend'],
db_parms['db-host'],
db_parms['db-databaseName'],
db_parms['db-user'],
db_parms['db-password'])
cursor = db.db.cursor()
cursor.execute("Select max(id) from Hands;")
row = cursor.fetchone()
db.disconnect() # that's all we need this for
self.n_hands_in_db = row[0]
if self.n_hands_in_db == 0:
self.cb.set_active(2)
self.cb.set_sensitive(False)
self.lab_drop.set_sensitive(False)
if __name__ == '__main__':
def destroy(*args): # call back for terminating the main eventloop
gtk.main_quit()
config = Configuration.Config()
db = fpdb_db.fpdb_db()
settings = {}
if os.name == 'nt': settings['os'] = 'windows'
else: settings['os'] = 'linuxmac'
settings.update(config.get_db_parameters('fpdb'))
settings.update(config.get_tv_parameters())
settings.update(config.get_import_parameters())
settings.update(config.get_default_paths())
i = GuiBulkImport(db, settings, config)
main_window = gtk.Window()
main_window.connect('destroy', destroy)
main_window.add(i.vbox)
main_window.show()
gtk.main()

View File

@ -121,11 +121,6 @@ def read_stdin(): # This is the thread function
destroy() destroy()
break # this thread is not always killed immediately with gtk.main_quit() break # this thread is not always killed immediately with gtk.main_quit()
# delete hud_dict entries for any HUD destroyed since last iteration
# for h in hud_dict:
# HUD_removed(h)
# removing this function, we shouldn't need it anymore, since the hud should notify us anyway, right?
# get basic info about the new hand from the db # get basic info about the new hand from the db
(table_name, max, poker_game) = db_connection.get_table_name(new_hand_id) (table_name, max, poker_game) = db_connection.get_table_name(new_hand_id)

View File

@ -361,7 +361,7 @@ def clean_title(name):
' \(deep hu\)', ' \(deep 6\)', ' \(2\)', ' \(deep hu\)', ' \(deep 6\)', ' \(2\)',
' \(edu\)', ' \(edu, 6 max\)', ' \(6\)', ' \(edu\)', ' \(edu, 6 max\)', ' \(6\)',
' \(speed\)', ' \(speed\)',
' no all-in', ' fast', ',', ' 50BB min', '\s+$']: ' no all-in', ' fast', ',', ' 50BB min', '50bb min', '\s+$']:
name = re.sub(pattern, '', name) name = re.sub(pattern, '', name)
name = name.rstrip() name = name.rstrip()
return name return name

View File

@ -44,6 +44,8 @@ import GuiGraphViewer
import FpdbSQLQueries import FpdbSQLQueries
import Configuration import Configuration
VERSION = "0.10"
class fpdb: class fpdb:
def tab_clicked(self, widget, tab_name): def tab_clicked(self, widget, tab_name):
"""called when a tab button is clicked to activate that tab""" """called when a tab button is clicked to activate that tab"""
@ -114,7 +116,8 @@ class fpdb:
#end def destroy #end def destroy
def dia_about(self, widget, data): def dia_about(self, widget, data):
print "todo: implement dia_about" print "todo: implement dia_about",
print " version = %s, requires database version %s" % (VERSION, "118")
#end def dia_about #end def dia_about
def dia_create_del_database(self, widget, data): def dia_create_del_database(self, widget, data):
@ -376,7 +379,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: alpha9+, p143 or higher") self.window.set_title("Free Poker DB - v%s or higher" % (VERSION, ))
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)

View File

@ -17,8 +17,25 @@
#see status.txt for site/games support info #see status.txt for site/games support info
import sys # Standard Library modules
import os # todo: remove this once import_dir is in fpdb_import
import sys
from time import time
import traceback
import math
import datetime
import re
# fpdb/FreePokerTools modules
import fpdb_simple
import fpdb_db
import fpdb_parse_logic
import Configuration
import EverleafToFpdb
# database interface modules
try: try:
import MySQLdb import MySQLdb
mysqlLibFound=True mysqlLibFound=True
@ -31,17 +48,6 @@ try:
except: except:
pass pass
import traceback
import math
import os
import datetime
import re
import fpdb_db
import fpdb_simple
import fpdb_parse_logic
import EverleafToFpdb
from time import time
class Importer: class Importer:
def __init__(self, caller, settings, config): def __init__(self, caller, settings, config):
@ -85,6 +91,15 @@ class Importer:
def setFailOnError(self, value): def setFailOnError(self, value):
self.settings['failOnError'] = value self.settings['failOnError'] = value
def setHandsInDB(self, value):
self.settings['handsInDB'] = value
def setThreads(self, value):
self.settings['threads'] = value
def setDropIndexes(self, value):
self.settings['dropIndexes'] = value
# def setWatchTime(self): # def setWatchTime(self):
# self.updated = time() # self.updated = time()
@ -93,7 +108,7 @@ class Importer:
#Add an individual file to filelist #Add an individual file to filelist
def addImportFile(self, filename, site = "default", filter = "passthrough"): def addImportFile(self, filename, site = "default", filter = "passthrough"):
#TODO: test it is a valid file #TODO: test it is a valid file -> put that in config!!
self.filelist[filename] = [site] + [filter] self.filelist[filename] = [site] + [filter]
#Add a directory of files to filelist #Add a directory of files to filelist
@ -111,14 +126,20 @@ class Importer:
else: else:
print "Warning: Attempted to add non-directory: '" + str(dir) + "' as an import directory" print "Warning: Attempted to add non-directory: '" + str(dir) + "' as an import directory"
#Run full import on filelist
def runImport(self): def runImport(self):
""""Run full import on self.filelist."""
start = datetime.datetime.now()
print "started at", start, "--", len(self.filelist), "files to import.", self.settings['dropIndexes']
if self.settings['dropIndexes'] == 'auto':
self.settings['dropIndexes'] = self.calculate_auto()
if self.settings['dropIndexes'] == 'drop':
fpdb_simple.prepareBulkImport(self.fdb) fpdb_simple.prepareBulkImport(self.fdb)
totstored = 0 totstored = 0
totdups = 0 totdups = 0
totpartial = 0 totpartial = 0
toterrors = 0 toterrors = 0
tottime = 0 tottime = 0
# if threads <= 1: do this bit
for file in self.filelist: for file in self.filelist:
(stored, duplicates, partial, errors, ttime) = self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1]) (stored, duplicates, partial, errors, ttime) = self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
totstored += stored totstored += stored
@ -126,9 +147,19 @@ class Importer:
totpartial += partial totpartial += partial
toterrors += errors toterrors += errors
tottime += ttime tottime += ttime
if self.settings['dropIndexes'] == 'drop':
fpdb_simple.afterBulkImport(self.fdb) fpdb_simple.afterBulkImport(self.fdb)
fpdb_simple.analyzeDB(self.fdb) fpdb_simple.analyzeDB(self.fdb)
return (totstored, totdups, totpartial, toterrors, tottime) return (totstored, totdups, totpartial, toterrors, tottime)
# else: import threaded
def calculate_auto(self):
"""An heuristic to determine a reasonable value of drop/don't drop"""
if len(self.filelist) == 1: return "don't drop"
if self.settings['handsInDB'] < 5000: return "drop"
if len(self.filelist) < 50: return "don't drop"
if self.settings['handsInDB'] > 50000: return "don't drop"
return "drop"
#Run import on updated files, then store latest update time. #Run import on updated files, then store latest update time.
def runUpdated(self): def runUpdated(self):

View File

View File

@ -15,23 +15,23 @@
#In the "official" distribution you can find the license in #In the "official" distribution you can find the license in
#agpl-3.0.txt in the docs folder of the package. #agpl-3.0.txt in the docs folder of the package.
#get rid of extraneous stuff
rm regression-test/*.found.txt rm regression-test/*.found.txt
rm regression-test/*.pyc rm regression-test/*.pyc
rm pyfpdb/*.pyc rm pyfpdb/*.pyc
mkdir fpdb-$1 # make the fpdb_$1.zip file for windows
cp -R docs fpdb-$1/ echo "*** making zip file"
cp -R packaging fpdb-$1/ zip -r ../fpdb_$1.zip docs
cp -R pyfpdb fpdb-$1/ zip -r ../fpdb_$1.zip ignore-me_perl6
rm fpdb-$1/pyfpdb/HUD_config.* zip -r ../fpdb_$1.zip packaging
cp pyfpdb/HUD_config.xml.example fpdb-$1/pyfpdb/HUD_config.xml zip -r ../fpdb_$1.zip pyfpdb
cp -R regression-test fpdb-$1/ zip -r ../fpdb_$1.zip regression-test
cp -R utils fpdb-$1/ zip -r ../fpdb_$1.zip utils
zip -r ../fpdb_$1.zip website
# now make the fpdb_$1.tar.bz2 file for linux
echo "*** making tar.bz2 file"
tar --recursion -cjf ../fpdb_$1.tar.bz2 *
cd fpdb-$1
zip -r releases/fpdb-1.0_$1.zip *
tar -cf - * | bzip2 >> releases/fpdb-1.0_$1.tar.bz2
cd ..
rm -r fpdb-$1
echo "Please ensure the files are named fpdb-1.0_alpha*_p*.*"