Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
edf22d8cf3
|
@ -27,10 +27,10 @@ import time
|
||||||
import fpdb_import
|
import fpdb_import
|
||||||
|
|
||||||
class GuiAutoImport (threading.Thread):
|
class GuiAutoImport (threading.Thread):
|
||||||
def browseClicked(self, widget, data):
|
def starsBrowseClicked(self, widget, data):
|
||||||
"""runs when user clicks browse on auto import tab"""
|
"""runs when user clicks browse on auto import tab"""
|
||||||
#print "start of GuiAutoImport.browseClicked"
|
#print "start of GuiAutoImport.starsBrowseClicked"
|
||||||
current_path=self.pathTBuffer.get_text(self.pathTBuffer.get_start_iter(), self.pathTBuffer.get_end_iter())
|
current_path=self.starsDirPath.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,11 +42,32 @@ 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.pathTBuffer.set_text(dia_chooser.get_filename())
|
self.starsDirPath.set_text(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.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):
|
def do_import(self):
|
||||||
"""Callback for timer to do an import iteration."""
|
"""Callback for timer to do an import iteration."""
|
||||||
|
@ -85,15 +106,17 @@ 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.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.
|
# Add directory to importer object.
|
||||||
self.importer.addImportDirectory(self.path, True)
|
self.importer.addImportDirectory(self.starspath, True)
|
||||||
|
self.importer.addImportDirectory(self.tiltpath, True)
|
||||||
self.do_import()
|
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)
|
gobject.timeout_add(interval*1000, self.do_import)
|
||||||
#end def GuiAutoImport.browseClicked
|
#end def GuiAutoImport.startClicked
|
||||||
|
|
||||||
def get_vbox(self):
|
def get_vbox(self):
|
||||||
"""returns the vbox of this thread"""
|
"""returns the vbox of this thread"""
|
||||||
|
@ -127,32 +150,42 @@ class GuiAutoImport (threading.Thread):
|
||||||
self.settingsHBox.pack_start(self.intervalLabel)
|
self.settingsHBox.pack_start(self.intervalLabel)
|
||||||
self.intervalLabel.show()
|
self.intervalLabel.show()
|
||||||
|
|
||||||
self.intervalTBuffer=gtk.TextBuffer()
|
self.intervalEntry=gtk.Entry()
|
||||||
self.intervalTBuffer.set_text(str(self.settings['hud-defaultInterval']))
|
self.intervalEntry.set_text(str(self.settings['hud-defaultInterval']))
|
||||||
self.intervalTView=gtk.TextView(self.intervalTBuffer)
|
self.settingsHBox.pack_start(self.intervalEntry)
|
||||||
self.settingsHBox.pack_start(self.intervalTView)
|
self.intervalEntry.show()
|
||||||
self.intervalTView.show()
|
|
||||||
|
|
||||||
|
|
||||||
self.pathHBox = gtk.HBox(False, 0)
|
self.pathHBox = gtk.HBox(False, 0)
|
||||||
self.mainVBox.pack_start(self.pathHBox, False, True, 0)
|
self.mainVBox.pack_start(self.pathHBox, False, True, 0)
|
||||||
self.pathHBox.show()
|
self.pathHBox.show()
|
||||||
|
|
||||||
self.pathLabel = gtk.Label("Path to auto-import:")
|
self.pathStarsLabel = gtk.Label("Path to PokerStars auto-import:")
|
||||||
self.pathHBox.pack_start(self.pathLabel, False, False, 0)
|
self.pathHBox.pack_start(self.pathStarsLabel, False, False, 0)
|
||||||
self.pathLabel.show()
|
self.pathStarsLabel.show()
|
||||||
|
|
||||||
self.pathTBuffer=gtk.TextBuffer()
|
self.starsDirPath=gtk.Entry()
|
||||||
self.pathTBuffer.set_text(self.settings['hud-defaultPath'])
|
self.starsDirPath.set_text(self.settings['hud-defaultPath'])
|
||||||
self.pathTView=gtk.TextView(self.pathTBuffer)
|
self.pathHBox.pack_start(self.starsDirPath, False, True, 0)
|
||||||
self.pathHBox.pack_start(self.pathTView, False, True, 0)
|
self.starsDirPath.show()
|
||||||
self.pathTView.show()
|
|
||||||
|
|
||||||
self.browseButton=gtk.Button("Browse...")
|
self.browseButton=gtk.Button("Browse...")
|
||||||
self.browseButton.connect("clicked", self.browseClicked, "Browse clicked")
|
self.browseButton.connect("clicked", self.starsBrowseClicked, "Browse clicked")
|
||||||
self.pathHBox.pack_end(self.browseButton, False, False, 0)
|
self.pathHBox.pack_start(self.browseButton, False, False, 0)
|
||||||
self.browseButton.show()
|
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=gtk.Button("Start Autoimport")
|
||||||
self.startButton.connect("clicked", self.startClicked, "start clicked")
|
self.startButton.connect("clicked", self.startClicked, "start clicked")
|
||||||
|
|
|
@ -45,9 +45,9 @@ class GuiGraphViewer (threading.Thread):
|
||||||
try: self.canvas.destroy()
|
try: self.canvas.destroy()
|
||||||
except AttributeError: pass
|
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":
|
if site=="PS":
|
||||||
site=2
|
site=2
|
||||||
|
@ -121,21 +121,19 @@ class GuiGraphViewer (threading.Thread):
|
||||||
self.settingsHBox.pack_start(self.nameLabel)
|
self.settingsHBox.pack_start(self.nameLabel)
|
||||||
self.nameLabel.show()
|
self.nameLabel.show()
|
||||||
|
|
||||||
self.nameTBuffer=gtk.TextBuffer()
|
self.nameEntry=gtk.Entry()
|
||||||
self.nameTBuffer.set_text("name")
|
self.nameEntry.set_text("name")
|
||||||
self.nameTView=gtk.TextView(self.nameTBuffer)
|
self.settingsHBox.pack_start(self.nameEntry)
|
||||||
self.settingsHBox.pack_start(self.nameTView)
|
self.nameEntry.show()
|
||||||
self.nameTView.show()
|
|
||||||
|
|
||||||
self.siteLabel = gtk.Label("Site (PS or FTP):")
|
self.siteLabel = gtk.Label("Site (PS or FTP):")
|
||||||
self.settingsHBox.pack_start(self.siteLabel)
|
self.settingsHBox.pack_start(self.siteLabel)
|
||||||
self.siteLabel.show()
|
self.siteLabel.show()
|
||||||
|
|
||||||
self.siteTBuffer=gtk.TextBuffer()
|
self.siteEntry=gtk.Entry()
|
||||||
self.siteTBuffer.set_text("PS")
|
self.siteEntry.set_text("PS")
|
||||||
self.siteTView=gtk.TextView(self.siteTBuffer)
|
self.settingsHBox.pack_start(self.siteEntry)
|
||||||
self.settingsHBox.pack_start(self.siteTView)
|
self.siteEntry.show()
|
||||||
self.siteTView.show()
|
|
||||||
|
|
||||||
self.showButton=gtk.Button("Show/Refresh")
|
self.showButton=gtk.Button("Show/Refresh")
|
||||||
self.showButton.connect("clicked", self.showClicked, "show clicked")
|
self.showButton.connect("clicked", self.showClicked, "show clicked")
|
||||||
|
|
|
@ -104,25 +104,27 @@ class Importer:
|
||||||
|
|
||||||
#Add an individual file to filelist
|
#Add an individual file to filelist
|
||||||
def addImportFile(self, filename):
|
def addImportFile(self, filename):
|
||||||
#todo: test it is a valid file
|
#TODO: test it is a valid file
|
||||||
self.filelist = self.filelist + [filename]
|
self.filelist = self.filelist + [filename]
|
||||||
#Remove duplicates
|
#Remove duplicates
|
||||||
self.filelist = list(set(self.filelist))
|
self.filelist = list(set(self.filelist))
|
||||||
|
|
||||||
#Add a directory of files to filelist
|
#Add a directory of files to filelist
|
||||||
def addImportDirectory(self,dir,monitor = False):
|
def addImportDirectory(self,dir,monitor = False):
|
||||||
#todo: test it is a valid directory
|
if os.path.isdir(dir):
|
||||||
if monitor == True:
|
if monitor == True:
|
||||||
self.monitor = True
|
self.monitor = True
|
||||||
self.dirlist = self.dirlist + [dir]
|
self.dirlist = self.dirlist + [dir]
|
||||||
|
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if os.path.isdir(file):
|
if os.path.isdir(file):
|
||||||
print "BulkImport is not recursive - please select the final directory in which the history files are"
|
print "BulkImport is not recursive - please select the final directory in which the history files are"
|
||||||
else:
|
else:
|
||||||
self.filelist = self.filelist + [os.path.join(dir, file)]
|
self.filelist = self.filelist + [os.path.join(dir, file)]
|
||||||
#Remove duplicates
|
#Remove duplicates
|
||||||
self.filelist = list(set(self.filelist))
|
self.filelist = list(set(self.filelist))
|
||||||
|
else:
|
||||||
|
print "Warning: Attempted to add: '" + str(dir) + "' as an import directory"
|
||||||
|
|
||||||
#Run full import on filelist
|
#Run full import on filelist
|
||||||
def runImport(self):
|
def runImport(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user