[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/master] Select graph stats by name in the config



commit 5303010a3d7c86d0663bb4da3df233fd425b8e81
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Oct 26 14:36:57 2014 -0700

    Select graph stats by name in the config
    
    No reason to make the user provide an int for this. They have names.
---
 arm/graph_panel.py |   17 +++++++----------
 armrc.sample       |    4 ++--
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arm/graph_panel.py b/arm/graph_panel.py
index f0a1ee7..5b2beb6 100644
--- a/arm/graph_panel.py
+++ b/arm/graph_panel.py
@@ -33,10 +33,6 @@ from stem.util import conf, enum, log, str_tools, system
 
 GraphStat = enum.Enum(('BANDWIDTH', 'bandwidth'), ('CONNECTIONS', 'connections'), ('SYSTEM_RESOURCES', 'resources'))
 
-# maps 'features.graph.type' config values to the initial types
-
-GRAPH_INIT_STATS = {1: GraphStat.BANDWIDTH, 2: GraphStat.CONNECTIONS, 3: GraphStat.SYSTEM_RESOURCES}
-
 DEFAULT_CONTENT_HEIGHT = 4  # space needed for labeling above and below the graph
 PRIMARY_COLOR, SECONDARY_COLOR = 'green', 'cyan'
 MIN_GRAPH_HEIGHT = 1
@@ -75,7 +71,7 @@ CONFIG = conf.config_dict('arm', {
   'features.graph.bound': 1,
   'features.graph.max_width': 150,
   'features.graph.showIntermediateBounds': True,
-  'features.graph.type': 1,
+  'features.graph.type': 'bandwidth',
   'features.panels.show.connection': True,
   'features.graph.bw.prepopulate': True,
   'features.graph.bw.transferInBytes': False,
@@ -382,11 +378,12 @@ class GraphPanel(panel.Panel):
     self.set_pause_attr('stats')
     self.set_pause_attr('_accounting_stats')
 
-    try:
-      initial_stats = GRAPH_INIT_STATS.get(CONFIG['features.graph.type'])
-      self.set_stats(initial_stats)
-    except ValueError:
-      pass  # invalid stats, maybe connections when lookups are disabled
+    if CONFIG['features.graph.type'] == 'none':
+      self.set_stats(None)
+    elif CONFIG['features.graph.type'] in GraphStat:
+      self.set_stats(CONFIG['features.graph.type'])
+    else:
+      log.warn("'%s' isn't a graph type." % CONFIG['features.graph.type'])
 
     # prepopulates bandwidth values from state file
 
diff --git a/armrc.sample b/armrc.sample
index 40025be..c878bee 100644
--- a/armrc.sample
+++ b/armrc.sample
@@ -158,7 +158,7 @@ features.config.descriptions.persist true
 # bound
 #   0 -> global maxima, 1 -> local maxima,  2 -> tight
 # type
-#   0 -> None, 1 -> Bandwidth, 2 -> Connections, 3 -> System Resources
+#   none, bandwidth, connections, resources
 # showIntermediateBounds
 #   shows y-axis increments between the top/bottom bounds
 
@@ -166,7 +166,7 @@ features.graph.height 7
 features.graph.maxWidth 150
 features.graph.interval each second
 features.graph.bound 1
-features.graph.type 1
+features.graph.type bandwidth
 features.graph.showIntermediateBounds true
 
 # Parameters for graphing bandwidth stats



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits