Make Session.execute_cmd consistent with Account/Object by accepting the session keyword

This commit is contained in:
Griatch 2018-10-10 23:26:20 +02:00
parent 52c84b44b5
commit 5f9047b161

View file

@ -407,7 +407,7 @@ class ServerSession(Session):
else: else:
self.data_out(**kwargs) self.data_out(**kwargs)
def execute_cmd(self, raw_string, **kwargs): def execute_cmd(self, raw_string, session=None, **kwargs):
""" """
Do something as this object. This method is normally never Do something as this object. This method is normally never
called directly, instead incoming command instructions are called directly, instead incoming command instructions are
@ -417,6 +417,9 @@ class ServerSession(Session):
Args: Args:
raw_string (string): Raw command input raw_string (string): Raw command input
session (Session): This is here to make API consistent with
Account/Object.execute_cmd. If given, data is passed to
that Session, otherwise use self.
Kwargs: Kwargs:
Other keyword arguments will be added to the found command Other keyword arguments will be added to the found command
object instace as variables before it executes. This is object instace as variables before it executes. This is
@ -426,7 +429,7 @@ class ServerSession(Session):
""" """
# inject instruction into input stream # inject instruction into input stream
kwargs["text"] = ((raw_string,), {}) kwargs["text"] = ((raw_string,), {})
self.sessionhandler.data_in(self, **kwargs) self.sessionhandler.data_in(session or self, **kwargs)
def __eq__(self, other): def __eq__(self, other):
"""Handle session comparisons""" """Handle session comparisons"""