add textview to autoimport window for dropping status/info messages on, just call it's AddText func to get it there
This commit is contained in:
		
							parent
							
								
									3439523de8
								
							
						
					
					
						commit
						67beb4bd9f
					
				| 
						 | 
				
			
			@ -71,22 +71,24 @@ class GuiAutoImport (threading.Thread):
 | 
			
		|||
 | 
			
		||||
        self.intervalLabel = gtk.Label("Time between imports in seconds:")
 | 
			
		||||
        self.intervalLabel.set_alignment(xalign=1.0, yalign=0.5)
 | 
			
		||||
        vbox1.pack_start(self.intervalLabel, True, True, 0)
 | 
			
		||||
        vbox1.pack_start(self.intervalLabel, False, True, 0)
 | 
			
		||||
 | 
			
		||||
        hbox = gtk.HBox(False, 0)
 | 
			
		||||
        vbox2.pack_start(hbox, True, True, 0)
 | 
			
		||||
        vbox2.pack_start(hbox, False, True, 0)
 | 
			
		||||
        self.intervalEntry = gtk.Entry()
 | 
			
		||||
        self.intervalEntry.set_text(str(self.config.get_import_parameters().get("interval")))
 | 
			
		||||
        hbox.pack_start(self.intervalEntry, False, False, 0)
 | 
			
		||||
        lbl1 = gtk.Label()
 | 
			
		||||
        hbox.pack_start(lbl1, expand=True, fill=True)
 | 
			
		||||
        hbox.pack_start(lbl1, expand=False, fill=True)
 | 
			
		||||
 | 
			
		||||
        lbl = gtk.Label('')
 | 
			
		||||
        vbox1.pack_start(lbl, expand=True, fill=True)
 | 
			
		||||
        vbox1.pack_start(lbl, expand=False, fill=True)
 | 
			
		||||
        lbl = gtk.Label('')
 | 
			
		||||
        vbox2.pack_start(lbl, expand=True, fill=True)
 | 
			
		||||
        vbox2.pack_start(lbl, expand=False, fill=True)
 | 
			
		||||
 | 
			
		||||
        self.addSites(vbox1, vbox2)
 | 
			
		||||
        self.textbuffer = gtk.TextBuffer()
 | 
			
		||||
        self.textview = gtk.TextView(self.textbuffer)
 | 
			
		||||
 | 
			
		||||
        hbox = gtk.HBox(False, 0)
 | 
			
		||||
        self.mainVBox.pack_start(hbox, expand=True, padding=3)
 | 
			
		||||
| 
						 | 
				
			
			@ -102,13 +104,27 @@ class GuiAutoImport (threading.Thread):
 | 
			
		|||
        self.startButton.connect("clicked", self.startClicked, "start clicked")
 | 
			
		||||
        hbox.pack_start(self.startButton, expand=False, fill=False)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        lbl2 = gtk.Label()
 | 
			
		||||
        hbox.pack_start(lbl2, expand=True, fill=False)
 | 
			
		||||
 | 
			
		||||
        hbox = gtk.HBox(False, 0)
 | 
			
		||||
        hbox.show()
 | 
			
		||||
 | 
			
		||||
        self.mainVBox.pack_start(hbox, expand=True, padding=3)
 | 
			
		||||
 | 
			
		||||
        scrolledwindow = gtk.ScrolledWindow()
 | 
			
		||||
        scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
 | 
			
		||||
        self.mainVBox.pack_end(scrolledwindow, expand=True)
 | 
			
		||||
        scrolledwindow.add(self.textview)
 | 
			
		||||
 | 
			
		||||
        self.mainVBox.show_all()
 | 
			
		||||
        self.addText("AutoImport Ready.")
 | 
			
		||||
 | 
			
		||||
    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)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #end of GuiAutoImport.__init__
 | 
			
		||||
| 
						 | 
				
			
			@ -139,8 +155,9 @@ class GuiAutoImport (threading.Thread):
 | 
			
		|||
        if self.doAutoImportBool:
 | 
			
		||||
            self.startButton.set_label(u' I M P O R T I N G  ')
 | 
			
		||||
            self.importer.runUpdated()
 | 
			
		||||
            sys.stdout.write(".")
 | 
			
		||||
            sys.stdout.flush()
 | 
			
		||||
            self.addText(".")
 | 
			
		||||
            #sys.stdout.write(".")
 | 
			
		||||
            #sys.stdout.flush()
 | 
			
		||||
            gobject.timeout_add(1000, self.reset_startbutton)
 | 
			
		||||
            return True
 | 
			
		||||
        return False
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +189,7 @@ class GuiAutoImport (threading.Thread):
 | 
			
		|||
            # - Ideally we want to release the lock if the auto-import is killed by some
 | 
			
		||||
            # kind of exception - is this possible?
 | 
			
		||||
            if self.settings['global_lock'].acquire(False):   # returns false immediately if lock not acquired
 | 
			
		||||
                print "\nGlobal lock taken ..."
 | 
			
		||||
                self.addText("\nGlobal lock taken ... Auto Import Started.\n")
 | 
			
		||||
                self.doAutoImportBool = True
 | 
			
		||||
                widget.set_label(u'  _Stop Autoimport  ')
 | 
			
		||||
                if self.pipe_to_hud is None:
 | 
			
		||||
