From d73a4614f35e2d9df729816747b37d7e82a242bc Mon Sep 17 00:00:00 2001 From: steffen123 Date: Tue, 19 Aug 2008 23:38:01 +0100 Subject: [PATCH] p60 - patches from ray - autoimport now doesnt block GUI and calls HUD. --- docs/known-bugs-and-planned-features.txt | 1 + pyfpdb/GuiAutoImport.py | 25 ++++++++++++++++++++---- pyfpdb/fpdb_import.py | 2 ++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt index f6ae60dc..06ae9033 100644 --- a/docs/known-bugs-and-planned-features.txt +++ b/docs/known-bugs-and-planned-features.txt @@ -3,6 +3,7 @@ Everything is subject to change and especially the order will often change. Patc alpha2 (release by 17Aug) ====== +set hud stats row1: hands, VPIP, PFR, PF3B/4B, ST row2: Aggr% (postflop), Fold% (postflop), W$sF, WtSD, W$@SD make windows use correct language version of Appdata, e.g. Anwendungdaten stop bulk importer from executing HUD hook seperate and improve instructions for update diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index af34ad58..42f5bf6d 100644 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -16,9 +16,12 @@ #agpl-3.0.txt in the docs folder of the package. import threading +import subprocess + import pygtk pygtk.require('2.0') import gtk +import gobject import os import time import fpdb_import @@ -45,21 +48,35 @@ class GuiAutoImport (threading.Thread): dia_chooser.destroy() #end def GuiAutoImport.browseClicked + def do_import(self): + """Callback for timer to do an import iteration.""" + fpdb_import.import_file_dict(self, self.settings) + return(1) + def startClicked(self, widget, data): """runs when user clicks start on auto import tab""" - + +# Check to see if we have an open file handle to the HUD and open one if we do not. +# bufsize = 1 means unbuffered +# We need to close this file handle sometime. + try: #uhhh, I don't this this is the best way to check for the existence of an attr + getattr(self, "pipe_to_hud") + except AttributeError: + cwd = os.getcwd() + command = os.path.join(cwd, 'HUD_main.py') + self.pipe_to_hud = subprocess.Popen(command, bufsize = 1, stdin = subprocess.PIPE) + self.path=self.pathTBuffer.get_text(self.pathTBuffer.get_start_iter(), self.pathTBuffer.get_end_iter()) for file in os.listdir(self.path): if os.path.isdir(file): print "AutoImport is not recursive - please select the final directory in which the history files are" else: self.inputFile=self.path+os.sep+file - fpdb_import.import_file_dict(self, self.settings) + self.do_import() print "GuiAutoImport.import_dir done" interval=int(self.intervalTBuffer.get_text(self.intervalTBuffer.get_start_iter(), self.intervalTBuffer.get_end_iter())) - time.sleep(interval) - self.startClicked(widget,data) + gobject.timeout_add(interval*1000, self.do_import) #end def GuiAutoImport.browseClicked def get_vbox(self): diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 6bee055c..82c7d968 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -108,6 +108,8 @@ def import_file_dict(options, settings): stored+=1 if settings['imp-callFpdbHud']: print "call to HUD here. handsId:",handsId +# pipe the Hands.id out to the HUD + options.pipe_to_hud.stdin.write("%s\n" % (handsId)) db.commit() except fpdb_simple.DuplicateError: duplicates+=1