Example #1
    def get_plugin_list(self, withdetails=False):
        """Get plugin list.

        :param bool withdetails: True if you want to get plugin list with details.
        data = (
                name: {
                    "description": item.description,
                    "every": item.every,
                    "lastExecutedAt": dtutils.unixtime(item.last_executed_at) if item.last_executed_at else None,
                    "lastExecutedResult": item.last_executed_result,
                for name, item in self.plugins.items()
            if withdetails
            else self.plugins.keys()

        return data
Example #2
    def get_plugin_logs(self, name, gte, lte=None):
        """Get plugin logs.

        :param str name: Plugin name
        :param gte: Greater than or equal to (created time)
        :param lte: Less than or equal to (created time)
        if name not in self.plugins.keys():
            raise KeyError("Plugin does not exist.")

        data = {}
        plugin = self.plugins[name]
        for k, v in plugin.fields.items():
            fielddata = {"type": plugin.field_types[k], "legends": ["created"] + [n for n, _ in v], "data": []}
            records = plugin.models[k].objects(created_at__gte=gte, created_at__lte=lte)
            for record in records:
                items = [dtutils.unixtime(record.created_at)]
                for n, _ in v:
                    items.append(getattr(record.items, n))
            data[k] = fielddata

        return data
Example #3
def test_raises_dtutils_unxtime():
    with raises(TypeError):
Example #4
def test_dtutils_unixtime(params, expected):
    assert dtutils.unixtime(*params) == expected