summaryrefslogtreecommitdiffstats
path: root/scripts/automation/regression/misc_methods.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-03-09 11:04:08 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-03-09 11:04:08 +0200
commit3f747bcf1d6cb5654bbd0b0e54fa56bc7ad90e69 (patch)
tree6e22c8b384699666535f23e7cb21d9e74b9be2f5 /scripts/automation/regression/misc_methods.py
parent344df4618f219758a6fd005e2ea3e3d1056b5f4b (diff)
regression: stl updates
Diffstat (limited to 'scripts/automation/regression/misc_methods.py')
-rwxr-xr-xscripts/automation/regression/misc_methods.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/scripts/automation/regression/misc_methods.py b/scripts/automation/regression/misc_methods.py
index b5cf79e0..6830be01 100755
--- a/scripts/automation/regression/misc_methods.py
+++ b/scripts/automation/regression/misc_methods.py
@@ -20,22 +20,28 @@ def mix_string (str):
return str.replace(' ', '_').lower()
# executes given command, returns tuple (return_code, stdout, stderr)
-def run_command(cmd):
- print 'Running command:', cmd
- proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- if stdout:
- print 'Stdout:\n%s' % stdout
- if proc.returncode:
- if stderr:
- print 'Stderr:\n%s' % stderr
- print 'Return code: %s' % proc.returncode
- return (proc.returncode, stdout, stderr)
-
-
-def run_remote_command(host, command_string):
+def run_command(cmd, background = False):
+ if background:
+ print 'Running command in background:', cmd
+ with open(os.devnull, 'w') as tempf:
+ subprocess.Popen(shlex.split(cmd), stdin=tempf, stdout=tempf, stderr=tempf)
+ return (None,)*3
+ else:
+ print 'Running command:', cmd
+ proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ (stdout, stderr) = proc.communicate()
+ if stdout:
+ print 'Stdout:\n%s' % stdout
+ if proc.returncode:
+ if stderr:
+ print 'Stderr:\n%s' % stderr
+ print 'Return code: %s' % proc.returncode
+ return (proc.returncode, stdout, stderr)
+
+
+def run_remote_command(host, command_string, background = False):
cmd = 'ssh -tt %s \'sudo sh -c "%s"\'' % (host, command_string)
- return run_command(cmd)
+ return run_command(cmd, background)
def generate_intf_lists (interfacesList):