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

[tor-commits] [stem/master] Supporting '/events clear'



commit 732ecff7d0aa193178f29b1d62cb3413398d7084
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat May 24 13:31:55 2014 -0700

    Supporting '/events clear'
    
    Adding a command to clear the backlog of events we've received.
---
 stem/interpreter/commands.py  |    7 +++++++
 stem/interpreter/settings.cfg |    3 +++
 2 files changed, 10 insertions(+)

diff --git a/stem/interpreter/commands.py b/stem/interpreter/commands.py
index 28b3e59..0342ba9 100644
--- a/stem/interpreter/commands.py
+++ b/stem/interpreter/commands.py
@@ -126,11 +126,18 @@ class ControlInterpretor(code.InteractiveConsole):
     Performs the '/events' operation, dumping the events that we've received
     belonging to the given types. If no types are specified then this provides
     all buffered events.
+
+    If the user runs '/events clear' then this clears the list of events we've
+    received.
     """
 
     events = self._received_events
     event_types = arg.upper().split()
 
+    if 'CLEAR' in event_types:
+      del self._received_events[:]
+      return format('cleared event backlog', *STANDARD_OUTPUT)
+
     if event_types:
       events = filter(lambda event: event.type in event_types, events)
 
diff --git a/stem/interpreter/settings.cfg b/stem/interpreter/settings.cfg
index 0ddf080..5e85a5e 100644
--- a/stem/interpreter/settings.cfg
+++ b/stem/interpreter/settings.cfg
@@ -130,6 +130,9 @@ help.description.events
 |Provides events that we've received belonging to the given event types. If
 |no types are specified then this provides all the messages that we've
 |received.
+|
+|You can also run '/events clear' to clear the backlog of events we've
+|received.
 
 help.description.info
 |Provides general information for a relay that's currently in the consensus.



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