@@ -34,6 +34,7 @@ def __init__(self, _id, package_name, verbose=False):
3434 # False in its constructor.
3535 self .ready = True
3636
37+ self .verbose = verbose
3738 self .manager_proxy = \
3839 AddonManagerProxy (self .package_name , verbose = verbose )
3940 self .manager_proxy .add_adapter (self )
@@ -60,7 +61,8 @@ def send_error(self, message):
6061
6162 def dump (self ):
6263 """Dump the state of the adapter to the log."""
63- print ('Adapter:' , self .name , '- dump() not implemented' )
64+ if self .verbose :
65+ print ('Adapter:' , self .name , '- dump() not implemented' )
6466
6567 def get_id (self ):
6668 """
@@ -166,7 +168,8 @@ def start_pairing(self, timeout):
166168
167169 timeout -- Timeout in seconds at which to quit pairing
168170 """
169- print ('Adapter:' , self .name , 'id' , self .id , 'pairing started' )
171+ if self .verbose :
172+ print ('Adapter:' , self .name , 'id' , self .id , 'pairing started' )
170173
171174 def send_pairing_prompt (self , prompt , url = None , device = None ):
172175 """
@@ -190,7 +193,8 @@ def send_unpairing_prompt(self, prompt, url=None, device=None):
190193
191194 def cancel_pairing (self ):
192195 """Cancel the pairing process."""
193- print ('Adapter:' , self .name , 'id' , self .id , 'pairing cancelled' )
196+ if self .verbose :
197+ print ('Adapter:' , self .name , 'id' , self .id , 'pairing cancelled' )
194198
195199 def remove_thing (self , device_id ):
196200 """
@@ -200,8 +204,9 @@ def remove_thing(self, device_id):
200204 """
201205 device = self .get_device (device_id )
202206 if device :
203- print ('Adapter:' , self .name , 'id' , self .id ,
204- 'remove_thing(' + device .id + ')' )
207+ if self .verbose :
208+ print ('Adapter:' , self .name , 'id' , self .id ,
209+ 'remove_thing(' + device .id + ')' )
205210
206211 self .handle_device_removed (device )
207212
@@ -212,13 +217,14 @@ def cancel_remove_thing(self, device_id):
212217 device_id -- ID of device to cancel unpairing with
213218 """
214219 device = self .get_device (device_id )
215- if device :
220+ if device and self . verbose :
216221 print ('Adapter:' , self .name , 'id' , self .id ,
217222 'cancel_remove_thing(' + device .id + ')' )
218223
219224 def unload (self ):
220225 """Perform any necessary cleanup before adapter is shut down."""
221- print ('Adapter:' , self .name , 'unloaded' )
226+ if self .verbose :
227+ print ('Adapter:' , self .name , 'unloaded' )
222228
223229 def set_pin (self , device_id , pin ):
224230 """
@@ -229,8 +235,9 @@ def set_pin(self, device_id, pin):
229235 """
230236 device = self .get_device (device_id )
231237 if device :
232- print ('Adapter:' , self .name , 'id' , self .id ,
233- 'set_pin(' + device .id + ', ' + pin + ')' )
238+ if self .verbose :
239+ print ('Adapter:' , self .name , 'id' , self .id ,
240+ 'set_pin(' + device .id + ', ' + pin + ')' )
234241 else :
235242 raise SetPinError ('Device not found' )
236243
@@ -244,8 +251,9 @@ def set_credentials(self, device_id, username, password):
244251 """
245252 device = self .get_device (device_id )
246253 if device :
247- print ('Adapter:' , self .name , 'id' , self .id ,
248- 'set_credentials(' + device .id + ', ' + username + ', ' +
249- password + ')' )
254+ if self .verbose :
255+ print ('Adapter:' , self .name , 'id' , self .id ,
256+ 'set_credentials(' + device .id + ', ' + username + ', ' +
257+ password + ')' )
250258 else :
251259 raise SetCredentialsError ('Device not found' )
0 commit comments