equal
deleted
inserted
replaced
77 if not event_ids or not event_ids[0]: |
77 if not event_ids or not event_ids[0]: |
78 raise http.HttpException(400, "The event parameter is missing") |
78 raise http.HttpException(400, "The event parameter is missing") |
79 self.event = event_ids[0] |
79 self.event = event_ids[0] |
80 self._init_props(self.factory.ws_factory, self.factory.conn) |
80 self._init_props(self.factory.ws_factory, self.factory.conn) |
81 |
81 |
|
82 def clean_annot(self, annot): |
|
83 if 'ts' in annot: |
|
84 annot['ts'] = annot['ts'].isoformat() |
|
85 if 'uuid' in annot: |
|
86 annot['uuid'] = str(annot['uuid']) |
|
87 |
82 #TODO: add error handling |
88 #TODO: add error handling |
83 def onMessage(self, payload, isBinary): |
89 def onMessage(self, payload, isBinary): |
84 if isBinary: |
90 if isBinary: |
85 return |
91 return |
86 msg = payload.decode('utf8') |
92 msg = payload.decode('utf8') |
92 'content' : params_annot |
98 'content' : params_annot |
93 } |
99 } |
94 |
100 |
95 def error_callback(failure): |
101 def error_callback(failure): |
96 res = params.copy() |
102 res = params.copy() |
|
103 self.clean_annot(res) |
97 res['status'] = 'KO' |
104 res['status'] = 'KO' |
98 res['failure'] = str(failure) |
105 res['failure'] = str(failure) |
99 self.sendMessage(json.dumps(res)) |
106 self.sendMessage(json.dumps(res)) |
100 |
107 |
101 def annot_callback(res): |
108 def annot_callback(res): |
102 if 'ts' in res: |
109 self.clean_annot(res) |
103 res['ts'] = res['ts'].isoformat()+'Z' |
|
104 if 'uuid' in res: |
|
105 res['uuid'] = str(res['uuid']) |
|
106 res['status'] = 'OK' |
110 res['status'] = 'OK' |
107 self.sendMessage(json.dumps(res)) |
111 self.sendMessage(json.dumps(res)) |
108 |
112 |
109 |
113 |
110 defer = self.process_annotation(params) |
114 defer = self.process_annotation(params) |