Skip to content

Commit 5a814fd

Browse files
committed
Removing the Matplotlib dependency.
A parser for Yum repo lists. Small locking improvements.
1 parent 46b0226 commit 5a814fd

File tree

18 files changed

+508
-340
lines changed

18 files changed

+508
-340
lines changed

grr/gui/admin_ui.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# pylint: disable=unused-import,g-bad-import-order
1414
from grr.gui import django_lib
1515
from grr.lib import server_plugins
16-
from grr.gui import plot_lib
1716
# pylint: enable=unused-import,g-bad-import-order
1817

1918
from grr.lib import config_lib

grr/gui/plot_lib.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

grr/gui/plugins/flow_management.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
"""GUI elements allowing launching and management of flows."""
33

44
import os
5-
import StringIO
65

76

8-
from grr.gui import plot_lib
97
from grr.gui import renderers
108
from grr.gui.plugins import crash_view
119
from grr.gui.plugins import fileview
@@ -837,46 +835,6 @@ def Layout(self, request, response):
837835
super(ClientCrashesRenderer, self).Layout(request, response)
838836

839837

840-
class ProgressGraphRenderer(renderers.ImageDownloadRenderer):
841-
842-
def Content(self, request, _):
843-
"""Generates the actual image to display."""
844-
flow_id = request.REQ.get("flow_id")
845-
flow_obj = aff4.FACTORY.Open(flow_id, age=aff4.ALL_TIMES,
846-
token=request.token)
847-
848-
log = list(flow_obj.GetValuesForAttribute(flow_obj.Schema.LOG))
849-
850-
create_time = flow_obj.state.context.create_time / 1000000
851-
852-
plot_data = [(int(x.age) / 1000000, int(str(x).split(" ")[1]))
853-
for x in log if "bytes" in str(x)]
854-
plot_data.append((create_time, 0))
855-
856-
plot_data = sorted([(x - create_time, y) for (x, y) in plot_data])
857-
858-
x = [a for (a, b) in plot_data]
859-
y = [b for (a, b) in plot_data]
860-
861-
params = {"backend": "png"}
862-
863-
plot_lib.plt.rcParams.update(params)
864-
plot_lib.plt.figure(1)
865-
plot_lib.plt.clf()
866-
867-
plot_lib.plt.plot(x, y)
868-
plot_lib.plt.title("Progress for flow %s" % flow_id)
869-
plot_lib.plt.xlabel("Time (s)")
870-
plot_lib.plt.ylabel("Bytes downloaded")
871-
plot_lib.plt.grid(True)
872-
873-
buf = StringIO.StringIO()
874-
plot_lib.plt.savefig(buf)
875-
buf.seek(0)
876-
877-
return buf.read()
878-
879-
880838
class GlobalLaunchFlows(renderers.AngularDirectiveRenderer):
881839
"""Launches flows that apply across clients."""
882840
description = "Start Global Flows"

grr/gui/plugins/hunt_view.py

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55

66

77
import collections as py_collections
8-
import StringIO
98
import urllib
109

1110

1211
import logging
1312

14-
from grr.gui import plot_lib
1513
from grr.gui import renderers
1614
from grr.gui.plugins import fileview
1715
from grr.gui.plugins import foreman
@@ -637,85 +635,6 @@ def Layout(self, request, response):
637635
hunt_id=self.hunt_id)
638636

639637

