2011-02-26 20:26:46 +01:00
|
|
|
#!/usr/bin/env python
|
2010-07-05 06:17:08 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-08-17 02:48:03 +02:00
|
|
|
|
2011-03-10 06:16:31 +01:00
|
|
|
#Copyright 2008-2011 Steffen Schaumburg
|
2008-08-17 02:48:03 +02:00
|
|
|
#This program is free software: you can redistribute it and/or modify
|
|
|
|
#it under the terms of the GNU Affero General Public License as published by
|
|
|
|
#the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
#This program is distributed in the hope that it will be useful,
|
|
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
#GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
#You should have received a copy of the GNU Affero General Public License
|
|
|
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-07-05 06:17:08 +02:00
|
|
|
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
2008-08-17 02:48:03 +02:00
|
|
|
|
2010-09-23 07:11:06 +02:00
|
|
|
import L10n
|
|
|
|
_ = L10n.get_translation()
|
|
|
|
|
2008-08-17 02:48:03 +02:00
|
|
|
import threading
|
2008-08-20 00:38:01 +02:00
|
|
|
import subprocess
|
2009-08-06 13:23:57 +02:00
|
|
|
import traceback
|
2008-08-20 00:38:01 +02:00
|
|
|
|
2008-08-17 02:48:03 +02:00
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
2008-08-20 00:38:01 +02:00
|
|
|
import gobject
|
2008-08-17 06:28:26 +02:00
|
|
|
import os
|
2008-12-13 20:57:08 +01:00
|
|
|
import sys
|
2008-08-17 06:28:26 +02:00
|
|
|
import time
|
2010-09-01 22:08:13 +02:00
|
|
|
|
|
|
|
import logging
|
|
|
|
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
|
|
|
log = logging.getLogger("importer")
|
|
|
|
|
|
|
|
|
2008-08-17 02:48:03 +02:00
|
|
|
import fpdb_import
|
2009-03-05 02:12:15 +01:00
|
|
|
from optparse import OptionParser
|
|
|
|
import Configuration
|
2009-06-15 05:14:53 +02:00
|
|
|
import string
|
2008-11-06 06:39:49 +01:00
|
|
|
|
2010-09-27 13:10:13 +02:00
|
|
|
if os.name == "nt":
|
|
|
|
import win32console
|
|
|
|
|
|
|
|
|
2008-08-17 02:48:03 +02:00
|
|
|
class GuiAutoImport (threading.Thread):
|
2010-10-07 07:02:36 +02:00
|
|
|
def __init__(self, settings, config, sql = None, parent = None, cli = False):
|
2009-09-11 07:12:46 +02:00
|
|
|
self.importtimer = 0
|
2009-11-03 21:06:48 +01:00
|
|
|
self.settings = settings
|
|
|
|
self.config = config
|
2009-08-02 00:29:00 +02:00
|
|
|
self.sql = sql
|
2010-06-28 00:21:40 +02:00
|
|
|
self.parent = parent
|
2008-12-15 09:22:49 +01:00
|
|
|
|
|
|
|
imp = self.config.get_import_parameters()
|
|
|
|
|
|
|
|
self.input_settings = {}
|
|
|
|
self.pipe_to_hud = None
|
|
|
|
|
2009-08-02 00:29:00 +02:00
|
|
|
self.importer = fpdb_import.Importer(self, self.settings, self.config, self.sql)
|
2008-12-15 09:22:49 +01:00
|
|
|
self.importer.setCallHud(True)
|
|
|
|
self.importer.setQuiet(False)
|
|
|
|
self.importer.setFailOnError(False)
|
|
|
|
self.importer.setHandCount(0)
|
2009-11-22 22:40:56 +01:00
|
|
|
|
2009-11-03 21:06:48 +01:00
|
|
|
self.server = settings['db-host']
|
|
|
|
self.user = settings['db-user']
|
|
|
|
self.password = settings['db-password']
|
|
|
|
self.database = settings['db-databaseName']
|
2008-12-15 09:22:49 +01:00
|
|
|
|
2010-10-07 07:02:36 +02:00
|
|
|
if cli == False:
|
|
|
|
self.setupGui()
|
|
|
|
else:
|
|
|
|
# TODO: Separate the code that grabs the directories from config
|
|
|
|
# Separate the calls to the Importer API
|
|
|
|
# Create a timer interface that doesn't rely on GTK
|
|
|
|
pass
|
|
|
|
|
|
|
|
def setupGui(self):
|
2009-11-03 21:06:48 +01:00
|
|
|
self.mainVBox = gtk.VBox(False,1)
|
2008-12-15 09:22:49 +01:00
|
|
|
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox = gtk.HBox(True, 0) # contains 2 equal vboxes
|
|
|
|
self.mainVBox.pack_start(hbox, False, False, 0)
|
2009-11-22 22:40:56 +01:00
|
|
|
|
2009-05-22 00:00:46 +02:00
|
|
|
vbox1 = gtk.VBox(True, 0)
|
|
|
|
hbox.pack_start(vbox1, True, True, 0)
|
|
|
|
vbox2 = gtk.VBox(True, 0)
|
|
|
|
hbox.pack_start(vbox2, True, True, 0)
|
2008-12-15 09:22:49 +01:00
|
|
|
|
2010-08-13 04:23:11 +02:00
|
|
|
self.intervalLabel = gtk.Label(_("Time between imports in seconds:"))
|
2009-05-22 00:00:46 +02:00
|
|
|
self.intervalLabel.set_alignment(xalign=1.0, yalign=0.5)
|
2009-11-30 05:52:36 +01:00
|
|
|
vbox1.pack_start(self.intervalLabel, False, True, 0)
|
2008-12-15 09:22:49 +01:00
|
|
|
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox = gtk.HBox(False, 0)
|
2009-11-30 05:52:36 +01:00
|
|
|
vbox2.pack_start(hbox, False, True, 0)
|
2009-05-22 00:00:46 +02:00
|
|
|
self.intervalEntry = gtk.Entry()
|
2008-12-15 09:22:49 +01:00
|
|
|
self.intervalEntry.set_text(str(self.config.get_import_parameters().get("interval")))
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox.pack_start(self.intervalEntry, False, False, 0)
|
|
|
|
lbl1 = gtk.Label()
|
2009-11-30 05:52:36 +01:00
|
|
|
hbox.pack_start(lbl1, expand=False, fill=True)
|
2009-05-22 00:00:46 +02:00
|
|
|
|
|
|
|
lbl = gtk.Label('')
|
2009-11-30 05:52:36 +01:00
|
|
|
vbox1.pack_start(lbl, expand=False, fill=True)
|
2009-05-22 00:00:46 +02:00
|
|
|
lbl = gtk.Label('')
|
2009-11-30 05:52:36 +01:00
|
|
|
vbox2.pack_start(lbl, expand=False, fill=True)
|
2009-05-22 00:00:46 +02:00
|
|
|
|
|
|
|
self.addSites(vbox1, vbox2)
|
2009-11-30 05:52:36 +01:00
|
|
|
self.textbuffer = gtk.TextBuffer()
|
|
|
|
self.textview = gtk.TextView(self.textbuffer)
|
2009-05-22 00:00:46 +02:00
|
|
|
|
|
|
|
hbox = gtk.HBox(False, 0)
|
|
|
|
self.mainVBox.pack_start(hbox, expand=True, padding=3)
|
2008-12-15 09:22:49 +01:00
|
|
|
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox = gtk.HBox(False, 0)
|
|
|
|
self.mainVBox.pack_start(hbox, expand=False, padding=3)
|
|
|
|
|
|
|
|
lbl1 = gtk.Label()
|
|
|
|
hbox.pack_start(lbl1, expand=True, fill=False)
|
2008-12-15 09:22:49 +01:00
|
|
|
|
|
|
|
self.doAutoImportBool = False
|
2011-04-08 11:12:38 +02:00
|
|
|
self.startButton = gtk.ToggleButton(_("Start _Auto Import"))
|
2008-12-15 09:22:49 +01:00
|
|
|
self.startButton.connect("clicked", self.startClicked, "start clicked")
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox.pack_start(self.startButton, expand=False, fill=False)
|
|
|
|
|
2011-02-16 08:50:21 +01:00
|
|
|
self.DetectButton = gtk.Button(_("Detect Directories"))
|
|
|
|
self.DetectButton.connect("clicked", self.detect_hh_dirs, "detect")
|
|
|
|
#hbox.pack_start(self.DetectButton, expand=False, fill=False)
|
|
|
|
|
2009-11-30 05:52:36 +01:00
|
|
|
|
2009-05-22 00:00:46 +02:00
|
|
|
lbl2 = gtk.Label()
|
|
|
|
hbox.pack_start(lbl2, expand=True, fill=False)
|
|
|
|
|
|
|
|
hbox = gtk.HBox(False, 0)
|
|
|
|
hbox.show()
|
2009-11-30 05:52:36 +01:00
|
|
|
|
2009-05-22 00:00:46 +02:00
|
|
|
self.mainVBox.pack_start(hbox, expand=True, padding=3)
|
2009-11-30 05:52:36 +01:00
|
|
|
|
|
|
|
scrolledwindow = gtk.ScrolledWindow()
|
|
|
|
scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
|
|
|
self.mainVBox.pack_end(scrolledwindow, expand=True)
|
|
|
|
scrolledwindow.add(self.textview)
|
|
|
|
|
2009-05-22 00:00:46 +02:00
|
|
|
self.mainVBox.show_all()
|
2010-08-29 19:12:48 +02:00
|
|
|
self.addText(_("Auto Import Ready."))
|
2009-11-30 05:52:36 +01:00
|
|
|
|
|
|
|
def addText(self, text):
|
|
|
|
end_iter = self.textbuffer.get_end_iter()
|
|
|
|
self.textbuffer.insert(end_iter, text)
|
|
|
|
self.textview.scroll_to_mark(self.textbuffer.get_insert(), 0)
|
2008-12-15 09:22:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
#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()
|
|
|
|
|
2010-08-29 19:12:48 +02:00
|
|
|
dia_chooser = gtk.FileChooserDialog(title=_("Please choose the path that you want to Auto Import"),
|
2008-12-15 09:22:49 +01:00
|
|
|
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
|
2010-06-28 00:21:40 +02:00
|
|
|
dia_chooser.set_destroy_with_parent(True)
|
|
|
|
dia_chooser.set_transient_for(self.parent)
|
2008-12-15 09:22:49 +01:00
|
|
|
|
|
|
|
response = dia_chooser.run()
|
|
|
|
if response == gtk.RESPONSE_OK:
|
|
|
|
#print dia_chooser.get_filename(), 'selected'
|
|
|
|
data[1].set_text(dia_chooser.get_filename())
|
|
|
|
self.input_settings[data[0]][0] = dia_chooser.get_filename()
|
|
|
|
elif response == gtk.RESPONSE_CANCEL:
|
2009-11-03 20:30:52 +01:00
|
|
|
#print 'Closed, no files selected'
|
|
|
|
pass
|
2008-12-15 09:22:49 +01:00
|
|
|
dia_chooser.destroy()
|
|
|
|
#end def GuiAutoImport.browseClicked
|
|
|
|
|
|
|
|
def do_import(self):
|
|
|
|
"""Callback for timer to do an import iteration."""
|
2008-12-18 18:49:17 +01:00
|
|
|
if self.doAutoImportBool:
|
2011-04-08 11:12:38 +02:00
|
|
|
self.startButton.set_label(_(u'_Auto Import Running'))
|
2008-12-18 18:49:17 +01:00
|
|
|
self.importer.runUpdated()
|
2009-11-30 05:52:36 +01:00
|
|
|
self.addText(".")
|
|
|
|
#sys.stdout.write(".")
|
|
|
|
#sys.stdout.flush()
|
2009-08-16 12:30:11 +02:00
|
|
|
gobject.timeout_add(1000, self.reset_startbutton)
|
2008-12-18 18:49:17 +01:00
|
|
|
return True
|
2009-11-03 21:06:48 +01:00
|
|
|
return False
|
2009-11-22 22:40:56 +01:00
|
|
|
|
2009-08-16 12:30:11 +02:00
|
|
|
def reset_startbutton(self):
|
2009-08-16 21:30:52 +02:00
|
|
|
if self.pipe_to_hud is not None:
|
2011-04-08 11:12:38 +02:00
|
|
|
self.startButton.set_label(_(u'Stop _Auto Import'))
|
2009-08-16 21:30:52 +02:00
|
|
|
else:
|
2011-04-08 11:12:38 +02:00
|
|
|
self.startButton.set_label(_(u'Start _Auto Import'))
|
2009-11-22 22:40:56 +01:00
|
|
|
|
2009-08-16 12:30:11 +02:00
|
|
|
return False
|
|
|
|
|
2011-02-16 08:50:21 +01:00
|
|
|
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:
|
2011-04-08 13:39:56 +02:00
|
|
|
print (_("DEBUG:") + " " + _("Detecting hand history directory for site: '%s'") % site)
|
2011-02-16 08:50:21 +01:00
|
|
|
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
|
2008-12-15 09:22:49 +01:00
|
|
|
|
|
|
|
def startClicked(self, widget, data):
|
|
|
|
"""runs when user clicks start on auto import tab"""
|
|
|
|
|
2011-03-18 00:11:47 +01:00
|
|
|
# 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.
|
|
|
|
|
|
|
|
# TODO: Allow for importing from multiple dirs - REB 29AUG2008
|
|
|
|
# As presently written this function does nothing if there is already a pipe open.
|
|
|
|
# That is not correct. It should open another dir for importing while piping the
|
|
|
|
# results to the same pipe. This means that self.path should be a a list of dirs
|
|
|
|
# to watch.
|
|
|
|
|
2010-11-29 02:15:09 +01:00
|
|
|
if data == "autostart" or (widget == self.startButton and self.startButton.get_active()):
|
2010-11-29 02:00:56 +01:00
|
|
|
self.startButton.set_active(True)
|
2009-07-19 00:01:18 +02:00
|
|
|
# - Does the lock acquisition need to be more sophisticated for multiple dirs?
|
|
|
|
# (see comment above about what to do if pipe already open)
|
2009-11-22 22:40:56 +01:00
|
|
|
# - Ideally we want to release the lock if the auto-import is killed by some
|
2009-07-19 00:01:18 +02:00
|
|
|
# kind of exception - is this possible?
|
2010-11-29 02:15:09 +01:00
|
|
|
if self.settings['global_lock'].acquire(wait=False, source="AutoImport"): # returns false immediately if lock not acquired
|
2011-04-08 13:39:56 +02:00
|
|
|
self.addText("\n" + _("Global lock taken ... Auto Import Started.")+"\n")
|
2009-08-16 12:30:11 +02:00
|
|
|
self.doAutoImportBool = True
|
2011-04-08 11:12:38 +02:00
|
|
|
self.startButton.set_label(_(u'Stop _Auto Import'))
|
2010-11-28 00:34:30 +01:00
|
|
|
while gtk.events_pending(): # change the label NOW don't wait for the pipe to open
|
|
|
|
gtk.main_iteration(False)
|
2009-08-16 12:30:11 +02:00
|
|
|
if self.pipe_to_hud is None:
|
2010-09-27 09:14:10 +02:00
|
|
|
if Configuration.FROZEN: # if py2exe, run hud_main.exe
|
2010-02-06 20:55:48 +01:00
|
|
|
path = Configuration.EXEC_PATH
|
|
|
|
command = "HUD_main.exe"
|
|
|
|
bs = 0
|
|
|
|
elif os.name == 'nt':
|
2010-01-31 12:16:42 +01:00
|
|
|
path = sys.path[0].replace('\\','\\\\')
|
2010-09-27 13:10:13 +02:00
|
|
|
if win32console.GetConsoleWindow() == 0:
|
|
|
|
command = 'pythonw "'+path+'\\HUD_main.pyw" ' + self.settings['cl_options']
|
|
|
|
else:
|
|
|
|
command = 'python "'+path+'\\HUD_main.pyw" ' + self.settings['cl_options']
|
2009-08-16 12:30:11 +02:00
|
|
|
bs = 0
|
|
|
|
else:
|
2010-06-06 22:03:03 +02:00
|
|
|
command = os.path.join(sys.path[0], 'HUD_main.pyw')
|
2009-08-16 12:30:11 +02:00
|
|
|
command = [command, ] + string.split(self.settings['cl_options'])
|
|
|
|
bs = 1
|
2009-11-22 22:40:56 +01:00
|
|
|
|
2010-08-13 04:23:11 +02:00
|
|
|
print _("opening pipe to HUD")
|
2010-11-28 00:34:30 +01:00
|
|
|
try:
|
2010-09-27 13:10:13 +02:00
|
|
|
if Configuration.FROZEN or (os.name == "nt" and win32console.GetConsoleWindow()) == 0:
|
2010-09-27 09:14:10 +02:00
|
|
|
self.pipe_to_hud = subprocess.Popen(command, bufsize=bs,
|
|
|
|
stdin=subprocess.PIPE,
|
2010-09-27 13:11:16 +02:00
|
|
|
stdout=subprocess.PIPE, # needed for pythonw / py2exe
|
|
|
|
stderr=subprocess.PIPE, # needed for pythonw / py2exe
|
2010-09-27 09:14:10 +02:00
|
|
|
universal_newlines=True
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
self.pipe_to_hud = subprocess.Popen(command, bufsize=bs, stdin=subprocess.PIPE, universal_newlines=True)
|
2009-08-16 12:30:11 +02:00
|
|
|
except:
|
|
|
|
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
2010-02-06 11:33:00 +01:00
|
|
|
#self.addText( "\n*** GuiAutoImport Error opening pipe: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1]))
|
2011-04-08 11:12:38 +02:00
|
|
|
self.addText("\n" + _("*** GuiAutoImport Error opening pipe:") + " " + traceback.format_exc() )
|
2009-11-22 22:40:56 +01:00
|
|
|
else:
|
2009-07-31 23:34:26 +02:00
|
|
|
for site in self.input_settings:
|
|
|
|
self.importer.addImportDirectory(self.input_settings[site][0], True, site, self.input_settings[site][1])
|
2009-11-30 05:52:36 +01:00
|
|
|
self.addText("\n * Add "+ site+ " import directory "+ str(self.input_settings[site][0]))
|
2009-11-22 22:40:56 +01:00
|
|
|
self.do_import()
|
2009-08-16 12:30:11 +02:00
|
|
|
interval = int(self.intervalEntry.get_text())
|
2009-09-11 07:12:46 +02:00
|
|
|
if self.importtimer != 0:
|
|
|
|
gobject.source_remove(self.importtimer)
|
2009-11-03 20:30:52 +01:00
|
|
|
self.importtimer = gobject.timeout_add(interval * 1000, self.do_import)
|
2009-11-22 22:40:56 +01:00
|
|
|
|
2009-07-19 00:01:18 +02:00
|
|
|
else:
|
2010-08-29 19:12:48 +02:00
|
|
|
self.addText(_("\nAuto Import aborted - global lock not available"))
|
2008-12-15 09:22:49 +01:00
|
|
|
else: # toggled off
|
2009-09-11 07:12:46 +02:00
|
|
|
gobject.source_remove(self.importtimer)
|
2009-07-19 00:01:18 +02:00
|
|
|
self.settings['global_lock'].release()
|
2008-12-18 18:49:17 +01:00
|
|
|
self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer
|
2010-08-29 19:12:48 +02:00
|
|
|
self.addText(_("\nStopping Auto Import - global lock released."))
|
2008-12-22 21:17:29 +01:00
|
|
|
if self.pipe_to_hud.poll() is not None:
|
2010-08-29 19:12:48 +02:00
|
|
|
self.addText(_("\n * Stop Auto Import: HUD already terminated"))
|
2008-12-22 21:17:29 +01:00
|
|
|
else:
|
2010-11-28 00:34:30 +01:00
|
|
|
self.pipe_to_hud.terminate()
|
2008-12-22 21:17:29 +01:00
|
|
|
#print >>self.pipe_to_hud.stdin, "\n"
|
2010-11-28 00:34:30 +01:00
|
|
|
# self.pipe_to_hud.communicate('\n') # waits for process to terminate
|
2008-12-18 18:49:17 +01:00
|
|
|
self.pipe_to_hud = None
|
2010-08-29 19:12:48 +02:00
|
|
|
self.startButton.set_label(_(u' Start _Auto Import '))
|
2008-12-18 18:49:17 +01:00
|
|
|
|
2008-12-15 09:22:49 +01:00
|
|
|
#end def GuiAutoImport.startClicked
|
|
|
|
|
|
|
|
def get_vbox(self):
|
|
|
|
"""returns the vbox of this thread"""
|
|
|
|
return self.mainVBox
|
|
|
|
#end def get_vbox
|
|
|
|
|
|
|
|
#Create the site line given required info and setup callbacks
|
|
|
|
#enabling and disabling sites from this interface not possible
|
|
|
|
#expects a box to layout the line horizontally
|
2009-05-22 00:00:46 +02:00
|
|
|
def createSiteLine(self, hbox1, hbox2, site, iconpath, hhpath, filter_name, active = True):
|
2011-03-10 02:26:42 +01:00
|
|
|
label = gtk.Label(_("%s auto-import:") % site)
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox1.pack_start(label, False, False, 3)
|
2008-12-15 09:22:49 +01:00
|
|
|
label.show()
|
|
|
|
|
|
|
|
dirPath=gtk.Entry()
|
|
|
|
dirPath.set_text(hhpath)
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox1.pack_start(dirPath, True, True, 3)
|
2008-12-15 09:22:49 +01:00
|
|
|
dirPath.show()
|
|
|
|
|
2010-08-13 04:23:11 +02:00
|
|
|
browseButton=gtk.Button(_("Browse..."))
|
2008-12-15 09:22:49 +01:00
|
|
|
browseButton.connect("clicked", self.browseClicked, [site] + [dirPath])
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox2.pack_start(browseButton, False, False, 3)
|
2008-12-15 09:22:49 +01:00
|
|
|
browseButton.show()
|
|
|
|
|
2009-11-03 21:06:48 +01:00
|
|
|
label = gtk.Label("%s filter:" % site)
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox2.pack_start(label, False, False, 3)
|
2008-12-15 09:22:49 +01:00
|
|
|
label.show()
|
|
|
|
|
|
|
|
filter=gtk.Entry()
|
|
|
|
filter.set_text(filter_name)
|
2009-05-22 00:00:46 +02:00
|
|
|
hbox2.pack_start(filter, True, True, 3)
|
2008-12-15 09:22:49 +01:00
|
|
|
filter.show()
|
|
|
|
|
2009-05-22 00:00:46 +02:00
|
|
|
def addSites(self, vbox1, vbox2):
|
2009-03-30 05:40:03 +02:00
|
|
|
the_sites = self.config.get_supported_sites()
|
2010-09-01 22:08:13 +02:00
|
|
|
#log.debug("addSites: the_sites="+str(the_sites))
|
2009-03-30 05:40:03 +02:00
|
|
|
for site in the_sites:
|
2009-05-22 00:00:46 +02:00
|
|
|
pathHBox1 = gtk.HBox(False, 0)
|
|
|
|
vbox1.pack_start(pathHBox1, False, True, 0)
|
|
|
|
pathHBox2 = gtk.HBox(False, 0)
|
|
|
|
vbox2.pack_start(pathHBox2, False, True, 0)
|
2009-11-22 22:40:56 +01:00
|
|
|
|
2008-12-15 09:22:49 +01:00
|
|
|
params = self.config.get_site_parameters(site)
|
2009-03-30 05:40:03 +02:00
|
|
|
paths = self.config.get_default_paths(site)
|
2009-05-22 00:00:46 +02:00
|
|
|
self.createSiteLine(pathHBox1, pathHBox2, site, False, paths['hud-defaultPath'], params['converter'], params['enabled'])
|
2008-12-15 09:22:49 +01:00
|
|
|
self.input_settings[site] = [paths['hud-defaultPath']] + [params['converter']]
|
2010-09-01 22:08:13 +02:00
|
|
|
#log.debug("addSites: input_settings="+str(self.input_settings))
|
2008-10-17 18:28:33 +02:00
|
|
|
|
2008-09-15 22:31:55 +02:00
|
|
|
if __name__== "__main__":
|
|
|
|
def destroy(*args): # call back for terminating the main eventloop
|
|
|
|
gtk.main_quit()
|
|
|
|
|
2009-03-05 02:12:15 +01:00
|
|
|
# settings = {}
|
|
|
|
# settings['db-host'] = "192.168.1.100"
|
|
|
|
# settings['db-user'] = "mythtv"
|
|
|
|
# settings['db-password'] = "mythtv"
|
|
|
|
# settings['db-databaseName'] = "fpdb"
|
|
|
|
# settings['hud-defaultInterval'] = 10
|
|
|
|
# settings['hud-defaultPath'] = 'C:/Program Files/PokerStars/HandHistory/nutOmatic'
|
|
|
|
# settings['callFpdbHud'] = True
|
|
|
|
|
|
|
|
parser = OptionParser()
|
|
|
|
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True, help="don't start gui")
|
2009-11-22 22:40:56 +01:00
|
|
|
(options, argv) = parser.parse_args()
|
2009-03-05 02:12:15 +01:00
|
|
|
|
|
|
|
config = Configuration.Config()
|
|
|
|
|
2008-09-15 22:31:55 +02:00
|
|
|
settings = {}
|
2009-03-05 02:12:15 +01:00
|
|
|
if os.name == 'nt': settings['os'] = 'windows'
|
|
|
|
else: settings['os'] = 'linuxmac'
|
|
|
|
|
2010-10-04 16:11:17 +02:00
|
|
|
settings.update(config.get_db_parameters())
|
2009-03-05 02:12:15 +01:00
|
|
|
settings.update(config.get_import_parameters())
|
|
|
|
settings.update(config.get_default_paths())
|
|
|
|
|
|
|
|
if(options.gui == True):
|
2010-10-04 16:23:21 +02:00
|
|
|
i = GuiAutoImport(settings, config, None, None)
|
2009-03-05 02:12:15 +01:00
|
|
|
main_window = gtk.Window()
|
|
|
|
main_window.connect('destroy', destroy)
|
|
|
|
main_window.add(i.mainVBox)
|
|
|
|
main_window.show()
|
|
|
|
gtk.main()
|
|
|
|
else:
|
2010-10-07 07:02:36 +02:00
|
|
|
i = GuiAutoImport(settings, config, cli = True)
|