Skip to content

Commit 1838e0d

Browse files
committed
improve error handling for userscripts
from python-diamond/Diamond#536
1 parent 872504d commit 1838e0d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/collectors/userscripts/userscripts.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,23 @@ def collect(self):
7676
(absolutescriptpath, e))
7777
continue
7878
if proc.returncode:
79-
self.log.error("%s return exit value %s; skipping" %
79+
self.log.error("%s return exit value %s" %
8080
(absolutescriptpath, proc.returncode))
81+
if err:
82+
self.log.warning("%s return error output: %s" %
83+
(absolutescriptpath, err))
8184
if not out:
82-
self.log.info("%s return no output" % absolutescriptpath)
85+
self.log.error("%s returned no output; skipping" %
86+
absolutescriptpath)
8387
continue
84-
if err:
85-
self.log.error("%s returned error output (stderr): %s" %
86-
(absolutescriptpath, err))
8788
# Use filter to remove empty lines of output
8889
for line in filter(None, out.split('\n')):
8990
# Ignore invalid lines
9091
try:
9192
name, value = line.split()
9293
float(value)
9394
except ValueError:
94-
self.log.error("%s returned invalid/unparsable output: %s" %
95+
self.log.error("%s returned error output: %s" %
9596
(absolutescriptpath, line))
9697
continue
9798
name, value = line.split()

0 commit comments

Comments
 (0)