mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 01:25:16 +00:00
Change message for empty output
This commit is contained in:
parent
389c6cb3c5
commit
c5f27253b0
@ -18,12 +18,14 @@ def query_to_script_path(path, query):
|
||||
|
||||
def run_script(script, shell):
|
||||
output = subprocess.check_output(script, shell=shell)
|
||||
if output is not None:
|
||||
output = output.strip()
|
||||
if output != "":
|
||||
return output, None
|
||||
if output is None:
|
||||
return None, "Error reading output"
|
||||
|
||||
return None, "Error reading output"
|
||||
output = output.strip()
|
||||
if not output:
|
||||
return None, "Empty output from script"
|
||||
|
||||
return output, None
|
||||
|
||||
|
||||
class Script(BaseQueryRunner):
|
||||
|
@ -31,6 +31,6 @@ class TestRunScript(BaseTestCase):
|
||||
self.monkeypatch.setattr(subprocess, "check_output", lambda script, shell: None)
|
||||
self.assertEqual((None, "Error reading output"), run_script("/foo/bar/baz.sh", True))
|
||||
self.monkeypatch.setattr(subprocess, "check_output", lambda script, shell: "")
|
||||
self.assertEqual((None, "Error reading output"), run_script("/foo/bar/baz.sh", True))
|
||||
self.assertEqual((None, "Empty output from script"), run_script("/foo/bar/baz.sh", True))
|
||||
self.monkeypatch.setattr(subprocess, "check_output", lambda script, shell: " ")
|
||||
self.assertEqual((None, "Error reading output"), run_script("/foo/bar/baz.sh", True))
|
||||
self.assertEqual((None, "Empty output from script"), run_script("/foo/bar/baz.sh", True))
|
||||
|
Loading…
Reference in New Issue
Block a user