Changeset 41
- Timestamp:
- 09/24/07 13:14:12 (1 year ago)
- Files:
-
- photobooth/photobooth.cfg (modified) (2 diffs)
- photobooth/photobooth.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
photobooth/photobooth.cfg
r39 r41 9 9 #device = /dev/tty.USA19H1d1P1.1 10 10 device = /dev/tty.usbserial-A3Q608W5 11 11 #device = /dev/tty.usbserial-A3Q609ZN 12 12 13 13 [SonMicroMifareSensorProtocol] … … 16 16 has_outputs = True 17 17 18 [JSONService] 19 username = XXX 20 password = XXX 21 base_url = http://picnicnetwork.org/services/rest 22 18 23 [NetworkConnectionSensor] 19 24 delay = 10 20 25 21 26 [JSONService] 22 base_url = http://pic 01.test.mediamatic.nl/services/rest/27 base_url = http://picnicnetwork.org/services/rest/ photobooth/photobooth.py
r40 r41 27 27 from fizzjik.remote import anymeta 28 28 29 import pprint 30 31 from twisted.web import client 32 29 33 class PhotoboothController(ConfigurableService): 30 34 implements(IController) 31 35 countdown = None 32 36 delay = 5.0 37 remote = None 33 38 34 39 def __init__(self, remote): … … 83 88 ] 84 89 return rv 85 d.addCallback(_addContacts)90 #d.addCallback(_addContacts) 86 91 return d 87 92 return defer.succeed(dict(tags=self.bucket)) … … 89 94 def _tagsToPeople(self): 90 95 l = [] 91 #for tag in self.bucket: 92 # l.append(self._getPersonByTag(tag)) 93 #d = defer.gatherResults(l) 94 95 return defer.succeed([{"id": "1417", "name": "Andy Smith"}, {"id": "4171", "name": "Koe"}]) 96 for tag in self.bucket: 97 l.append(self._getPersonByTag(tag).addCallback( 98 self._fillContacts)) 99 d = defer.gatherResults(l) 100 return d 101 102 #return defer.succeed([{"id": "1417", "name": "Andy Smith"}, {"id": "4171", "name": "Koe"}]) 96 103 return d 97 104 98 105 def _getPersonByTag(self, tag): 99 d = self.remote.identity.search.uri(uri='urn:rfid:%s'%(tag)) 100 d.addCallback(lambda x: x[0]) 101 return d 106 d = self.remote.call("identity.search.uri", 107 dict(uri='urn:rfid:%s'%(tag))) 108 def _getId(rv): 109 return rv[0]['thg_id'] 110 111 d.addCallback(_getId) 112 d.addCallback(self._getPersonByThing) 113 return d 114 115 def _getPersonByThing(self, thing): 116 d = self.remote.call("picnic.persons.get", 117 dict(id=thing)) 118 def _translate(rv): 119 rv['name'] = rv['name']['full'] 120 return rv 121 d.addCallback(_translate) 122 return d 123 124 def _fillContacts(self, person): 125 d = self.remote.call("picnic.relations.getList", 126 dict(id=person['id'])) 127 def _really(rv): 128 l = [] 129 for c in rv: 130 #pprint.pprint(c) 131 132 contact_id = c[1] 133 l.append(self._getPersonByThing(contact_id)) 134 return defer.gatherResults(l) 135 d.addCallback(_really) 136 def _fill(rv): 137 person['contacts'] = rv 138 return person 139 d.addCallback(_fill) 140 return d 141 102 142 103 143 … … 171 211 lpr.setServiceParent(hub) 172 212 173 xmlrpc = XMLRPCService()174 xmlrpc.setServiceParent(hub)175 176 json = JSONService()213 #xmlrpc = XMLRPCService() 214 #xmlrpc.setServiceParent(hub) 215 216 json = anymeta.JSONService() 177 217 json.setServiceParent(hub) 178 218 179 controller = PhotoboothController( JSONService)219 controller = PhotoboothController(json) 180 220 controller.setServiceParent(hub) 181 221
