def event_from_message(self, body, localize=True, now=time.time, tzfields=_TZGETTER, adjust_timestamp=adjust_timestamp, CLIENT_CLOCK_SKEW=CLIENT_CLOCK_SKEW): type = body['type'] if type == 'task-sent': # clients never sync so cannot use their clock value _c = body['clock'] = (self.clock.value or 1) + CLIENT_CLOCK_SKEW self.adjust_clock(_c) else: try: clock = body['clock'] except KeyError: body['clock'] = self.forward_clock() else: self.adjust_clock(clock) if localize: try: offset, timestamp = tzfields(body) except KeyError: pass else: body['timestamp'] = adjust_timestamp(timestamp, offset) body['local_received'] = now() return type, body
def event_from_message(self, body, localize=True, now=time.time): type = body.get('type', '').lower() clock = body.get('clock') if clock: self.adjust_clock(clock) if localize: try: offset, timestamp = _TZGETTER(body) except KeyError: pass else: body['timestamp'] = adjust_timestamp(timestamp, offset) return type, Event(type, body, local_received=now())
def event_from_message( self, body, localize=True, now=monotonic, tzfields=_TZGETTER, adjust_timestamp=adjust_timestamp ): type = body.get("type", "").lower() clock = body.get("clock") if clock: self.adjust_clock(clock) if localize: try: offset, timestamp = tzfields(body) except KeyError: pass else: body["timestamp"] = adjust_timestamp(timestamp, offset) return type, Event(type, body, local_received=now())
def event_from_message( self, body, localize=True, now=time.time, tzfields=_TZGETTER, adjust_timestamp=adjust_timestamp ): type = body["type"] if type == "task-sent": # clients never sync so cannot use their clock value body["clock"] = self.forward_clock() else: try: clock = body["clock"] except KeyError: body["clock"] = self.forward_clock() else: self.adjust_clock(clock) if localize: try: offset, timestamp = tzfields(body) except KeyError: pass else: body["timestamp"] = adjust_timestamp(timestamp, offset) body["local_received"] = now() return type, body