summary refs log tree commit diff
path: root/Blather.py
diff options
context:
space:
mode:
Diffstat (limited to 'Blather.py')
-rwxr-xr-xBlather.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/Blather.py b/Blather.py
index 461a456..f5d8a67 100755
--- a/Blather.py
+++ b/Blather.py
@@ -36,7 +36,7 @@ class Blather:
 		self.read_commands()
 		self.recognizer = Recognizer(lang_file, dic_file)
 		self.recognizer.connect('finished',self.recognizer_finished)
-		
+
 		if opts.interface != None:
 			if opts.interface == "q":
 				#import the ui from qt
@@ -46,18 +46,18 @@ class Blather:
 			else:
 				print "no GUI defined"
 				sys.exit()
-				
+
 			self.ui = UI(args,opts.continuous)
 			self.ui.connect("command", self.process_command)
 			#can we load the icon resource?
 			icon = self.load_resource("icon.png")
 			if icon:
 				self.ui.set_icon(icon)
-		
+
 		if self.opts.history:
 			self.history = []
-		
-					
+
+
 	def read_commands(self):
 		#read the.commands file
 		file_lines = open(command_file)
@@ -75,21 +75,21 @@ class Blather:
 						strings.write( key.strip()+"\n")
 		#close the strings file
 		strings.close()
-	
+
 	def log_history(self,text):
 		if self.opts.history:
 			self.history.append(text)
 			if len(self.history) > self.opts.history:
 				#pop off the first item
 				self.history.pop(0)
-			
+
 			#open and truncate the blather history file
 			hfile = open(history_file, "w")
 			for line in self.history:
 				hfile.write( line+"\n")
 			#close the  file
 			hfile.close()
-	
+
 	def recognizer_finished(self, recognizer, text):
 		t = text.lower()
 		#is there a matching command?
@@ -107,16 +107,14 @@ class Blather:
 				self.recognizer.pause()
 			#let the UI know that there is a finish
 			self.ui.finished(t)
-	
+
 	def run(self):
 		if self.ui:
 			self.ui.run()
 		else:
-			blather.recognizer.listen()	
+			blather.recognizer.listen()
 
 	def quit(self):
-		if self.ui:
-			self.ui.quit()
 		sys.exit()
 
 	def process_command(self, UI, command):
@@ -133,7 +131,7 @@ class Blather:
 			self.recognizer.pause()
 		elif command == "quit":
 			self.quit()
-	
+
 	def load_resource(self,string):
 		local_data = os.path.join(os.path.dirname(__file__), 'data')
 		paths = ["/usr/share/blather/","/usr/local/share/blather", local_data]
@@ -143,9 +141,9 @@ class Blather:
 				return resource
 		#if we get this far, no resource was found
 		return False
-    
-    
-    
+
+
+
 if __name__ == "__main__":
 	parser = OptionParser()
 	parser.add_option("-i", "--interface",  type="string", dest="interface",
@@ -155,7 +153,7 @@ if __name__ == "__main__":
 		action="store_true", dest="continuous", default=False,
 		help="starts interface with 'continuous' listen enabled")
 	parser.add_option("-H", "--history", type="int",
-		action="store", dest="history", 	
+		action="store", dest="history",
 		help="number of commands to store in history file")
 
 	(options, args) = parser.parse_args()
@@ -170,11 +168,11 @@ if __name__ == "__main__":
 	#run the blather
 	blather.run()
 	#start the main loop
-		
+
 	try:
 		main_loop.run()
 	except:
 		print "time to quit"
 		main_loop.quit()
 		sys.exit()
-		
+