Browse Source

Added -p --pass-words flag that will pass the recognized words to the shell command

a few print commands were remove too.
Jezra 10 years ago
parent
commit
87585c7b20
4 changed files with 15 additions and 5 deletions
  1. 15
    2
      Blather.py
  2. 0
    1
      GtkTrayUI.py
  3. 0
    1
      GtkUI.py
  4. 0
    1
      QtUI.py

+ 15
- 2
Blather.py View File

123
 			#close the  file
123
 			#close the  file
124
 			hfile.close()
124
 			hfile.close()
125
 
125
 
126
+	# Print the cmd and then run the command
127
+	def run_command(self, cmd):
128
+		print cmd
129
+		subprocess.call(cmd, shell=True)
130
+
126
 	def recognizer_finished(self, recognizer, text):
131
 	def recognizer_finished(self, recognizer, text):
127
 		t = text.lower()
132
 		t = text.lower()
128
 		#is there a matching command?
133
 		#is there a matching command?
131
 			if self.options['valid_sentence_command']:
136
 			if self.options['valid_sentence_command']:
132
 				subprocess.call(self.options['valid_sentence_command'], shell=True)
137
 				subprocess.call(self.options['valid_sentence_command'], shell=True)
133
 			cmd = self.commands[t]
138
 			cmd = self.commands[t]
134
-			print cmd
135
-			subprocess.call(cmd, shell=True)
139
+			#should we be passing words?
140
+			if self.options['pass_words']:
141
+				cmd+=" "+t
142
+				self.run_command(cmd)
143
+			else:
144
+				self.run_command(cmd)
136
 			self.log_history(text)
145
 			self.log_history(text)
137
 		else:
146
 		else:
138
 			#run the invalid_sentence_command if there is a valid sentence command
147
 			#run the invalid_sentence_command if there is a valid sentence command
192
 		action="store_true", dest="continuous", default=False,
201
 		action="store_true", dest="continuous", default=False,
193
 		help="starts interface with 'continuous' listen enabled")
202
 		help="starts interface with 'continuous' listen enabled")
194
 
203
 
204
+	parser.add_option("-p", "--pass-words",
205
+		action="store_true", dest="pass_words", default=False,
206
+		help="passes the recognized words as arguments to the shell command")
207
+
195
 	parser.add_option("-o", "--override",
208
 	parser.add_option("-o", "--override",
196
 		action="store_true", dest="override", default=False,
209
 		action="store_true", dest="override", default=False,
197
 		help="override config file with command line options")
210
 		help="override config file with command line options")

+ 0
- 1
GtkTrayUI.py View File

80
 		self.emit("command", "quit")
80
 		self.emit("command", "quit")
81
 
81
 
82
 	def finished(self, text):
82
 	def finished(self, text):
83
-		print text
84
 		if not self.menu_continuous.get_active():
83
 		if not self.menu_continuous.get_active():
85
 			self.menu_listen.set_label("Listen")
84
 			self.menu_listen.set_label("Listen")
86
 			self.statusicon.set_from_icon_name("blather_stopped")
85
 			self.statusicon.set_from_icon_name("blather_stopped")

+ 0
- 1
GtkUI.py View File

90
 		self.emit("command", "quit")
90
 		self.emit("command", "quit")
91
 
91
 
92
 	def finished(self, text):
92
 	def finished(self, text):
93
-		print text
94
 		#if the continuous isn't pressed
93
 		#if the continuous isn't pressed
95
 		if not self.ccheckbox.get_active():
94
 		if not self.ccheckbox.get_active():
96
 			self.lsbutton_stopped()
95
 			self.lsbutton_stopped()

+ 0
- 1
QtUI.py View File

93
 		self.emit("command", "quit")
93
 		self.emit("command", "quit")
94
 
94
 
95
 	def finished(self, text):
95
 	def finished(self, text):
96
-		print text
97
 		#if the continuous isn't pressed
96
 		#if the continuous isn't pressed
98
 		if not self.ccheckbox.isChecked():
97
 		if not self.ccheckbox.isChecked():
99
 			self.lsbutton_stopped()
98
 			self.lsbutton_stopped()

Loading…
Cancel
Save