From 7c35d107abfbba0152baa04f8c3ad2c4f3607502 Mon Sep 17 00:00:00 2001 From: av1nxsh <79896600+av1nxsh@users.noreply.github.com> Date: Tue, 2 Mar 2021 14:24:00 +0530 Subject: [PATCH 1/6] rest_client.py first --- scripts/rest_client.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/rest_client.py b/scripts/rest_client.py index b6e66cfa4..eb084f400 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -75,7 +75,7 @@ class FtRestClient(): :return: json object """ return self._post("start") - + def stop(self): """Stop the bot. Use `start` to restart. @@ -174,6 +174,14 @@ class FtRestClient(): """ return self._get("show_config") + def ping(self): + """simple ping""" + + if self.show_config()['state']=="running": + return {"status": "pong"} + else: + return{"status": "not_running"} + def logs(self, limit=None): """Show latest logs. From 4fe2e542b4d9d63c17ca7f3490f25c7b823b7c7a Mon Sep 17 00:00:00 2001 From: av1nxsh <79896600+av1nxsh@users.noreply.github.com> Date: Tue, 2 Mar 2021 14:25:37 +0530 Subject: [PATCH 2/6] rest_client.py removing tab --- scripts/rest_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rest_client.py b/scripts/rest_client.py index eb084f400..183a906df 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -75,7 +75,7 @@ class FtRestClient(): :return: json object """ return self._post("start") - + def stop(self): """Stop the bot. Use `start` to restart. From 82bf65f696af779bfbe537e813de6f2492b76c10 Mon Sep 17 00:00:00 2001 From: av1nxsh <79896600+av1nxsh@users.noreply.github.com> Date: Tue, 2 Mar 2021 14:49:33 +0530 Subject: [PATCH 3/6] rest_client.py flake8 issues --- scripts/rest_client.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/rest_client.py b/scripts/rest_client.py index 183a906df..6aba92e7a 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -176,12 +176,11 @@ class FtRestClient(): def ping(self): """simple ping""" - if self.show_config()['state']=="running": return {"status": "pong"} else: - return{"status": "not_running"} - + return {"status": "not_running"} + def logs(self, limit=None): """Show latest logs. From 95c635091ef1e7f16ec5fce669d67b26af4a7abc Mon Sep 17 00:00:00 2001 From: av1nxsh <79896600+av1nxsh@users.noreply.github.com> Date: Tue, 2 Mar 2021 14:57:05 +0530 Subject: [PATCH 4/6] rest_client.py fixed operator --- scripts/rest_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rest_client.py b/scripts/rest_client.py index 6aba92e7a..39da0a406 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -176,7 +176,7 @@ class FtRestClient(): def ping(self): """simple ping""" - if self.show_config()['state']=="running": + if self.show_config()['state'] == "running": return {"status": "pong"} else: return {"status": "not_running"} From 218d22ed528da1bcc22b6971c4ff4f4ec847eae6 Mon Sep 17 00:00:00 2001 From: av1nxsh <79896600+av1nxsh@users.noreply.github.com> Date: Tue, 2 Mar 2021 15:45:16 +0530 Subject: [PATCH 5/6] rest_client.py updated for connection error case --- scripts/rest_client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/rest_client.py b/scripts/rest_client.py index 39da0a406..a7d7705fe 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -176,7 +176,9 @@ class FtRestClient(): def ping(self): """simple ping""" - if self.show_config()['state'] == "running": + if not self.show_config(): + return {"status": "not_running"} + elif self.show_config()['state'] == "running": return {"status": "pong"} else: return {"status": "not_running"} From a85e656e8d5320db721216365205c16160756d5f Mon Sep 17 00:00:00 2001 From: av1nxsh <79896600+av1nxsh@users.noreply.github.com> Date: Tue, 2 Mar 2021 16:16:20 +0530 Subject: [PATCH 6/6] rest_client.py optimised with var 'configstatus' --- scripts/rest_client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/rest_client.py b/scripts/rest_client.py index a7d7705fe..ecf961ddd 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -176,9 +176,10 @@ class FtRestClient(): def ping(self): """simple ping""" - if not self.show_config(): + configstatus = self.show_config() + if not configstatus: return {"status": "not_running"} - elif self.show_config()['state'] == "running": + elif configstatus['state'] == "running": return {"status": "pong"} else: return {"status": "not_running"}