From a99d5609fad2d38b97c43babd9179e2f3b646d47 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 12 Dec 2018 18:00:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=B5=8B=E8=AF=95=E7=A1=AC=E4=BB=B6=E7=AD=89=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/models/adhoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ops/models/adhoc.py b/apps/ops/models/adhoc.py index 1f322f944..82c6fa37e 100644 --- a/apps/ops/models/adhoc.py +++ b/apps/ops/models/adhoc.py @@ -229,7 +229,7 @@ class AdHoc(models.Model): history.result = raw history.summary = summary return raw, summary - except Exception as e: + except IndexError as e: return {}, {"dark": {"all": str(e)}, "contacted": []} finally: # f.close() From 55ff82545a4bb635901cdf2cc6c9e3c087d1098e Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 12 Dec 2018 18:03:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=89=A7=E8=A1=8Cargs=E4=B8=BA=E7=A9=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/ansible/runner.py | 2 ++ apps/ops/models/adhoc.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/ops/ansible/runner.py b/apps/ops/ansible/runner.py index fe23b0d6d..7931b72ee 100644 --- a/apps/ops/ansible/runner.py +++ b/apps/ops/ansible/runner.py @@ -165,6 +165,8 @@ class AdHocRunner: ) def clean_args(self, module, args): + if not args: + return '' if module not in self.command_modules_choices: return args if isinstance(args, str): diff --git a/apps/ops/models/adhoc.py b/apps/ops/models/adhoc.py index 82c6fa37e..1f322f944 100644 --- a/apps/ops/models/adhoc.py +++ b/apps/ops/models/adhoc.py @@ -229,7 +229,7 @@ class AdHoc(models.Model): history.result = raw history.summary = summary return raw, summary - except IndexError as e: + except Exception as e: return {}, {"dark": {"all": str(e)}, "contacted": []} finally: # f.close()