Adding a way to query all of the polling periods
authorEd Page <eopage@byu.net>
Sat, 30 Jan 2010 04:47:57 +0000 (22:47 -0600)
committerEd Page <eopage@byu.net>
Sat, 30 Jan 2010 04:47:57 +0000 (22:47 -0600)
src/channel/debug_prompt.py
src/gvoice/state_machine.py

index af04bf9..72091d0 100644 (file)
@@ -220,3 +220,20 @@ class DebugPromptChannel(tp.ChannelTypeText, cmd.Cmd):
 
        def help_version(self):
                self._report_new_message("Prints the version (hint: %s-%s)" % (constants.__version__, constants.__build__))
 
        def help_version(self):
                self._report_new_message("Prints the version (hint: %s-%s)" % (constants.__version__, constants.__build__))
+
+       def do_get_polling(self, args):
+               if args:
+                       self._report_new_message("No arguments supported")
+                       return
+               self._report_new_message("\n".join((
+                       "Contacts:", repr(self._conn.session.addressbookStateMachine)
+               )))
+               self._report_new_message("\n".join((
+                       "Voicemail:", repr(self._conn.session.voicemailsStateMachine)
+               )))
+               self._report_new_message("\n".join((
+                       "Texts:", repr(self._conn.session.textsStateMachine)
+               )))
+
+       def help_get_polling(self):
+               self._report_new_message("Prints the frequency each of the state machines updates")
index ba7ce8b..6eb6af8 100644 (file)
@@ -51,6 +51,9 @@ class NopStateStrategy(object):
        def timeout(self):
                return UpdateStateMachine.INFINITE_PERIOD
 
        def timeout(self):
                return UpdateStateMachine.INFINITE_PERIOD
 
+       def __repr__(self):
+               return "NopStateStrategy()"
+
 
 class ConstantStateStrategy(object):
 
 
 class ConstantStateStrategy(object):
 
@@ -68,6 +71,9 @@ class ConstantStateStrategy(object):
        def timeout(self):
                return self._timeout
 
        def timeout(self):
                return self._timeout
 
+       def __repr__(self):
+               return "ConstantStateStrategy(timeout=%r)" % self._timeout
+
 
 class GeometricStateStrategy(object):
 
 
 class GeometricStateStrategy(object):
 
@@ -94,6 +100,11 @@ class GeometricStateStrategy(object):
                timeout = self._init + self._current
                return timeout
 
                timeout = self._init + self._current
                return timeout
 
+       def __repr__(self):
+               return "GeometricStateStrategy(init=%r, min=%r, max=%r)" % (
+                       self._init, self._min, self._max
+               )
+
 
 class StateMachine(object):
 
 
 class StateMachine(object):
 
@@ -175,6 +186,12 @@ class UpdateStateMachine(StateMachine):
                        )
                )
 
                        )
                )
 
+       def __repr__(self):
+               return """UpdateStateMachine(
+       name=%r,
+       strategie=%r,
+)""" % (self._name, self._strategies)
+
        def set_state_strategy(self, state, strategy):
                self._strategies[state] = strategy
 
        def set_state_strategy(self, state, strategy):
                self._strategies[state] = strategy