Skip to content

Commit 95639cc

Browse files
Fixed conceptual name error and simplified hook call logic.
1 parent 5eb8beb commit 95639cc

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

webhooks.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import hmac
2323
from hashlib import sha1
2424
from json import loads, dumps
25-
from shlex import split as shsplit
2625
from subprocess import Popen, PIPE
2726
from os import access, X_OK
2827
from os.path import isfile, abspath, normpath, dirname, join
@@ -101,29 +100,31 @@ def index():
101100
]
102101

103102
# Run scripts
104-
silent = config.get('return_scripts_info', False)
105103
ran = {}
106104
for s in scripts:
107105
if isfile(s) and access(s, X_OK):
108106

109-
cmd = "{} '{}'".format(s, dumps(payload))
110-
logging.error(cmd)
111-
112107
proc = Popen(
113-
shsplit(cmd),
108+
[s, dumps(payload)],
114109
shell=True,
115110
stdout=PIPE, stderr=PIPE
116111
)
117112
stdout, stderr = proc.communicate()
118113

119-
if not silent:
120-
ran[basename(s)] = {
121-
'returncode': proc.returncode,
122-
'stdout': stdout,
123-
'stderr': stderr,
124-
}
114+
ran[basename(s)] = {
115+
'returncode': proc.returncode,
116+
'stdout': stdout,
117+
'stderr': stderr,
118+
}
119+
120+
output = ''
121+
122+
info = config.get('return_scripts_info', False)
123+
if info:
124+
output = dumps(ran, sort_keys=True, indent=4)
125+
logging.debug(output)
125126

126-
return ran
127+
return output
127128

128129

129130
if __name__ == '__main__':

0 commit comments

Comments
 (0)