Exemplo n.º 1
0
    def last_reacted_on(self):
        """Gives the timestamp of the last time when the reactor's action has
        been executed

        Returns:
            str if reactor reacted at least once, ``None`` otherwise

        """
        if self.last_reaction_timestamp is None:
            return None
        return ts.stringify(self.last_reaction_timestamp)
Exemplo n.º 2
0
    def json(self):
        """Dumps this object to a JSON string.

        Returns:
            str

        """
        data = dict(id=self.id, owner=self.owner, description=self.description,
                    eventtypes=[str(et) for et in self.types],
                    tags=list(self.tags), timestamp=ts.stringify(self.timestamp))
        return dumps(data)
Exemplo n.º 3
0
    def json(self):
        """Dumps this object to a JSON string.

        Returns:
            str

        """
        data = dict(id=self.id,
                    type=self.type.json(),
                    owner=self.owner,
                    status=self.status,
                    description=self.description,
                    payload=self.payload,
                    tags=list(self.tags),
                    timestamp=ts.stringify(self.timestamp))
        return dumps(data)
Exemplo n.º 4
0
 def __setattr__(self, key, value):
     event = Event(DataOperationEventType,
                   payload={
                       'datum': {
                           'class': 'Observed',
                           'property': 'field'
                       },
                       'operation': 'modify',
                       'timestamp': stringify(utc_now()),
                       'meta': {
                           'old_value': self.field,
                           'new_value': value
                       }
                   })
     super().__setattr__(key, value)
     brq.publish(event)
Exemplo n.º 5
0
def test_stringify():
    dateobj = datetime.datetime(1983, 7, 3, 9, 0, 0)
    result = timestamp.stringify(dateobj)
    assert isinstance(result, str)