| 
						 | 
				
			
			@ -190,12 +207,11 @@ class GuiAutoImport (threading.Thread):
 | 
			
		|||
                                                            universal_newlines=True)
 | 
			
		||||
                    except:
 | 
			
		||||
                        err = traceback.extract_tb(sys.exc_info()[2])[-1]
 | 
			
		||||
                        print "*** GuiAutoImport Error opening pipe: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
 | 
			
		||||
                        self.addText( "\n*** GuiAutoImport Error opening pipe: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1]))
 | 
			
		||||
                    else:
 | 
			
		||||
                        for site in self.input_settings:
 | 
			
		||||
                            self.importer.addImportDirectory(self.input_settings[site][0], True, site, self.input_settings[site][1])
 | 
			
		||||
                            print " * Add", site, " import directory", str(self.input_settings[site][0])
 | 
			
		||||
                            print "+Import directory - Site: " + site + " dir: " + str(self.input_settings[site][0])
 | 
			
		||||
                            self.addText("\n * Add "+ site+ " import directory "+ str(self.input_settings[site][0]))
 | 
			
		||||
                            self.do_import()
 | 
			
		||||
                            interval = int(self.intervalEntry.get_text())
 | 
			
		||||
                    if self.importtimer != 0:
 | 
			
		||||
| 
						 | 
				
			
			@ -203,14 +219,14 @@ class GuiAutoImport (threading.Thread):
 | 
			
		|||
                    self.importtimer = gobject.timeout_add(interval * 1000, self.do_import)
 | 
			
		||||
 | 
			
		||||
            else:
 | 
			
		||||
                print "auto-import aborted - global lock not available"
 | 
			
		||||
                self.addText("\nauto-import aborted - global lock not available")
 | 
			
		||||
        else: # toggled off
 | 
			
		||||
            gobject.source_remove(self.importtimer)
 | 
			
		||||
            self.settings['global_lock'].release()
 | 
			
		||||
            self.doAutoImportBool = False # do_import will return this and stop the gobject callback timer
 | 
			
		||||
            print "Stopping autoimport - global lock released."
 | 
			
		||||
            self.addText("\nStopping autoimport - global lock released.")
 | 
			
		||||
            if self.pipe_to_hud.poll() is not None:
 | 
			
		||||
                print " * Stop Autoimport: HUD already terminated"
 | 
			
		||||
                self.addText("\n * Stop Autoimport: HUD already terminated")
 | 
			
		||||
            else:
 | 
			
		||||
                #print >>self.pipe_to_hud.stdin, "\n"
 | 
			
		||||
                self.pipe_to_hud.communicate('\n') # waits for process to terminate
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -262,7 +262,7 @@ class HUD_main(object):
 | 
			
		|||
                    if hasattr(tablewindow, 'number'):
 | 
			
		||||
                        self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, type, stat_dict, cards)
 | 
			
		||||
                    else:
 | 
			
		||||
                        sys.stderr.write('Table "%s" no longer exists\n', table_name)
 | 
			
		||||
                        sys.stderr.write('Table "%s" no longer exists\n' % table_name)
 | 
			
		||||
 | 
			
		||||
            self.db_connection.connection.rollback()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -357,6 +357,11 @@ class Importer:
 | 
			
		|||
                if file in self.updatedsize: # we should be able to assume that if we're in size, we're in time as well
 | 
			
		||||
                    if stat_info.st_size > self.updatedsize[file] or stat_info.st_mtime > self.updatedtime[file]:
 | 
			
		||||
#                        print "file",counter," updated", os.path.basename(file), stat_info.st_size, self.updatedsize[file], stat_info.st_mtime, self.updatedtime[file]
 | 
			
		||||
                        try:
 | 
			
		||||
                            if not os.path.isdir(file):
 | 
			
		||||
                                self.caller.addText("\n"+file)
 | 
			
		||||
                        except KeyError: # TODO: What error happens here?
 | 
			
		||||
                            pass
 | 
			
		||||
                        self.import_file_dict(self.database, file, self.filelist[file][0], self.filelist[file][1], None)
 | 
			
		||||
                        self.updatedsize[file] = stat_info.st_size
 | 
			
		||||
                        self.updatedtime[file] = time()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user