[or-cvs] r22583: {arm} Adding optional 15 minute graphing interval and stub in case (arm/trunk/interface/graphing)

Damian Johnson atagar1 at gmail.com
Fri Jul 2 15:32:44 UTC 2010


Author: atagar
Date: 2010-07-02 15:32:44 +0000 (Fri, 02 Jul 2010)
New Revision: 22583

Modified:
   arm/trunk/interface/graphing/bandwidthStats.py
   arm/trunk/interface/graphing/graphPanel.py
Log:
Adding optional 15 minute graphing interval and stub in case prepopulating from the state file actually works out (still not sure if it'll be viable).



Modified: arm/trunk/interface/graphing/bandwidthStats.py
===================================================================
--- arm/trunk/interface/graphing/bandwidthStats.py	2010-07-02 01:42:00 UTC (rev 22582)
+++ arm/trunk/interface/graphing/bandwidthStats.py	2010-07-02 15:32:44 UTC (rev 22583)
@@ -52,6 +52,31 @@
     if self._config["features.graph.bw.accounting.show"]:
       self.isAccounting = conn.getInfo('accounting/enabled') == '1'
   
+  # TODO: Currently this function is unused and pending responses on #tor-dev
+  # to figure out if the feature's even viable. If not, scrape.
+  def prepopulateFromState(self):
+    """
+    Attempts to use tor's state file to prepopulate values for the 15 minute
+    interval via the BWHistoryReadValues/BWHistoryWriteValues values. This
+    returns True if successful and False otherwise.
+    """
+    
+    
+    # get the user's data directory (usually '~/.tor')
+    dataDir = conn.getOption("DataDirectory")
+    if not dataDir: return False
+    
+    # attempt to open the state file
+    try: stateFile = open("%s/state" % dataDir, "r")
+    except IOError: return False
+    
+    # find the BWHistory lines (might not exist yet for new relays)
+    bwReadLine, bwWriteLine = None, None
+    
+    for line in stateFile:
+      if line.startswith("BWHistoryReadValues"): bwReadLine = line
+      elif line.startswith("BWHistoryWriteValues"): bwWriteLine = line
+  
   def bandwidth_event(self, event):
     if self.isAccounting and self.isNextTickRedraw():
       if time.time() - self.accountingLastUpdated >= self._config["features.graph.bw.accounting.rate"]:

Modified: arm/trunk/interface/graphing/graphPanel.py
===================================================================
--- arm/trunk/interface/graphing/graphPanel.py	2010-07-02 01:42:00 UTC (rev 22582)
+++ arm/trunk/interface/graphing/graphPanel.py	2010-07-02 15:32:44 UTC (rev 22583)
@@ -23,8 +23,9 @@
 from util import panel, uiTools
 
 # time intervals at which graphs can be updated
-UPDATE_INTERVALS = [("each second", 1),     ("5 seconds", 5),   ("30 seconds", 30),   ("minutely", 60),
-                    ("half hour", 1800),    ("hourly", 3600),   ("daily", 86400)]
+UPDATE_INTERVALS = [("each second", 1), ("5 seconds", 5),   ("30 seconds", 30),
+                    ("minutely", 60),   ("15 minute", 900), ("30 minute", 1800),
+                    ("hourly", 3600),   ("daily", 86400)]
 
 DEFAULT_HEIGHT = 10 # space needed for graph and content
 DEFAULT_COLOR_PRIMARY, DEFAULT_COLOR_SECONDARY = "green", "cyan"



More information about the tor-commits mailing list