Skip to content

Commit 313af85

Browse files
authored
Merge pull request #1 from donkeystudio/return-exit-code
To return exit code from the executed script.
2 parents 7d932e7 + 69324e7 commit 313af85

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ Success
7171
```json
7272
{
7373
"status": 200,
74-
"data": "1 2 test\n"
74+
"data": "1 2 test\n",
75+
"code": "Exit code from the target script."
7576
}
7677
```
7778
Failed

api_resource.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ def process_post(self):
5353
command = [self._config.target] + payload.args
5454
self._logger.info(f'Running command: {command}')
5555
result = subprocess.run(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
56+
# Get return code from command
57+
return_code = result.returncode
58+
self._logger.info(f'Return code: {return_code}')
5659
self._logger.debug(f'Result: {result.stdout}')
57-
return {'status': 200, 'data': result.stdout}, 200
60+
return {'status': 200, 'data': result.stdout, 'code': return_code}, 200
5861

5962

6063
def process_get(self):

0 commit comments

Comments
 (0)