From f0c65478b4f85372db4c72b4613dc3e4d0a81e4f Mon Sep 17 00:00:00 2001 From: Sean Lane <5761232+seanlane@users.noreply.github.com> Date: Wed, 31 Jan 2018 10:20:37 -0700 Subject: [PATCH 1/3] Update apm.py Add option to not print output from APM cmd. In a perfect world, I think it might be best to adjust the return value of method to return a tuple of `(response, output)` so the caller can do what they will with the output, or something similar, but that will likely cause a fair amount of refactoring. This change should keep the default behavior while allowing to opt out from printing input, for example when running APM from Gekko. I haven't spent an inordinate amount of time thinking over this change, so feedback is certainly welcome :) --- apm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apm.py b/apm.py index 718098c..958b46f 100644 --- a/apm.py +++ b/apm.py @@ -20,7 +20,7 @@ if ver==2: # Python 2 - def cmd(server, app, aline): + def cmd(server, app, aline, disp=True): '''Send a request to the server \n \ server = address of server \n \ app = application name \n \ @@ -40,7 +40,8 @@ def cmd(server, app, aline): if not char: break elif char == '\n': - print(line) + if disp: + print(line) line = '' else: line += char From 0f9af9ca8c92b61838ee6045720d5326b96777a8 Mon Sep 17 00:00:00 2001 From: Sean Lane <5761232+seanlane@users.noreply.github.com> Date: Wed, 31 Jan 2018 10:23:25 -0700 Subject: [PATCH 2/3] Update apm.py Add same change to Python 3 branch --- apm.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apm.py b/apm.py index 958b46f..077fdbd 100644 --- a/apm.py +++ b/apm.py @@ -309,11 +309,12 @@ def load_meas(server,app,name,value): else: # Python 3+ - def cmd(server,app,aline): + def cmd(server,app,aline, disp=True): '''Send a request to the server \n \ server = address of server \n \ app = application name \n \ - aline = line to send to server \n''' + aline = line to send to server \n \ + disp = Print output \n''' try: # Web-server URL address url_base = server.strip() + '/online/apm_line.php' @@ -331,7 +332,8 @@ def cmd(server,app,aline): if not char: break elif char == '\n': - print(line) + if disp: + print(line) line = '' else: line += char From 4b722ef50e6dbe4c48e09304f47cc5eb22d28343 Mon Sep 17 00:00:00 2001 From: Sean Lane <5761232+seanlane@users.noreply.github.com> Date: Wed, 31 Jan 2018 10:24:40 -0700 Subject: [PATCH 3/3] Update apm.py Add comment to Python 2 branch as well --- apm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apm.py b/apm.py index 077fdbd..24b3864 100644 --- a/apm.py +++ b/apm.py @@ -24,7 +24,8 @@ def cmd(server, app, aline, disp=True): '''Send a request to the server \n \ server = address of server \n \ app = application name \n \ - aline = line to send to server \n''' + aline = line to send to server \n \ + disp = Print output \n''' try: # Web-server URL address url_base = string.strip(server) + '/online/apm_line.php'