Change in ...osmo-python-tests[master]: Add osmo_interact_exec.py

2019-08-26 Thread osmith
osmith has abandoned this change. ( 
https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15273 )

Change subject: Add osmo_interact_exec.py
..


Abandoned
--
To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15273
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Change-Id: If38243171c94d8ce9d6cdc269da59c9ebc9942bb
Gerrit-Change-Number: 15273
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-MessageType: abandon


Change in ...osmo-python-tests[master]: Add osmo_interact_exec.py

2019-08-23 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15273 )

Change subject: Add osmo_interact_exec.py
..


Patch Set 1: Code-Review-2

This one was pushed by error by myself, probably needs to be abandonned.


--
To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15273
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Change-Id: If38243171c94d8ce9d6cdc269da59c9ebc9942bb
Gerrit-Change-Number: 15273
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Fri, 23 Aug 2019 13:55:27 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in ...osmo-python-tests[master]: Add osmo_interact_exec.py

2019-08-23 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15273 )

Change subject: Add osmo_interact_exec.py
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15273
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Change-Id: If38243171c94d8ce9d6cdc269da59c9ebc9942bb
Gerrit-Change-Number: 15273
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith 
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Fri, 23 Aug 2019 13:55:07 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in ...osmo-python-tests[master]: Add osmo_interact_exec.py

2019-08-23 Thread pespin
Hello osmith,

I'd like you to do a code review. Please visit

https://gerrit.osmocom.org/c/python/osmo-python-tests/+/15273

to review the following change.


Change subject: Add osmo_interact_exec.py
..

Add osmo_interact_exec.py

Change-Id: If38243171c94d8ce9d6cdc269da59c9ebc9942bb
---
M osmopy/osmo_interact/common.py
A osmopy/osmo_interact/exec.py
A scripts/osmo_interact_exec.py
3 files changed, 132 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/73/15273/1

diff --git a/osmopy/osmo_interact/common.py b/osmopy/osmo_interact/common.py
index 39163a2..bc2b461 100644
--- a/osmopy/osmo_interact/common.py
+++ b/osmopy/osmo_interact/common.py
@@ -374,7 +374,7 @@

 return passed

-def common_parser(doc=None):
+def common_parser(doc=None, host=True):
 parser = argparse.ArgumentParser(description=doc,
  
formatter_class=argparse.RawDescriptionHelpFormatter)
 parser.add_argument('-r', '--run', dest='run_app_str',
@@ -383,8 +383,9 @@
 ' application is launched.')
 parser.add_argument('-p', '--port', dest='port',
 help="Port to reach the application at.")
-parser.add_argument('-H', '--host', dest='host', default='localhost',
-help="Host to reach the application at.")
+if host:
+parser.add_argument('-H', '--host', dest='host', default='localhost',
+help="Host to reach the application at.")
 return parser

 def parser_add_verify_args(parser):
@@ -397,17 +398,30 @@
 parser.add_argument('transcript_files', nargs='*', help='transcript 
file(s) to verify')
 return parser

-def parser_add_run_args(parser):
+def parser_add_run_args(parser, cmd_files=True):
 parser.add_argument('-O', '--output', dest='output_path',
 help="Write command results to a file instead of 
stdout."
 "('-O -' writes to stdout and is the default)")
 parser.add_argument('-c', '--command', dest='cmd_str',
 help="Run this command (before reading input files, if 
any)."
 " multiple commands may be separated by ';'")
-parser.add_argument('cmd_files', nargs='*', help='file(s) with plain 
commands to run')
+if cmd_files:
+parser.add_argument('cmd_files', nargs='*', help='file(s) with plain 
commands to run')
 return parser

-def main_run_commands(run_app_str, output_path, cmd_str, cmd_files, interact):
+def parser_require_args(parser, dests):
+for dest in dests:
+found = False
+for action in parser._actions:
+if action.dest == dest:
+action.required = True
+found = True
+break
+if not found:
+raise RuntimeError("Could not find argument with dest: " + dest)
+
+def main_run_commands(run_app_str, output_path, cmd_str, cmd_files, interact,
+  purge_output=True):
 to_stdout = False
 if not output_path or output_path == '-':
 to_stdout = True
@@ -418,7 +432,7 @@
 application = None

 if run_app_str:
-application = Application(run_app_str, quiet=to_stdout)
+application = Application(run_app_str, quiet=to_stdout, 
purge_output=purge_output)
 application.run()

 try:
diff --git a/osmopy/osmo_interact/exec.py b/osmopy/osmo_interact/exec.py
new file mode 100644
index 000..c2f2f08
--- /dev/null
+++ b/osmopy/osmo_interact/exec.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python3
+#
+# (C) 2019 by sysmocom s.f.m.c. GmbH 
+# All rights reserved.
+#
+# Author: Oliver Smith 
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+'''
+Wait until a given application listens for TCP connections, then run C tests or
+other programs against it.
+'''
+
+import subprocess
+from .common import *
+
+class InteractExec(Interact):
+def __init__(self, port, verbose=False, update=False):
+super().__init__(Interact.StepBase, host="localhost", port=port,
+ verbose=verbose, update=update)
+
+def command(self, command):
+print("Launching: " + command)
+
+try:
+# Do not allow commands with