Configuration: _getframe(0) so that GuiAutoImport can run standalone
(stack not deep enough to go one deeper) fpdb_import: Everleaf plumbing back in place. GuiAutoImport.py: run standalone.
This commit is contained in:
parent
7049a959ec
commit
75dcf002f9
|
@ -609,7 +609,7 @@ class Config:
|
||||||
|
|
||||||
def execution_path(self, filename):
|
def execution_path(self, filename):
|
||||||
"""Join the fpdb path to filename."""
|
"""Join the fpdb path to filename."""
|
||||||
return os.path.join(os.path.dirname(inspect.getfile(sys._getframe(1))), filename)
|
return os.path.join(os.path.dirname(inspect.getfile(sys._getframe(0))), filename)
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
c = Config()
|
c = Config()
|
||||||
|
|
|
@ -26,7 +26,8 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import fpdb_import
|
import fpdb_import
|
||||||
|
from optparse import OptionParser
|
||||||
|
import Configuration
|
||||||
|
|
||||||
class GuiAutoImport (threading.Thread):
|
class GuiAutoImport (threading.Thread):
|
||||||
def __init__(self, settings, config):
|
def __init__(self, settings, config):
|
||||||
|
@ -134,7 +135,8 @@ class GuiAutoImport (threading.Thread):
|
||||||
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
|
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
else:
|
else:
|
||||||
command = self.config.execution_path('HUD_main.py')
|
# command = os.path.join(os.getcwd(), 'HUD_main.py') # clearly doesn't work if you run from somewhere else.
|
||||||
|
command = self.config.execution_path('HUD_main.py') # Hi Ray. Sorry about this, kludging.
|
||||||
bs = 1
|
bs = 1
|
||||||
self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
|
@ -214,18 +216,39 @@ if __name__== "__main__":
|
||||||
def destroy(*args): # call back for terminating the main eventloop
|
def destroy(*args): # call back for terminating the main eventloop
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
settings = {}
|
# settings = {}
|
||||||
settings['db-host'] = "192.168.1.100"
|
# settings['db-host'] = "192.168.1.100"
|
||||||
settings['db-user'] = "mythtv"
|
# settings['db-user'] = "mythtv"
|
||||||
settings['db-password'] = "mythtv"
|
# settings['db-password'] = "mythtv"
|
||||||
settings['db-databaseName'] = "fpdb"
|
# settings['db-databaseName'] = "fpdb"
|
||||||
settings['hud-defaultInterval'] = 10
|
# settings['hud-defaultInterval'] = 10
|
||||||
settings['hud-defaultPath'] = 'C:/Program Files/PokerStars/HandHistory/nutOmatic'
|
# settings['hud-defaultPath'] = 'C:/Program Files/PokerStars/HandHistory/nutOmatic'
|
||||||
settings['callFpdbHud'] = True
|
# settings['callFpdbHud'] = True
|
||||||
|
|
||||||
i = GuiAutoImport(settings)
|
parser = OptionParser()
|
||||||
main_window = gtk.Window()
|
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True, help="don't start gui")
|
||||||
main_window.connect("destroy", destroy)
|
|
||||||
main_window.add(i.mainVBox)
|
(options, sys.argv) = parser.parse_args()
|
||||||
main_window.show()
|
|
||||||
gtk.main()
|
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())
|
||||||
|
|
||||||
|
if(options.gui == True):
|
||||||
|
i = GuiAutoImport(settings, config)
|
||||||
|
main_window = gtk.Window()
|
||||||
|
main_window.connect('destroy', destroy)
|
||||||
|
main_window.add(i.mainVBox)
|
||||||
|
main_window.show()
|
||||||
|
gtk.main()
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ class HandHistoryConverter(threading.Thread):
|
||||||
self.maxseats = 10
|
self.maxseats = 10
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
#TODO : I got rid of most of the hhdir stuff.
|
||||||
tmp = "HandHistoryConverter: '%s'\n" % (self.sitename)
|
tmp = "HandHistoryConverter: '%s'\n" % (self.sitename)
|
||||||
tmp = tmp + "\thhbase: '%s'\n" % (self.hhbase)
|
tmp = tmp + "\thhbase: '%s'\n" % (self.hhbase)
|
||||||
tmp = tmp + "\thhdir: '%s'\n" % (self.hhdir)
|
tmp = tmp + "\thhdir: '%s'\n" % (self.hhdir)
|
||||||
|
@ -143,13 +144,18 @@ class HandHistoryConverter(threading.Thread):
|
||||||
if gametype is None:
|
if gametype is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
hand = None
|
||||||
if gametype[1] in ("hold", "omaha"):
|
if gametype[1] in ("hold", "omaha"):
|
||||||
hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handtext)
|
hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handtext)
|
||||||
elif gametype[1] in ("razz","stud","stud8"):
|
elif gametype[1] in ("razz","stud","stud8"):
|
||||||
hand = Hand.StudHand(self, self.sitename, gametype, handtext)
|
hand = Hand.StudHand(self, self.sitename, gametype, handtext)
|
||||||
|
|
||||||
hand.writeHand(self.out_fh)
|
if hand:
|
||||||
|
hand.writeHand(self.out_fh)
|
||||||
|
else:
|
||||||
|
logging.info("Unrecognised game type: %s" % gametype[1])
|
||||||
|
# TODO: pity we don't know the HID at this stage. Log the entire hand?
|
||||||
|
# From the log we can deduce that it is the hand after the one before :)
|
||||||
|
|
||||||
|
|
||||||
def processFile(self):
|
def processFile(self):
|
||||||
|
|
|
@ -118,7 +118,6 @@ class Importer:
|
||||||
def addBulkImportImportFileOrDir(self, inputPath,filter = "passthrough"):
|
def addBulkImportImportFileOrDir(self, inputPath,filter = "passthrough"):
|
||||||
"""Add a file or directory for bulk import"""
|
"""Add a file or directory for bulk import"""
|
||||||
# Bulk import never monitors
|
# Bulk import never monitors
|
||||||
|
|
||||||
# if directory, add all files in it. Otherwise add single file.
|
# if directory, add all files in it. Otherwise add single file.
|
||||||
# TODO: only add sane files?
|
# TODO: only add sane files?
|
||||||
if os.path.isdir(inputPath):
|
if os.path.isdir(inputPath):
|
||||||
|
@ -133,6 +132,7 @@ class Importer:
|
||||||
#dirlist is a hash of lists:
|
#dirlist is a hash of lists:
|
||||||
#dirlist{ 'PokerStars' => ["/path/to/import/", "filtername"] }
|
#dirlist{ 'PokerStars' => ["/path/to/import/", "filtername"] }
|
||||||
def addImportDirectory(self,dir,monitor = False, site = "default", filter = "passthrough"):
|
def addImportDirectory(self,dir,monitor = False, site = "default", filter = "passthrough"):
|
||||||
|
#gets called by GuiAutoImport.
|
||||||
#This should really be using os.walk
|
#This should really be using os.walk
|
||||||
#http://docs.python.org/library/os.html
|
#http://docs.python.org/library/os.html
|
||||||
if os.path.isdir(dir):
|
if os.path.isdir(dir):
|
||||||
|
@ -237,12 +237,12 @@ class Importer:
|
||||||
hhbase = os.path.expanduser(hhbase)
|
hhbase = os.path.expanduser(hhbase)
|
||||||
hhdir = os.path.join(hhbase,site)
|
hhdir = os.path.join(hhbase,site)
|
||||||
try:
|
try:
|
||||||
ofile = os.path.join(hhdir, file.split(os.path.sep)[-2]+"-"+os.path.basename(file))
|
out_path = os.path.join(hhdir, file.split(os.path.sep)[-2]+"-"+os.path.basename(file))
|
||||||
except:
|
except:
|
||||||
ofile = os.path.join(hhdir, "x"+strftime("%d-%m-%y")+os.path.basename(file))
|
out_path = os.path.join(hhdir, "x"+strftime("%d-%m-%y")+os.path.basename(file))
|
||||||
out_fh = open(ofile, 'w') # TODO: seek to previous place in input and append output
|
#out_fh = open(ofile, 'w') # TODO: seek to previous place in input and append output
|
||||||
in_fh =
|
conv = EverleafToFpdb.Everleaf(in_path = file, out_path = out_path)
|
||||||
conv = EverleafToFpdb.Everleaf(in_fh = file, out_fh = out_fh)
|
conv.join()
|
||||||
elif filter == "FulltiltToFpdb":
|
elif filter == "FulltiltToFpdb":
|
||||||
print "converting ", file
|
print "converting ", file
|
||||||
conv = FulltiltToFpdb.FullTilt(in_fh = file, out_fh = out_fh)
|
conv = FulltiltToFpdb.FullTilt(in_fh = file, out_fh = out_fh)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user