From e353ea43bef0c509574fec8f2acfffc107a62aa7 Mon Sep 17 00:00:00 2001 From: Stefan Weiher Date: Wed, 31 May 2017 16:19:06 +0200 Subject: [PATCH] Mostly minor layout changes. Implemented error handling with the trend data in wc_getTrend. Expanded the EXAMPLES file by a few examples showing how to use the -s und -e options of wc_getTrend. --- EXAMPLES | 42 ++++++++++++++++++++++++++++++++++++++++-- README | 5 +++-- wc_getReport.py | 3 ++- wc_getTrend.py | 13 +++++++++---- wc_getValue.py | 2 +- wc_query.py | 2 +- 6 files changed, 56 insertions(+), 11 deletions(-) diff --git a/EXAMPLES b/EXAMPLES index 2e01a26..55ae1df 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -79,5 +79,43 @@ End time is undefined. Use -e to define date and time. 05/30/2017 04:27:00 PM 63.783897 05/30/2017 04:28:00 PM 63.783897 - - +### The usage of the date+time options -s and -e are examplified. -l ist not specified, thus, the last ten values are returned: +$ python wc_getTrend.py -u wsdl -n /trees/geographic/#geb_g/#g_luft/#primzuluft_1_2_stm/#g_primzuluft_trend/m006 -s '05/30/2017 03:00:00 AM' -e '05/30/2017 06:00:00 AM' +No password specified via -p. Please enter your WebCTRL login password: +05/30/2017 05:51:00 AM 59.97419 +05/30/2017 05:52:00 AM 59.97419 +05/30/2017 05:53:00 AM 59.97419 +05/30/2017 05:54:00 AM 59.97419 +05/30/2017 05:55:00 AM 59.97419 +05/30/2017 05:56:00 AM 59.97419 +05/30/2017 05:57:00 AM 59.97419 +05/30/2017 05:58:00 AM 59.97419 +05/30/2017 05:59:00 AM 59.97419 +05/30/2017 06:00:00 AM 59.97419 + +### -l is specified, thus, the first ten values starting from the time given in -s are returned: +$ python wc_getTrend.py -u wsdl -n /trees/geographic/#geb_g/#g_luft/#primzuluft_1_2_stm/#g_primzuluft_trend/m006 -s '05/30/2017 03:00:00 AM' -e '05/30/2017 06:00:00 AM' -l +No password specified via -p. Please enter your WebCTRL login password: +05/30/2017 03:01:00 AM 63.87936 +05/30/2017 03:02:00 AM 63.87936 +05/30/2017 03:03:00 AM 63.87936 +05/30/2017 03:04:00 AM 64.26652 +05/30/2017 03:05:00 AM 64.26652 +05/30/2017 03:06:00 AM 64.26652 +05/30/2017 03:07:00 AM 64.26652 +05/30/2017 03:08:00 AM 64.26652 +05/30/2017 03:09:00 AM 64.26652 +05/30/2017 03:10:00 AM 64.26652 + +### Get all values (-m 0) between the times given in -s and -e: +$ python wc_getTrend.py -u wsdl -n /trees/geographic/#geb_g/#g_luft/#primzuluft_1_2_stm/#g_primzuluft_trend/m006 -s '05/30/2017 03:00:00 AM' -e '05/30/2017 04:00:00 AM' -l -m 0 +No password specified via -p. Please enter your WebCTRL login password: +05/30/2017 03:01:00 AM 63.87936 +05/30/2017 03:02:00 AM 63.87936 +05/30/2017 03:03:00 AM 63.87936 +05/30/2017 03:04:00 AM 64.26652 +... +05/30/2017 03:57:00 AM 60.07319 +05/30/2017 03:58:00 AM 60.07319 +05/30/2017 03:59:00 AM 60.07319 +05/30/2017 04:00:00 AM 60.07319 diff --git a/README b/README index be85264..a0b4ace 100644 --- a/README +++ b/README @@ -17,8 +17,9 @@ webctrl$ ./build_project.sh The executables can be found in ./dist/wc_*/wc_* -Add the directory to the PATH environment variable (in your ~/.bashrc in order to be able to execute the wc_* commands -everywhere: PATH=$PATH:$HOME/.../webctrl/dist/wc_query:$HOME/.../webctrl/dist/wc_getValue:... +Add the directory to the PATH environment variable (in your ~/.bashrc) in order to be able to +execute the wc_* commands everywhere: +PATH=$PATH:$HOME/.../webctrl/dist/wc_query:$HOME/.../webctrl/dist/wc_getValue:... Running the tools ----------------- diff --git a/wc_getReport.py b/wc_getReport.py index 3532de3..b4d6ca8 100644 --- a/wc_getReport.py +++ b/wc_getReport.py @@ -11,7 +11,7 @@ parser = argparse.ArgumentParser() -parser.add_argument('--username', '-u', type=str, default=None, help='User name for the login to the WebCTRL server') +parser.add_argument('--username', '-u', type=str, default=None, help='Username for the login to the WebCTRL server') parser.add_argument('--password', '-p', type=str, default=None, help='Password for the login to the WebCTRL server') parser.add_argument('--node', '-n', type=str, default=None, help='Path to the point or node for which you want to retrieve a report.') @@ -98,5 +98,6 @@ c = c + n * '-' + '---' print c + sys.exit(0) diff --git a/wc_getTrend.py b/wc_getTrend.py index bcf1e4e..81dfb98 100644 --- a/wc_getTrend.py +++ b/wc_getTrend.py @@ -10,7 +10,7 @@ parser = argparse.ArgumentParser() -parser.add_argument('--username', '-u', type=str, default=None, help='User name for the login to the WebCTRL server') +parser.add_argument('--username', '-u', type=str, default=None, help='Username for the login to the WebCTRL server') parser.add_argument('--password', '-p', type=str, default=None, help='Password for the login to the WebCTRL server') parser.add_argument('--node', '-n', type=str, default=None, help='The full path to the point or trend log node whose trend data is desired.') @@ -21,7 +21,7 @@ parser.add_argument('--eTime', '-e', type=str, default=None, help="End Time. Returns trend data values until this time. Like this: 'MM/DD/YYYY HH:MM:SS PM'.") parser.add_argument('--limit', '-l', action='store_true', default=False, - help='If specified maxRecords are retrieved from the start or maxRecords are retrieved from the end.') + help='If specified maxRecords are retrieved from the start. If not specified maxRecords are retrieved from the end.') parser.add_argument('--maxRec', '-m', type=int, default=10, help='Maximum number of records desired. Use a number >0 to limit records; use 0 to retrieve unlimited records.') args = parser.parse_args() @@ -68,8 +68,13 @@ print fault sys.exit(1) -for x in range(0, len(trendData)-1, 2): - print trendData[x] + ' ' + trendData[x+1] + +if trendData: + for x in range(0, len(trendData) - 1, 2): + print trendData[x] + ' ' + trendData[x + 1] +else: + print 'No data caught. Check your -s and -e time specifications. Perhaps the end time is before the start time.' + sys.exit(1) sys.exit(0) diff --git a/wc_getValue.py b/wc_getValue.py index d0bcfb1..7290cfb 100644 --- a/wc_getValue.py +++ b/wc_getValue.py @@ -10,7 +10,7 @@ parser = argparse.ArgumentParser() -parser.add_argument('--username', '-u', type=str, default=None, help='User name for the login to the WebCTRL server') +parser.add_argument('--username', '-u', type=str, default=None, help='Username for the login to the WebCTRL server') parser.add_argument('--password', '-p', type=str, default=None, help='Password for the login to the WebCTRL server') parser.add_argument('--node', '-n', type=str, default=None, help='Path to the point or node for which you want to retrieve the present value.') diff --git a/wc_query.py b/wc_query.py index f48cf90..11d9083 100644 --- a/wc_query.py +++ b/wc_query.py @@ -11,7 +11,7 @@ parser = argparse.ArgumentParser() -parser.add_argument('--username', '-u', type=str, default=None, help='User name for the login to the WebCTRL server') +parser.add_argument('--username', '-u', type=str, default=None, help='Username for the login to the WebCTRL server') parser.add_argument('--password', '-p', type=str, default=None, help='Password for the login to the WebCTRL server') parser.add_argument('--node', '-n', type=str, default=None, help='Path to the point or node whose children you want to retrieve. Start querying at the lowest level with "-n /trees/geographic"')