aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/tools/mpm_shell.py
diff options
context:
space:
mode:
authorDerek Kozel <derek.kozel@ettus.com>2018-01-24 12:54:55 +0000
committerMartin Braun <martin.braun@ettus.com>2018-01-24 10:32:30 -0800
commitf764f5ea6d19c3f26cbc00f1096b1dfcb77f359c (patch)
treeebf8c5a8cd96bec4f52e8a0bb99385ccd5d095d0 /mpm/tools/mpm_shell.py
parent4c81ed0a5dd01e65db560b9ed0db14407d14ce3e (diff)
downloaduhd-f764f5ea6d19c3f26cbc00f1096b1dfcb77f359c.tar.gz
uhd-f764f5ea6d19c3f26cbc00f1096b1dfcb77f359c.tar.bz2
uhd-f764f5ea6d19c3f26cbc00f1096b1dfcb77f359c.zip
mpm: Changed mpm_shell to support scripted use
Diffstat (limited to 'mpm/tools/mpm_shell.py')
-rwxr-xr-xmpm/tools/mpm_shell.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/mpm/tools/mpm_shell.py b/mpm/tools/mpm_shell.py
index 405cb3710..d17fb5c61 100755
--- a/mpm/tools/mpm_shell.py
+++ b/mpm/tools/mpm_shell.py
@@ -122,22 +122,21 @@ class MPMShell(cmd.Cmd):
"""
RPC Shell class. See cmd module.
"""
- def __init__(self):
+ def __init__(self, host, port, claim, hijack):
cmd.Cmd.__init__(self)
self.prompt = "> "
self.client = None
self.remote_methods = []
self._claimer = None
- self._host = None
- self._port = None
+ self._host = host
+ self._port = port
self._device_info = None
- args = parse_args()
- if args.host is not None:
- self.connect(args.host, args.port)
- if args.claim:
+ if host is not None:
+ self.connect(host, port)
+ if claim:
self.claim()
- elif args.hijack:
- self.hijack(args.hijack)
+ elif hijack:
+ self.hijack(hijack)
self.update_prompt()
def _add_command(self, command, docs, requires_token=False):
@@ -180,10 +179,11 @@ class MPMShell(cmd.Cmd):
if isinstance(response, bool):
if response:
print("Command executed successfully!")
- return
- print("Command failed!")
- return
- print("==> " + str(response))
+ else:
+ print("Command failed!")
+ else:
+ print("==> " + str(response))
+ return response
def get_names(self):
" We need this for tab completion. "
@@ -384,7 +384,9 @@ class MPMShell(cmd.Cmd):
def main():
" Go, go, go! "
- my_shell = MPMShell()
+ args = parse_args()
+ my_shell = MPMShell(args.host, args.port, args.claim, args.hijack)
+
try:
return my_shell.run()
except KeyboardInterrupt: