Merge branch 'master' of git://git.assembla.com/fpdboz

This commit is contained in:
Ray 2008-10-17 21:35:14 -04:00
commit edf22d8cf3
3 changed files with 85 additions and 52 deletions

View File

@ -27,10 +27,10 @@ import time
import fpdb_import
class GuiAutoImport (threading.Thread):
def browseClicked(self, widget, data):
def starsBrowseClicked(self, widget, data):
"""runs when user clicks browse on auto import tab"""
#print "start of GuiAutoImport.browseClicked"
current_path=self.pathTBuffer.get_text(self.pathTBuffer.get_start_iter(), self.pathTBuffer.get_end_iter())
#print "start of GuiAutoImport.starsBrowseClicked"
current_path=self.starsDirPath.get_text()
dia_chooser = gtk.FileChooserDialog(title="Please choose the path that you want to auto import",
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
@ -42,11 +42,32 @@ class GuiAutoImport (threading.Thread):
response = dia_chooser.run()
if response == gtk.RESPONSE_OK:
#print dia_chooser.get_filename(), 'selected'
self.pathTBuffer.set_text(dia_chooser.get_filename())
self.starsDirPath.set_text(dia_chooser.get_filename())
elif response == gtk.RESPONSE_CANCEL:
print 'Closed, no files selected'
dia_chooser.destroy()
#end def GuiAutoImport.browseClicked
#end def GuiAutoImport.starsBrowseClicked
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):
"""Callback for timer to do an import iteration."""
@ -85,15 +106,17 @@ class GuiAutoImport (threading.Thread):
# command = command + " %s" % (self.database)
# print "command = ", command
# self.pipe_to_hud = os.popen(command, 'w')
self.path=self.pathTBuffer.get_text(self.pathTBuffer.get_start_iter(), self.pathTBuffer.get_end_iter())
self.starspath=self.starsDirPath.get_text()
self.tiltpath=self.tiltDirPath.get_text()
# Add directory to importer object and set the initial mtime reference.
self.importer.addImportDirectory(self.path, True)
# Add directory to importer object.
self.importer.addImportDirectory(self.starspath, True)
self.importer.addImportDirectory(self.tiltpath, True)
self.do_import()
interval=int(self.intervalTBuffer.get_text(self.intervalTBuffer.get_start_iter(), self.intervalTBuffer.get_end_iter()))
interval=int(self.intervalEntry.get_text())
gobject.timeout_add(interval*1000, self.do_import)
#end def GuiAutoImport.browseClicked
#end def GuiAutoImport.startClicked
def get_vbox(self):
"""returns the vbox of this thread"""
@ -127,33 +150,43 @@ class GuiAutoImport (threading.Thread):
self.settingsHBox.pack_start(self.intervalLabel)
self.intervalLabel.show()
self.intervalTBuffer=gtk.TextBuffer()
self.intervalTBuffer.set_text(str(self.settings['hud-defaultInterval']))
self.intervalTView=gtk.TextView(self.intervalTBuffer)
self.settingsHBox.pack_start(self.intervalTView)
self.intervalTView.show()
self.intervalEntry=gtk.Entry()
self.intervalEntry.set_text(str(self.settings['hud-defaultInterval']))
self.settingsHBox.pack_start(self.intervalEntry)
self.intervalEntry.show()
self.pathHBox = gtk.HBox(False, 0)
self.mainVBox.pack_start(self.pathHBox, False, True, 0)
self.pathHBox.show()
self.pathLabel = gtk.Label("Path to auto-import:")
self.pathHBox.pack_start(self.pathLabel, False, False, 0)
self.pathLabel.show()
self.pathTBuffer=gtk.TextBuffer()
self.pathTBuffer.set_text(self.settings['hud-defaultPath'])
self.pathTView=gtk.TextView(self.pathTBuffer)
self.pathHBox.pack_start(self.pathTView, False, True, 0)
self.pathTView.show()
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()
self.starsDirPath.set_text(self.settings['hud-defaultPath'])
self.pathHBox.pack_start(self.starsDirPath, False, True, 0)
self.starsDirPath.show()
self.browseButton=gtk.Button("Browse...")
self.browseButton.connect("clicked", self.browseClicked, "Browse clicked")
self.pathHBox.pack_end(self.browseButton, False, False, 0)
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()
self.tiltDirPath.set_text(self.settings['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)

View File

@ -45,9 +45,9 @@ class GuiGraphViewer (threading.Thread):
try: self.canvas.destroy()
except AttributeError: pass
name=self.nameTBuffer.get_text(self.nameTBuffer.get_start_iter(), self.nameTBuffer.get_end_iter())
name=self.nameEntry.get_text()
site=self.siteTBuffer.get_text(self.siteTBuffer.get_start_iter(), self.siteTBuffer.get_end_iter())
site=self.siteEntry.get_text()
if site=="PS":
site=2
@ -121,21 +121,19 @@ class GuiGraphViewer (threading.Thread):
self.settingsHBox.pack_start(self.nameLabel)
self.nameLabel.show()
self.nameTBuffer=gtk.TextBuffer()
self.nameTBuffer.set_text("name")
self.nameTView=gtk.TextView(self.nameTBuffer)
self.settingsHBox.pack_start(self.nameTView)
self.nameTView.show()
self.nameEntry=gtk.Entry()
self.nameEntry.set_text("name")
self.settingsHBox.pack_start(self.nameEntry)
self.nameEntry.show()
self.siteLabel = gtk.Label("Site (PS or FTP):")
self.settingsHBox.pack_start(self.siteLabel)
self.siteLabel.show()
self.siteTBuffer=gtk.TextBuffer()
self.siteTBuffer.set_text("PS")
self.siteTView=gtk.TextView(self.siteTBuffer)
self.settingsHBox.pack_start(self.siteTView)
self.siteTView.show()
self.siteEntry=gtk.Entry()
self.siteEntry.set_text("PS")
self.settingsHBox.pack_start(self.siteEntry)
self.siteEntry.show()
self.showButton=gtk.Button("Show/Refresh")
self.showButton.connect("clicked", self.showClicked, "show clicked")

View File

@ -104,25 +104,27 @@ class Importer:
#Add an individual file to filelist
def addImportFile(self, filename):
#todo: test it is a valid file
#TODO: test it is a valid file
self.filelist = self.filelist + [filename]
#Remove duplicates
self.filelist = list(set(self.filelist))
#Add a directory of files to filelist
def addImportDirectory(self,dir,monitor = False):
#todo: test it is a valid directory
if monitor == True:
self.monitor = True
self.dirlist = self.dirlist + [dir]
if os.path.isdir(dir):
if monitor == True:
self.monitor = True
self.dirlist = self.dirlist + [dir]
for file in os.listdir(dir):
if os.path.isdir(file):
print "BulkImport is not recursive - please select the final directory in which the history files are"
else:
self.filelist = self.filelist + [os.path.join(dir, file)]
#Remove duplicates
self.filelist = list(set(self.filelist))
for file in os.listdir(dir):
if os.path.isdir(file):
print "BulkImport is not recursive - please select the final directory in which the history files are"
else:
self.filelist = self.filelist + [os.path.join(dir, file)]
#Remove duplicates
self.filelist = list(set(self.filelist))
else:
print "Warning: Attempted to add: '" + str(dir) + "' as an import directory"
#Run full import on filelist
def runImport(self):