Exemplo n.º 1
0
def plugins(request):

    Service = namedtuple("Service", ["name", "status", "pid", "start_url", "stop_url", "status_url", "jail_status"])

    host = get_base_url(request)
    plugins = models.Plugins.objects.filter(plugin_enabled=True)
    args = map(lambda y: (y, host, request), plugins)

    pool = eventlet.GreenPool(20)
    for plugin, _json, jail_status in pool.imap(get_plugin_status, args):
        if not _json:
            _json = {}
            _json["status"] = None

        plugin.service = Service(
            name=plugin.plugin_name,
            status=_json["status"],
            pid=_json.get("pid", None),
            start_url="/plugins/%s/%d/_s/start" % (plugin.plugin_name, plugin.id),
            stop_url="/plugins/%s/%d/_s/stop" % (plugin.plugin_name, plugin.id),
            status_url="/plugins/%s/%d/_s/status" % (plugin.plugin_name, plugin.id),
            jail_status=jail_status,
        )

        plugin.update_available = availablePlugins.get_update_status(plugin.id)

    return render(request, "plugins/plugins.html", {"plugins": plugins})
Exemplo n.º 2
0
def plugins(request):
    jc_path = None
    try:
        jc = JailsConfiguration.objects.order_by("-id")[0]
        jc_path = jc.jc_path

    except:
        jc_path = None

    Service = namedtuple('Service', [
        'name',
        'status',
        'pid',
        'start_url',
        'stop_url',
        'status_url',
        'jail_status',
    ])

    host = get_base_url(request)

    plugins = []
    temp = models.Plugins.objects.filter(plugin_enabled=True)
    if jc_path:
        for t in temp:
            if os.path.exists("%s/%s" % (jc_path, t.plugin_jail)):
                plugins.append(t)

    args = [(y, host, request) for y in plugins]

    with ThreadPool(10) as pool:
        for plugin, _json, jail_status in pool.imap(get_plugin_status, args):
            if not _json:
                _json = {}
                _json['status'] = None

            plugin.service = Service(
                name=plugin.plugin_name,
                status=_json['status'],
                pid=_json.get("pid", None),
                start_url="/plugins/%s/%d/_s/start" % (
                    plugin.plugin_name, plugin.id
                ),
                stop_url="/plugins/%s/%d/_s/stop" % (
                    plugin.plugin_name, plugin.id
                ),
                status_url="/plugins/%s/%d/_s/status" % (
                    plugin.plugin_name, plugin.id
                ),
                jail_status=jail_status,
            )

            plugin.update_available = availablePlugins.get_update_status(plugin.id)

    return render(request, "plugins/plugins.html", {
        'plugins': plugins,
    })
Exemplo n.º 3
0
def plugins(request):
    jc_path = None
    try:
        jc = JailsConfiguration.objects.order_by("-id")[0]
        jc_path = jc.jc_path

    except:
        jc_path = None

    Service = namedtuple('Service', [
        'name',
        'status',
        'pid',
        'start_url',
        'stop_url',
        'status_url',
        'jail_status',
    ])

    host = get_base_url(request)

    plugins = []
    temp = models.Plugins.objects.filter(plugin_enabled=True)
    if jc_path:
        for t in temp:
            if os.path.exists("%s/%s" % (jc_path, t.plugin_jail)):
                plugins.append(t)

    args = map(lambda y: (y, host, request), plugins)

    pool = eventlet.GreenPool(20)
    for plugin, _json, jail_status in pool.imap(get_plugin_status, args):
        if not _json:
            _json = {}
            _json['status'] = None

        plugin.service = Service(
            name=plugin.plugin_name,
            status=_json['status'],
            pid=_json.get("pid", None),
            start_url="/plugins/%s/%d/_s/start" % (
                plugin.plugin_name, plugin.id
            ),
            stop_url="/plugins/%s/%d/_s/stop" % (
                plugin.plugin_name, plugin.id
            ),
            status_url="/plugins/%s/%d/_s/status" % (
                plugin.plugin_name, plugin.id
            ),
            jail_status=jail_status,
        )

        plugin.update_available = availablePlugins.get_update_status(plugin.id)

    return render(request, "plugins/plugins.html", {
        'plugins': plugins,
    })
Exemplo n.º 4
0
def plugins(request):

    Service = namedtuple('Service', [
        'name',
        'status',
        'pid',
        'start_url',
        'stop_url',
        'status_url',
        'jail_status',
    ])

    host = get_base_url(request)
    plugins = models.Plugins.objects.filter(plugin_enabled=True)
    args = map(lambda y: (y, host, request), plugins)

    pool = eventlet.GreenPool(20)
    for plugin, _json, jail_status in pool.imap(get_plugin_status, args):
        if not _json:
            _json = {}
            _json['status'] = None

        plugin.service = Service(
            name=plugin.plugin_name,
            status=_json['status'],
            pid=_json.get("pid", None),
            start_url="/plugins/%s/%d/_s/start" %
            (plugin.plugin_name, plugin.id),
            stop_url="/plugins/%s/%d/_s/stop" %
            (plugin.plugin_name, plugin.id),
            status_url="/plugins/%s/%d/_s/status" %
            (plugin.plugin_name, plugin.id),
            jail_status=jail_status,
        )

        plugin.update_available = availablePlugins.get_update_status(plugin.id)

    return render(request, "plugins/plugins.html", {
        'plugins': plugins,
    })