From d276d58aac8fec49cc1a8f532e95e8159fa23b5e Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Mon, 13 Dec 2021 16:29:05 -0500 Subject: [PATCH] 2021-12-13 Fred Gleason * Added a 'LogLock()' type class to the 'rivwebpyapi' API. * Modified the 'rivwebpyapi.LockLog()' call to return a 'rivwebpyapi.LogLock' object. Signed-off-by: Fred Gleason --- ChangeLog | 4 ++++ apis/rivwebpyapi/api/rivwebpyapi.py | 16 ++++++++++++++-- apis/rivwebpyapi/tests/lock_log.py | 12 +++--------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 82e79915..a654847f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22783,3 +22783,7 @@ * Added a 'SystemSettings()' type class to the 'rivwebpyapi' API. * Modified the 'rivwebpyapi.ListSystemSettings()' call to return a 'rivwebpyapi.SystemSettings' object. +2021-12-13 Fred Gleason + * Added a 'LogLock()' type class to the 'rivwebpyapi' API. + * Modified the 'rivwebpyapi.LockLog()' call to return + a 'rivwebpyapi.LogLock' object. diff --git a/apis/rivwebpyapi/api/rivwebpyapi.py b/apis/rivwebpyapi/api/rivwebpyapi.py index 3e67a17b..d6c372da 100755 --- a/apis/rivwebpyapi/api/rivwebpyapi.py +++ b/apis/rivwebpyapi/api/rivwebpyapi.py @@ -233,6 +233,14 @@ LOGLINE_FIELDS={ 'extAnncType': 'string' } +LOG_LOCK_FIELDS={ + 'result': 'boolean', + 'logName': 'string', + 'lockGuid': 'string', + 'address': 'string', + 'lockTimeout': 'integer' +} + SCHEDULER_CODE_FIELDS={ 'code': 'string', 'description': 'string' @@ -455,6 +463,10 @@ class LogLine(RivendellType): def __init__(self,values={}): super().__init__(LOGLINE_FIELDS,values) +class LogLock(RivendellType): + def __init__(self,values={}): + super().__init__(LOG_LOCK_FIELDS,values) + class SchedulerCode(RivendellType): def __init__(self,values={}): super().__init__(SCHEDULER_CODE_FIELDS,values) @@ -1743,7 +1755,7 @@ class rivwebpyapi(object): def LockLog(self,log_name,operation,guid): """ - Manage the lock for the specified log (dictionary). + Manage the lock for the specified log (rivwebpyapi.LogLock object). Takes the following argument: @@ -1795,7 +1807,7 @@ class rivwebpyapi(object): handler=RivWebPyApi_ListHandler(base_tag='logLock',fields=fields) xml.sax.parseString(r.text,handler) - return handler.output()[0] + return LogLock(handler.output()[0]) def PostImage(self,image_id): """ diff --git a/apis/rivwebpyapi/tests/lock_log.py b/apis/rivwebpyapi/tests/lock_log.py index 9326f45a..b4ac8e60 100755 --- a/apis/rivwebpyapi/tests/lock_log.py +++ b/apis/rivwebpyapi/tests/lock_log.py @@ -78,7 +78,7 @@ if((operation!='CREATE')and(not guid)): # webapi=rivwebpyapi.rivwebpyapi(url=url,username=username,password=password) try: - result=webapi.LockLog(log_name=log_name,operation=operation,guid=guid) + lock=webapi.LockLog(log_name=log_name,operation=operation,guid=guid) except rivwebpyapi.RivWebPyError as err: eprint('*** ERROR ***') eprint('Response Code: '+str(err.responseCode)) @@ -90,12 +90,6 @@ except rivwebpyapi.RivWebPyError as err: # # Display the result # +for key in lock.values(): + print(key+': '+str(lock.values()[key])) print('') -print('RESULT:') -print('result: '+str(result['result'])) -print('logName: '+str(result['logName'])) -print('lockGuid: '+str(result['lockGuid'])) -print('address: '+str(result['address'])) -print('lockTimeout: '+str(result['address'])) -print('') -