[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Provide a nice error if accounting isn't enabled
commit 1fd1e38afd6c84ce2cc69d0fd9c6fd14e6e4db80
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Sep 14 14:47:12 2014 -0700
Provide a nice error if accounting isn't enabled
Check if accounting is abled when we first call get_accounting_stats() so we
can provide a nicer error if it isn't.
---
stem/control.py | 3 +++
test/unit/control/controller.py | 1 +
2 files changed, 4 insertions(+)
diff --git a/stem/control.py b/stem/control.py
index 57e4550..04098c0 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -1228,6 +1228,9 @@ class Controller(BaseController):
"""
try:
+ if self.get_info('accounting/enabled') != '1':
+ raise stem.ControllerError("Accounting isn't enabled")
+
retrieved = time.time()
status = self.get_info('accounting/hibernating')
interval_end = self.get_info('accounting/interval-end')
diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py
index 4e04f9d..7c7911e 100644
--- a/test/unit/control/controller.py
+++ b/test/unit/control/controller.py
@@ -288,6 +288,7 @@ class TestControl(unittest.TestCase):
"""
get_info_mock.side_effect = lambda param, **kwargs: {
+ 'accounting/enabled': '1',
'accounting/hibernating': 'awake',
'accounting/interval-end': '2014-09-14 19:41:00',
'accounting/bytes': '4837 2050',
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits