From cb99327fd929e145aa62c8b48e6c93c3a379a69f Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 16 Feb 2011 15:50:21 +0800 Subject: [PATCH] AutoImport: Add hidden button for auto-detection Discovered that I didn't have an easy way to report that info back to the gtk widget and got bored. Maybe someone else will take it up. --- pyfpdb/GuiAutoImport.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 70a12215..258dd975 100755 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -122,6 +122,10 @@ class GuiAutoImport (threading.Thread): self.startButton.connect("clicked", self.startClicked, "start clicked") hbox.pack_start(self.startButton, expand=False, fill=False) + self.DetectButton = gtk.Button(_("Detect Directories")) + self.DetectButton.connect("clicked", self.detect_hh_dirs, "detect") + #hbox.pack_start(self.DetectButton, expand=False, fill=False) + lbl2 = gtk.Label() hbox.pack_start(lbl2, expand=True, fill=False) @@ -190,6 +194,31 @@ class GuiAutoImport (threading.Thread): return False + def detect_hh_dirs(self, widget, data): + """Attempt to find user hand history directories for enabled sites""" + the_sites = self.config.get_supported_sites() + for site in the_sites: + params = self.config.get_site_parameters(site) + if params['enabled'] == True: + print "DEBUG: Detecting hh directory for site: '%s'" % site + if os.name == 'posix': + if self.posix_detect_hh_dirs(site): + #data[1].set_text(dia_chooser.get_filename()) + self.input_settings[site][0] + pass + elif os.name == 'nt': + # Sorry + pass + + def posix_detect_hh_dirs(self, site): + defaults = { + 'PokerStars': '~/.wine/drive_c/Program Files/PokerStars/HandHistory', + } + if site == 'PokerStars': + directory = os.path.expanduser(defaults[site]) + for file in [file for file in os.listdir(directory) if not file in [".",".."]]: + print file + return False def startClicked(self, widget, data): """runs when user clicks start on auto import tab"""