[tor-commits] [arm/master] Replacing start_time attribute with config property

atagar at torproject.org atagar at torproject.org
Mon Oct 21 21:10:15 UTC 2013


commit d9bbfcf88165f8b01253ae00197494a5abc01bf0
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Oct 18 11:09:12 2013 -0700

    Replacing start_time attribute with config property
    
    I dislike plumbing our startup time through three functions. Might as well make
    it a config attribute - we might want it elsewhere anyway.
---
 arm/controller.py |   11 +++++------
 arm/starter.py    |    4 ++--
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arm/controller.py b/arm/controller.py
index 680fcf8..8fc198b 100644
--- a/arm/controller.py
+++ b/arm/controller.py
@@ -48,6 +48,7 @@ CONFIG = conf.config_dict("arm", {
   "features.confirmQuit": True,
   "features.graph.type": 1,
   "features.graph.bw.prepopulate": True,
+  "attribute.start_time": 0,
 }, conf_handler)
 
 GraphStat = enum.Enum("BANDWIDTH", "CONNECTIONS", "SYSTEM_RESOURCES")
@@ -512,11 +513,9 @@ def connResetListener(controller, eventType, _):
       except ValueError:
         pass
 
-def start_arm(start_time):
+def start_arm():
   """
   Initializes the interface and starts the main draw loop.
-
-  :param float start_time: unix timestamp for when arm was started
   """
 
   if CONFIG["features.panels.show.connection"]:
@@ -554,7 +553,7 @@ def start_arm(start_time):
         connections.get_resolver().set_paused(not controller.is_alive())
 
   try:
-    curses.wrapper(drawTorMonitor, start_time)
+    curses.wrapper(drawTorMonitor)
   except UnboundLocalError as exc:
     if os.environ['TERM'] != 'xterm':
       shutdownDaemons()
@@ -573,15 +572,15 @@ def start_arm(start_time):
     panel.HALT_ACTIVITY = True
     shutdownDaemons()
 
-def drawTorMonitor(stdscr, startTime):
+def drawTorMonitor(stdscr):
   """
   Main draw loop context.
 
   Arguments:
     stdscr    - curses window
-    startTime - unix time for when arm was started
   """
 
+  startTime = CONFIG['attribute.start_time']
   initController(stdscr, startTime)
   control = getController()
 
diff --git a/arm/starter.py b/arm/starter.py
index 501c582..435ae95 100644
--- a/arm/starter.py
+++ b/arm/starter.py
@@ -259,8 +259,8 @@ def _armrc_dump(armrc_path):
 
 
 def main():
-  start_time = time.time()
   config = stem.util.conf.get_config("arm")
+  config.set('attribute.start_time', str(int(time.time())))
 
   try:
     _load_settings()
@@ -396,7 +396,7 @@ def main():
     plural_label = "s" if len(missing_event_types) > 1 else ""
     stem.util.log.info("arm doesn't recognize the following event type%s: %s (log 'UNKNOWN' events to see them)" % (plural_label, ", ".join(missing_event_types)))
 
-  arm.controller.start_arm(start_time)
+  arm.controller.start_arm()
 
 if __name__ == '__main__':
   main()





More information about the tor-commits mailing list