diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 3bcaaa91..091b2d47 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -25,6 +25,7 @@ Handles HUD configuration files. # Standard Library modules import os import sys +import inspect import string import traceback import shutil @@ -582,6 +583,10 @@ class Config: sg.append(c.supported_games[game].game_name) return sg + def execution_path(self, filename): + """Join the fpdb path to filename.""" + return os.path.join(os.path.dirname(inspect.getfile(sys._getframe(1))), filename) + if __name__== "__main__": c = Config() @@ -638,3 +643,5 @@ if __name__== "__main__": for game in c.get_supported_games(): print c.get_game_parameters(game) + + print "start up path = ", c.execution_path("") \ No newline at end of file diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index bb5e0386..ffe46bb1 100644 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -23,6 +23,7 @@ pygtk.require('2.0') import gtk import gobject import os +import sys import time import fpdb_import @@ -104,7 +105,7 @@ class GuiAutoImport (threading.Thread): self.importer.runUpdated() print "GuiAutoImport.import_dir done" return True - + def startClicked(self, widget, data): """runs when user clicks start on auto import tab""" @@ -126,8 +127,7 @@ class GuiAutoImport (threading.Thread): self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE, universal_newlines=True) else: - cwd = os.getcwd() - command = os.path.join(cwd, 'HUD_main.py') + command = self.config.execution_path('HUD_main.py') bs = 1 self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE, universal_newlines=True) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 1c83ef9b..7cb62918 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -266,7 +266,7 @@ class Stud_cards: card_images = {} suits = ('S', 'H', 'D', 'C') ranks = ('A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2', 'B') - pb = gtk.gdk.pixbuf_new_from_file("54PFozzycards0.png") + pb = gtk.gdk.pixbuf_new_from_file(self.config.execution_path("54PFozzycards0.png")) for j in range(0, 14): for i in range(0, 4): diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index 6eaf1c93..54079425 100755 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -342,6 +342,7 @@ def clean_title(name): for pattern in [' \(6 max\)', ' \(heads up\)', ' \(deep\)', ' \(deep hu\)', ' \(deep 6\)', ' \(2\)', ' \(edu\)', ' \(edu, 6 max\)', ' \(6\)', + ' \(speed\)', ' no all-in', ' fast', ',', ' 50BB min', '\s+$']: name = re.sub(pattern, '', name) name = name.rstrip() @@ -368,12 +369,12 @@ def discover_mac_by_name(c, tablename): if __name__=="__main__": c = Configuration.Config() - print discover_table_by_name(c, "Louie") + print discover_table_by_name(c, "Ringe") # print discover_tournament_table(c, "118942908", "3") - tables = discover(c) - for t in tables.keys(): - print tables[t] +# tables = discover(c) +# for t in tables.keys(): +# print tables[t] print "press enter to continue" sys.stdin.readline() diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index d257fe15..7c9bbe21 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -771,7 +771,7 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo print "line:",line,"cardValues[playerNo]:",cardValues[playerNo] raise FpdbError("read too many/too few holecards in parseCardLine") elif (category=="razz" or category=="studhi" or category=="studhilo"): - if (line.find("shows")==-1): + if (line.find("shows")==-1 and line.find("mucked")==-1): #print "parseCardLine(in stud if), street:", street if line[pos+2]=="]": #-> not (hero and 3rd street) cardValues[playerNo][street+2]=line[pos:pos+1] @@ -1005,7 +1005,15 @@ def parseTableLine(site, base, line): elif line.find("heads up")!=-1: maxSeats=2 - return {'maxSeats':maxSeats, 'tableName':line[pos1:pos2]} + tableName = line[pos1:pos2] + for pattern in [' \(6 max\)', ' \(heads up\)', ' \(deep\)', + ' \(deep hu\)', ' \(deep 6\)', ' \(2\)', + ' \(edu\)', ' \(edu, 6 max\)', ' \(6\)', + ' \(speed\)', + ' no all-in', ' fast', ',', ' 50BB min', '\s+$']: + tableName = re.sub(pattern, '', tableName) + tableName = tableName.rstrip() + return {'maxSeats':maxSeats, 'tableName':tableName} else: raise FpdbError("invalid site ID") #end def parseTableLine