add useful (hopefully) exception handler
This commit is contained in:
		
							parent
							
								
									f3a4a8b0d0
								
							
						
					
					
						commit
						3b9fa3b177
					
				| 
						 | 
					@ -159,29 +159,33 @@ class GuiAutoImport (threading.Thread):
 | 
				
			||||||
            # - Ideally we want to release the lock if the auto-import is killed by some 
 | 
					            # - Ideally we want to release the lock if the auto-import is killed by some 
 | 
				
			||||||
            # kind of exception - is this possible?
 | 
					            # kind of exception - is this possible?
 | 
				
			||||||
            if self.settings['global_lock'].acquire(False):   # returns false immediately if lock not acquired
 | 
					            if self.settings['global_lock'].acquire(False):   # returns false immediately if lock not acquired
 | 
				
			||||||
                print "\nGlobal lock taken ..."
 | 
					                try:
 | 
				
			||||||
                self.doAutoImportBool = True
 | 
					                    print "\nGlobal lock taken ..."
 | 
				
			||||||
                widget.set_label(u'  _Stop Autoimport  ')
 | 
					                    self.doAutoImportBool = True
 | 
				
			||||||
                if self.pipe_to_hud is None:
 | 
					                    widget.set_label(u'  _Stop Autoimport  ')
 | 
				
			||||||
                    if os.name == 'nt':
 | 
					                    if self.pipe_to_hud is None:
 | 
				
			||||||
                        command = "python HUD_main.py" + " " + self.settings['cl_options']
 | 
					                        if os.name == 'nt':
 | 
				
			||||||
                        bs = 0    # windows is not happy with line buffing here
 | 
					                            command = "python HUD_main.py" + " " + self.settings['cl_options']
 | 
				
			||||||
                        self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE, 
 | 
					                            bs = 0    # windows is not happy with line buffing here
 | 
				
			||||||
                                                        universal_newlines=True)
 | 
					                            self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE, 
 | 
				
			||||||
                    else:
 | 
					                                                            universal_newlines=True)
 | 
				
			||||||
                        command = os.path.join(sys.path[0],  'HUD_main.py')
 | 
					                        else:
 | 
				
			||||||
                        cl = [command, ] + string.split(self.settings['cl_options'])
 | 
					                            command = os.path.join(sys.path[0],  'HUD_main.py')
 | 
				
			||||||
                        self.pipe_to_hud = subprocess.Popen(cl, bufsize = 1, stdin = subprocess.PIPE, 
 | 
					                            cl = [command, ] + string.split(self.settings['cl_options'])
 | 
				
			||||||
                                                        universal_newlines=True)
 | 
					                            self.pipe_to_hud = subprocess.Popen(cl, bufsize = 1, stdin = subprocess.PIPE, 
 | 
				
			||||||
 | 
					                                                            universal_newlines=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    # Add directories to importer object.
 | 
					                        # Add directories to importer object.
 | 
				
			||||||
                    for site in self.input_settings:
 | 
					                        for site in self.input_settings:
 | 
				
			||||||
                        self.importer.addImportDirectory(self.input_settings[site][0], True, site, self.input_settings[site][1])
 | 
					                            self.importer.addImportDirectory(self.input_settings[site][0], True, site, self.input_settings[site][1])
 | 
				
			||||||
                        print "Adding import directories - Site: " + site + " dir: "+ str(self.input_settings[site][0])
 | 
					                            print "Adding import directories - Site: " + site + " dir: "+ str(self.input_settings[site][0])
 | 
				
			||||||
                        self.do_import()
 | 
					                            self.do_import()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        interval=int(self.intervalEntry.get_text())
 | 
					                            interval=int(self.intervalEntry.get_text())
 | 
				
			||||||
                        gobject.timeout_add(interval*1000, self.do_import)
 | 
					                            gobject.timeout_add(interval*1000, self.do_import)
 | 
				
			||||||
 | 
					                except:
 | 
				
			||||||
 | 
					                    err = traceback.extract_tb(sys.exc_info()[2])[-1]
 | 
				
			||||||
 | 
					                    print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                print "auto-import aborted - global lock not available"
 | 
					                print "auto-import aborted - global lock not available"
 | 
				
			||||||
        else: # toggled off
 | 
					        else: # toggled off
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user