From d39d95ebc91d987350641800d891bd788e335d62 Mon Sep 17 00:00:00 2001 From: Aleksandr Alekseev Date: Wed, 24 May 2023 14:39:23 +0200 Subject: [PATCH 1/4] Fixing PanDA client --- core/panda_client/views.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/panda_client/views.py b/core/panda_client/views.py index 53c2c15f..f47f4659 100644 --- a/core/panda_client/views.py +++ b/core/panda_client/views.py @@ -22,12 +22,21 @@ def client(request): if auth is not None and ('Authorization' in auth and 'Origin' in auth): if len(request.session['requestParams']) > 0: data = request.session['requestParams'] + + if 'taskID' in data and data['taskID'] is not None: + jeditaskid = data['taskID'] + elif 'taskid' in data and data['taskid'] is not None: + jeditaskid = data['taskid'] + else: + jeditaskid = None + info['text'] ='Error! JeditaskID is none' + ###Finish Task - if data['action'] == 'finishtask' and ('taskID' in data and data['taskID'] is not None): - info['text'] = finish_task(auth=auth, jeditaskid=data['taskID']) + if data['action'] == 'finishtask' and jeditaskid is not None: + info['text'] = finish_task(auth=auth, jeditaskid=jeditaskid) ### Kill Task - elif data['action'] == 'killtask' and ('taskID' in data and data['taskID'] is not None): - info['text'] = kill_task(auth=auth, jeditaskid=data['taskID']) + elif data['action'] == 'killtask' and jeditaskid is not None: + info['text'] = kill_task(auth=auth, jeditaskid=jeditaskid) ### Set debug mode elif data['action'] == 'setdebugmode' and ('pandaid' in data and data['pandaid'] is not None): if ('params' in data and data['params'] is not None): From 3a45d9193deb41577de1f3dfa2c74639d5d6b3e6 Mon Sep 17 00:00:00 2001 From: Aleksandr Alekseev Date: Wed, 24 May 2023 14:40:26 +0200 Subject: [PATCH 2/4] Fixing PanDA client --- core/panda_client/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/panda_client/views.py b/core/panda_client/views.py index f47f4659..867b2e6d 100644 --- a/core/panda_client/views.py +++ b/core/panda_client/views.py @@ -29,7 +29,6 @@ def client(request): jeditaskid = data['taskid'] else: jeditaskid = None - info['text'] ='Error! JeditaskID is none' ###Finish Task if data['action'] == 'finishtask' and jeditaskid is not None: @@ -53,7 +52,10 @@ def client(request): else: info['redirect'] = 'false' else: - info['text'] = 'Operation error' + if jeditaskid is None: + info['text'] = 'Error! JeditaskID is none' + else: + info['text'] = 'Operation error' else: info['text'] = 'Request body is empty' else: From 0dfa084cc2beb2700ebe5316564bbefb3e3e1d7d Mon Sep 17 00:00:00 2001 From: Aleksandr Alekseev Date: Wed, 24 May 2023 15:01:39 +0200 Subject: [PATCH 3/4] Fixing PanDA client --- core/panda_client/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/panda_client/utils.py b/core/panda_client/utils.py index 9a4d1604..3daeebba 100644 --- a/core/panda_client/utils.py +++ b/core/panda_client/utils.py @@ -63,7 +63,7 @@ def kill_task(auth, jeditaskid): resp = post(url, headers=auth, data=data) resp = resp.text except Exception as ex: - resp = "ERROR killTask: %s %s" % (ex, resp.status_code) + resp = "ERROR killTask: %s" % (ex) else: resp = 'Jeditaskid is not defined' From 9bbd5d81f88fb9b7b4c50b5a1e82c654643dc2f0 Mon Sep 17 00:00:00 2001 From: Aleksandr Alekseev Date: Wed, 24 May 2023 15:33:31 +0200 Subject: [PATCH 4/4] Fixing PanDA client Adding logging --- core/panda_client/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/panda_client/utils.py b/core/panda_client/utils.py index 3daeebba..82ac7edc 100644 --- a/core/panda_client/utils.py +++ b/core/panda_client/utils.py @@ -64,9 +64,11 @@ def kill_task(auth, jeditaskid): resp = resp.text except Exception as ex: resp = "ERROR killTask: %s" % (ex) + _logger.error(ex) else: resp = 'Jeditaskid is not defined' - + _logger.debug("Finish task command. jeditaskid: {0}, properErrorCode: {1}, URL: {2}, response: {3}". + format(data['jediTaskID'], data['properErrorCode'], url, resp)) return resp @@ -94,10 +96,12 @@ def finish_task(auth, jeditaskid, soft=True): resp = post(url, headers=auth, data=data) resp = resp.text except Exception as ex: - resp = "ERROR finishTask: %s %s" % (ex, resp.status_code) + resp = "ERROR finishTask: %s" % (ex) + _logger.error(ex) else: resp = 'Jeditaskid is not defined' - + _logger.debug("Finish task command. jeditaskid: {0}, properErrorCode: {1}, soft: {2}, URL: {3}, response: {4}". + format(data['jediTaskID'], data['properErrorCode'], data['soft'], url, resp)) return resp