640-
class HuntClientCompletionGraphRenderer(renderers.ImageDownloadRenderer):
641-
642-
def Content(self, request, _):
643-
"""Generates the actual image to display."""
644-
hunt_id = request.REQ.get("hunt_id")
645-
hunt = aff4.FACTORY.Open(hunt_id, aff4_type="GRRHunt", token=request.token)
646-
clients_by_status = hunt.GetClientsByStatus()
647-
648-
cl = clients_by_status["STARTED"]
649-
fi = clients_by_status["COMPLETED"]
650-
651-
cdict = {}
652-
for c in cl:
653-
cdict.setdefault(c, []).append(c.age)
654-
655-
fdict = {}
656-
for c in fi:
657-
fdict.setdefault(c, []).append(c.age)
658-
659-
cl_age = [int(min(x) / 1e6) for x in cdict.values()]
660-
fi_age = [int(min(x) / 1e6) for x in fdict.values()]
661-
662-
cl_hist = {}
663-
fi_hist = {}
664-
665-
for age in cl_age:
666-
cl_hist.setdefault(age, 0)
667-
cl_hist[age] += 1
668-
669-
for age in fi_age:
670-
fi_hist.setdefault(age, 0)
671-
fi_hist[age] += 1
672-
673-
t0 = min(cl_age) - 1
674-
times = [t0]
675-
cl = [0]
676-
fi = [0]
677-
678-
all_times = set(cl_age) | set(fi_age)
679-
cl_count = 0
680-
fi_count = 0
681-
682-
for time in sorted(all_times):
683-
# Check if there is a datapoint one second earlier, add one if not.
684-
if times[-1] != time - 1:
685-
times.append(time)
686-
cl.append(cl_count)
687-
fi.append(fi_count)
688-
689-
cl_count += cl_hist.get(time, 0)
690-
fi_count += fi_hist.get(time, 0)
691-
692-
times.append(time)
693-
cl.append(cl_count)
694-
fi.append(fi_count)
695-
696-
# Convert to hours, starting from 0.
697-
times = [(t - t0) / 3600.0 for t in times]
698-
699-
params = {"backend": "png"}
700-
701-
plot_lib.plt.rcParams.update(params)
702-
plot_lib.plt.figure(1)
703-
plot_lib.plt.clf()
704-
705-
plot_lib.plt.plot(times, cl, label="Agents issued.")
706-
plot_lib.plt.plot(times, fi, label="Agents completed.")
707-
plot_lib.plt.title("Agent Coverage")
708-
plot_lib.plt.xlabel("Time (h)")
709-
plot_lib.plt.ylabel(r"Agents")
710-
plot_lib.plt.grid(True)
711-
plot_lib.plt.legend(loc=4)
712-
buf = StringIO.StringIO()
713-
plot_lib.plt.savefig(buf)
714-
buf.seek(0)
715-
716-
return buf.read()
717-
718-
719638
class HuntHostInformationRenderer(fileview.AFF4Stats):
720639
"""Modified HostInformation that reads from hunt_client variable."""
721640

grr/gui/plugins/semantic.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -529,26 +529,6 @@ def Layout(self, request, response, aff4_path=None):
529529
request, response)
530530

531531

532-
class ProgressButtonRenderer(RDFValueRenderer):
533-
"""Renders a button that shows a progress graph."""
534-
535-
# This specifies the name of the RDFValue object we will render.
536-
classname = "ProgressGraph"
537-
538-
layout_template = renderers.Template("""
539-
Open a graph showing the download progress in a new window:
540-
<button id="{{ unique|escape }}">
541-
Generate
542-
</button>
543-
""")
544-
545-
def Layout(self, request, response):
546-
self.flow_id = request.REQ.get("flow")
547-
response = super(ProgressButtonRenderer, self).Layout(request, response)
548-
return self.CallJavascript(response, "ProgressButtonRenderer.Layout",
549-
flow_id=self.flow_id)
550-
551-
552532
class FlowStateRenderer(DictRenderer):
553533
"""A Flow state is similar to a dict."""
554534
classname = "FlowState"

grr/gui/static/javascript/plugins/semantic.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,6 @@ grr.Renderer('RDFValueArrayRenderer', {
5252
});
5353

5454

55-
grr.Renderer('ProgressButtonRenderer', {
56-
Layout: function(state) {
57-
var unique = state.unique;
58-
var flow_id = state.flow_id;
59-
60-
var button = $('#' + unique).button();
61-
grr.downloadHandler(button, {flow_id: flow_id}, false,
62-
'/render/Download/ProgressGraphRenderer');
63-
}
64-
});
65-
66-
6755
grr.Renderer('AES128KeyFormRenderer', {
6856
Layout: function(state) {
6957
var prefix = state.prefix;

0 commit comments

Comments
 (0)