diff --git a/medusa/scripts/__init__.py b/medusa/scripts/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/bin/medusa-wrapper b/medusa/scripts/medusa-wrapper.sh similarity index 96% rename from bin/medusa-wrapper rename to medusa/scripts/medusa-wrapper.sh index 4494eda34..27affb82d 100755 --- a/bin/medusa-wrapper +++ b/medusa/scripts/medusa-wrapper.sh @@ -1,3 +1,5 @@ +#! /bin/sh + # Copyright 2019 Spotify AB. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -#! /bin/sh if test -f pid; then # We can't wait for things that aren't our children. Loop and sleep. :-( while ! test -f status; do @@ -26,5 +27,6 @@ fi $@ >stdout 2>stderr & echo $! >pid wait $! -echo $? >status +STATUS=$? +echo ${STATUS} >status exit $(cat status) diff --git a/medusa/scripts/medusa_wrapper.py b/medusa/scripts/medusa_wrapper.py new file mode 100644 index 000000000..68d9a78e9 --- /dev/null +++ b/medusa/scripts/medusa_wrapper.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +import subprocess +import sys +import os + + +def main(): + # Adjust the path to where your actual shell script is located + script_dir = os.path.join(os.path.dirname(__file__)) + script_path = os.path.join(script_dir, 'medusa-wrapper.sh') + args = sys.argv[1:] + command = [script_path] + args + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + if stderr: + print(stderr, file=sys.stderr) + if stdout: + print(stdout, file=sys.stdout) + rc = p.returncode + sys.exit(rc) + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index 24ae2c204..2705dc204 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,8 +35,7 @@ packages = [ { include = "medusa" } ] include = [ - { path = "medusa-example.ini" }, - { path = "bin/medsua-wrapper" } + { path = "medusa-example.ini" } ] [project] @@ -44,6 +43,7 @@ requires-python = ">=3.8,<=3.11" [tool.poetry.scripts] medusa = { reference = "medusa.medusacli:cli", type = "console" } +medusa-wrapper = { reference = "medusa.scripts.medusa_wrapper:main", type = "console" } [tool.poetry.dependencies] python = "^3.8"