Permalink
Browse files

removed type requirement for input to broadcast(), converted messages…

… to strings before sending to Scratch
  • Loading branch information...
1 parent affa165 commit e87339a7c37505ce1a5152633ef42df73d3905fc @pilliq committed Dec 27, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 scratch.py
View
@@ -70,17 +70,18 @@ def sensorupdate(self, data):
raise TypeError('Expected a dict')
message = 'sensor-update'
for key in data.keys():
- message = message+' "'+key+'" '+str(data[key])
+ message = message+' "'+str(key)+'" '+str(data[key])
self.send(message)
def broadcast(self, data):
"""Takes a list of message strings and writes a broadcast message to scratch"""
- if not isinstance(data, list):
- raise TypeError('Expected a list')
message = 'broadcast'
- for mess in data:
- message = message+' "'+mess+'"'
- self.send(message)
+ if isinstance(data, list):
+ for mess in data:
+ message = message+' "'+str(mess)+'"'
+ self.send(message)
+ else:
+ self.send(message+' "'+str(data)+'"')
def parse_message(self, message):
#TODO: parse sensorupdates with quotes in sensor names and values

0 comments on commit e87339a

Please sign in to comment.