Modified Auto import GUI to allow n-sites based on config file. Added filter option to display. Added option to enable or disable sites in Config
This commit is contained in:
parent
cf714a8ec1
commit
68344b5ec0
|
@ -57,6 +57,7 @@ class Site:
|
||||||
self.hudbgcolor = node.getAttribute("bgcolor")
|
self.hudbgcolor = node.getAttribute("bgcolor")
|
||||||
self.hudfgcolor = node.getAttribute("fgcolor")
|
self.hudfgcolor = node.getAttribute("fgcolor")
|
||||||
self.converter = node.getAttribute("converter")
|
self.converter = node.getAttribute("converter")
|
||||||
|
self.enabled = node.getAttribute("enabled")
|
||||||
self.layout = {}
|
self.layout = {}
|
||||||
|
|
||||||
for layout_node in node.getElementsByTagName('layout'):
|
for layout_node in node.getElementsByTagName('layout'):
|
||||||
|
@ -494,13 +495,14 @@ class Config:
|
||||||
parms["site_path"] = self.supported_sites[site].site_path
|
parms["site_path"] = self.supported_sites[site].site_path
|
||||||
parms["table_finder"] = self.supported_sites[site].table_finder
|
parms["table_finder"] = self.supported_sites[site].table_finder
|
||||||
parms["HH_path"] = self.supported_sites[site].HH_path
|
parms["HH_path"] = self.supported_sites[site].HH_path
|
||||||
|
parms["enabled"] = self.supported_sites[site].enabled
|
||||||
return parms
|
return parms
|
||||||
|
|
||||||
def set_site_parameters(self, site_name, converter = None, decoder = None,
|
def set_site_parameters(self, site_name, converter = None, decoder = None,
|
||||||
hudbgcolor = None, hudfgcolor = None,
|
hudbgcolor = None, hudfgcolor = None,
|
||||||
hudopacity = None, screen_name = None,
|
hudopacity = None, screen_name = None,
|
||||||
site_path = None, table_finder = None,
|
site_path = None, table_finder = None,
|
||||||
HH_path = None):
|
HH_path = None, enabled = None):
|
||||||
"""Sets the specified site parameters for the specified site."""
|
"""Sets the specified site parameters for the specified site."""
|
||||||
site_node = self.get_site_node(site_name)
|
site_node = self.get_site_node(site_name)
|
||||||
if not db_node == None:
|
if not db_node == None:
|
||||||
|
@ -513,6 +515,7 @@ class Config:
|
||||||
if not site_path == None: site_node.setAttribute("site_path", site_path)
|
if not site_path == None: site_node.setAttribute("site_path", site_path)
|
||||||
if not table_finder == None: site_node.setAttribute("table_finder", table_finder)
|
if not table_finder == None: site_node.setAttribute("table_finder", table_finder)
|
||||||
if not HH_path == None: site_node.setAttribute("HH_path", HH_path)
|
if not HH_path == None: site_node.setAttribute("HH_path", HH_path)
|
||||||
|
if not enabled == None: site_node.setAttribute("enabled", enabled)
|
||||||
|
|
||||||
if self.supported_databases.has_key(db_name):
|
if self.supported_databases.has_key(db_name):
|
||||||
if not converter == None: self.supported_sites[site].converter = converter
|
if not converter == None: self.supported_sites[site].converter = converter
|
||||||
|
@ -524,6 +527,7 @@ class Config:
|
||||||
if not site_path == None: self.supported_sites[site].site_path = site_path
|
if not site_path == None: self.supported_sites[site].site_path = site_path
|
||||||
if not table_finder == None: self.supported_sites[site].table_finder = table_finder
|
if not table_finder == None: self.supported_sites[site].table_finder = table_finder
|
||||||
if not HH_path == None: self.supported_sites[site].HH_path = HH_path
|
if not HH_path == None: self.supported_sites[site].HH_path = HH_path
|
||||||
|
if not enabled == None: self.supported_sites[site].enabled = enabled
|
||||||
return
|
return
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
|
|
|
@ -26,11 +26,56 @@ import os
|
||||||
import time
|
import time
|
||||||
import fpdb_import
|
import fpdb_import
|
||||||
|
|
||||||
|
|
||||||
class GuiAutoImport (threading.Thread):
|
class GuiAutoImport (threading.Thread):
|
||||||
def starsBrowseClicked(self, widget, data):
|
def __init__(self, settings, config):
|
||||||
"""runs when user clicks browse on auto import tab"""
|
"""Constructor for GuiAutoImport"""
|
||||||
#print "start of GuiAutoImport.starsBrowseClicked"
|
self.settings=settings
|
||||||
current_path=self.starsDirPath.get_text()
|
self.config=config
|
||||||
|
|
||||||
|
self.input_settings = {}
|
||||||
|
|
||||||
|
self.importer = fpdb_import.Importer(self,self.settings)
|
||||||
|
self.importer.setCallHud(True)
|
||||||
|
self.importer.setMinPrint(30)
|
||||||
|
self.importer.setQuiet(False)
|
||||||
|
self.importer.setFailOnError(False)
|
||||||
|
self.importer.setHandCount(0)
|
||||||
|
# self.importer.setWatchTime()
|
||||||
|
|
||||||
|
self.server=settings['db-host']
|
||||||
|
self.user=settings['db-user']
|
||||||
|
self.password=settings['db-password']
|
||||||
|
self.database=settings['db-databaseName']
|
||||||
|
|
||||||
|
self.mainVBox=gtk.VBox(False,1)
|
||||||
|
self.mainVBox.show()
|
||||||
|
|
||||||
|
self.settingsHBox = gtk.HBox(False, 0)
|
||||||
|
self.mainVBox.pack_start(self.settingsHBox, False, True, 0)
|
||||||
|
self.settingsHBox.show()
|
||||||
|
|
||||||
|
self.intervalLabel = gtk.Label("Interval (ie. break) between imports in seconds:")
|
||||||
|
self.settingsHBox.pack_start(self.intervalLabel)
|
||||||
|
self.intervalLabel.show()
|
||||||
|
|
||||||
|
self.intervalEntry=gtk.Entry()
|
||||||
|
self.intervalEntry.set_text(str(self.settings['hud-defaultInterval']))
|
||||||
|
self.settingsHBox.pack_start(self.intervalEntry)
|
||||||
|
self.intervalEntry.show()
|
||||||
|
|
||||||
|
self.addSites(self.mainVBox)
|
||||||
|
|
||||||
|
self.startButton=gtk.Button("Start Autoimport")
|
||||||
|
self.startButton.connect("clicked", self.startClicked, "start clicked")
|
||||||
|
self.mainVBox.add(self.startButton)
|
||||||
|
self.startButton.show()
|
||||||
|
|
||||||
|
|
||||||
|
#end of GuiAutoImport.__init__
|
||||||
|
def browseClicked(self, widget, data):
|
||||||
|
"""runs when user clicks one of the browse buttons in the auto import tab"""
|
||||||
|
current_path=data[1].get_text()
|
||||||
|
|
||||||
dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import",
|
dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import",
|
||||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||||
|
@ -42,32 +87,12 @@ class GuiAutoImport (threading.Thread):
|
||||||
response = dia_chooser.run()
|
response = dia_chooser.run()
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
#print dia_chooser.get_filename(), 'selected'
|
#print dia_chooser.get_filename(), 'selected'
|
||||||
self.starsDirPath.set_text(dia_chooser.get_filename())
|
data[1].set_text(dia_chooser.get_filename())
|
||||||
|
self.input_settings[data[0]][0] = dia_chooser.get_filename()
|
||||||
elif response == gtk.RESPONSE_CANCEL:
|
elif response == gtk.RESPONSE_CANCEL:
|
||||||
print 'Closed, no files selected'
|
print 'Closed, no files selected'
|
||||||
dia_chooser.destroy()
|
dia_chooser.destroy()
|
||||||
#end def GuiAutoImport.starsBrowseClicked
|
#end def GuiAutoImport.browseClicked
|
||||||
|
|
||||||
def tiltBrowseClicked(self, widget, data):
|
|
||||||
"""runs when user clicks browse on auto import tab"""
|
|
||||||
#print "start of GuiAutoImport.tiltBrowseClicked"
|
|
||||||
current_path=self.tiltDirPath.get_text()
|
|
||||||
|
|
||||||
dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import",
|
|
||||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
|
||||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
|
||||||
#dia_chooser.set_current_folder(pathname)
|
|
||||||
dia_chooser.set_filename(current_path)
|
|
||||||
#dia_chooser.set_select_multiple(select_multiple) #not in tv, but want this in bulk import
|
|
||||||
|
|
||||||
response = dia_chooser.run()
|
|
||||||
if response == gtk.RESPONSE_OK:
|
|
||||||
#print dia_chooser.get_filename(), 'selected'
|
|
||||||
self.tiltDirPath.set_text(dia_chooser.get_filename())
|
|
||||||
elif response == gtk.RESPONSE_CANCEL:
|
|
||||||
print 'Closed, no files selected'
|
|
||||||
dia_chooser.destroy()
|
|
||||||
#end def GuiAutoImport.tiltBrowseClicked
|
|
||||||
|
|
||||||
def do_import(self):
|
def do_import(self):
|
||||||
"""Callback for timer to do an import iteration."""
|
"""Callback for timer to do an import iteration."""
|
||||||
|
@ -106,12 +131,10 @@ class GuiAutoImport (threading.Thread):
|
||||||
# command = command + " %s" % (self.database)
|
# command = command + " %s" % (self.database)
|
||||||
# print "command = ", command
|
# print "command = ", command
|
||||||
# self.pipe_to_hud = os.popen(command, 'w')
|
# self.pipe_to_hud = os.popen(command, 'w')
|
||||||
self.starspath=self.starsDirPath.get_text()
|
|
||||||
self.tiltpath=self.tiltDirPath.get_text()
|
|
||||||
|
|
||||||
# Add directory to importer object.
|
# Add directories to importer object.
|
||||||
self.importer.addImportDirectory(self.starspath, True, "PokerStars", "passthrough")
|
for site in self.input_settings:
|
||||||
self.importer.addImportDirectory(self.tiltpath, True, "FullTilt", "passthrough")
|
self.importer.addImportDirectory(self.input_settings[site][0], True, site, self.input_settings[site][1])
|
||||||
self.do_import()
|
self.do_import()
|
||||||
|
|
||||||
interval=int(self.intervalEntry.get_text())
|
interval=int(self.intervalEntry.get_text())
|
||||||
|
@ -123,78 +146,44 @@ class GuiAutoImport (threading.Thread):
|
||||||
return self.mainVBox
|
return self.mainVBox
|
||||||
#end def get_vbox
|
#end def get_vbox
|
||||||
|
|
||||||
def __init__(self, settings, config, debug=True):
|
#Create the site line given required info and setup callbacks
|
||||||
"""Constructor for GuiAutoImport"""
|
#enabling and disabling sites from this interface not possible
|
||||||
self.settings=settings
|
#expects a box to layout the line horizontally
|
||||||
self.config=config
|
def createSiteLine(self, hbox, site, iconpath, hhpath, filter_name, active = True):
|
||||||
self.importer = fpdb_import.Importer(self,self.settings)
|
label = gtk.Label(site + " auto-import:")
|
||||||
self.importer.setCallHud(True)
|
hbox.pack_start(label, False, False, 0)
|
||||||
self.importer.setMinPrint(30)
|
label.show()
|
||||||
self.importer.setQuiet(False)
|
|
||||||
self.importer.setFailOnError(False)
|
|
||||||
self.importer.setHandCount(0)
|
|
||||||
# self.importer.setWatchTime()
|
|
||||||
|
|
||||||
self.server=settings['db-host']
|
dirPath=gtk.Entry()
|
||||||
self.user=settings['db-user']
|
dirPath.set_text(hhpath)
|
||||||
self.password=settings['db-password']
|
hbox.pack_start(dirPath, False, True, 0)
|
||||||
self.database=settings['db-databaseName']
|
dirPath.show()
|
||||||
|
|
||||||
self.mainVBox=gtk.VBox(False,1)
|
browseButton=gtk.Button("Browse...")
|
||||||
self.mainVBox.show()
|
browseButton.connect("clicked", self.browseClicked, [site] + [dirPath])
|
||||||
|
hbox.pack_start(browseButton, False, False, 0)
|
||||||
|
browseButton.show()
|
||||||
|
|
||||||
self.settingsHBox = gtk.HBox(False, 0)
|
label = gtk.Label(site + " filter:")
|
||||||
self.mainVBox.pack_start(self.settingsHBox, False, True, 0)
|
hbox.pack_start(label, False, False, 0)
|
||||||
self.settingsHBox.show()
|
label.show()
|
||||||
|
|
||||||
self.intervalLabel = gtk.Label("Interval (ie. break) between imports in seconds:")
|
filter=gtk.Entry()
|
||||||
self.settingsHBox.pack_start(self.intervalLabel)
|
filter.set_text(filter_name)
|
||||||
self.intervalLabel.show()
|
hbox.pack_start(filter, False, True, 0)
|
||||||
|
filter.show()
|
||||||
|
|
||||||
self.intervalEntry=gtk.Entry()
|
def addSites(self, vbox):
|
||||||
self.intervalEntry.set_text(str(self.settings['hud-defaultInterval']))
|
for site in self.config.supported_sites.keys():
|
||||||
self.settingsHBox.pack_start(self.intervalEntry)
|
pathHBox = gtk.HBox(False, 0)
|
||||||
self.intervalEntry.show()
|
vbox.pack_start(pathHBox, False, True, 0)
|
||||||
|
pathHBox.show()
|
||||||
|
|
||||||
self.pathHBox = gtk.HBox(False, 0)
|
paths = self.config.get_default_paths(site)
|
||||||
self.mainVBox.pack_start(self.pathHBox, False, True, 0)
|
params = self.config.get_site_parameters(site)
|
||||||
self.pathHBox.show()
|
self.createSiteLine(pathHBox, site, False, paths['hud-defaultPath'], params['converter'], params['enabled'])
|
||||||
|
self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']]
|
||||||
|
|
||||||
self.pathStarsLabel = gtk.Label("Path to PokerStars auto-import:")
|
|
||||||
self.pathHBox.pack_start(self.pathStarsLabel, False, False, 0)
|
|
||||||
self.pathStarsLabel.show()
|
|
||||||
|
|
||||||
self.starsDirPath=gtk.Entry()
|
|
||||||
paths = self.config.get_default_paths("PokerStars")
|
|
||||||
self.starsDirPath.set_text(paths['hud-defaultPath'])
|
|
||||||
self.pathHBox.pack_start(self.starsDirPath, False, True, 0)
|
|
||||||
self.starsDirPath.show()
|
|
||||||
|
|
||||||
self.browseButton=gtk.Button("Browse...")
|
|
||||||
self.browseButton.connect("clicked", self.starsBrowseClicked, "Browse clicked")
|
|
||||||
self.pathHBox.pack_start(self.browseButton, False, False, 0)
|
|
||||||
self.browseButton.show()
|
|
||||||
|
|
||||||
self.pathTiltLabel = gtk.Label("Path to Full Tilt auto-import:")
|
|
||||||
self.pathHBox.pack_start(self.pathTiltLabel, False, False, 0)
|
|
||||||
self.pathTiltLabel.show()
|
|
||||||
|
|
||||||
self.tiltDirPath=gtk.Entry()
|
|
||||||
paths = self.config.get_default_paths("Full Tilt")
|
|
||||||
self.tiltDirPath.set_text(paths['hud-defaultPath'])
|
|
||||||
self.pathHBox.pack_start(self.tiltDirPath, False, True, 0)
|
|
||||||
self.tiltDirPath.show()
|
|
||||||
|
|
||||||
self.browseButton=gtk.Button("Browse...")
|
|
||||||
self.browseButton.connect("clicked", self.tiltBrowseClicked, "Browse clicked")
|
|
||||||
self.pathHBox.pack_start(self.browseButton, False, False, 0)
|
|
||||||
self.browseButton.show()
|
|
||||||
|
|
||||||
self.startButton=gtk.Button("Start Autoimport")
|
|
||||||
self.startButton.connect("clicked", self.startClicked, "start clicked")
|
|
||||||
self.mainVBox.add(self.startButton)
|
|
||||||
self.startButton.show()
|
|
||||||
#end of GuiAutoImport.__init__
|
|
||||||
if __name__== "__main__":
|
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()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user