Skip to content

Commit

Permalink
Add bin/medusa-wrapper to package's installed scripts (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvoncek authored Apr 25, 2024
1 parent edb76ef commit 69e00a4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Empty file added medusa/scripts/__init__.py
Empty file.
6 changes: 4 additions & 2 deletions bin/medusa-wrapper → medusa/scripts/medusa-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#! /bin/sh

# Copyright 2019 Spotify AB. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -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
Expand All @@ -26,5 +27,6 @@ fi
$@ >stdout 2>stderr &
echo $! >pid
wait $!
echo $? >status
STATUS=$?
echo ${STATUS} >status
exit $(cat status)
24 changes: 24 additions & 0 deletions medusa/scripts/medusa_wrapper.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ packages = [
{ include = "medusa" }
]
include = [
{ path = "medusa-example.ini" },
{ path = "bin/medsua-wrapper" }
{ path = "medusa-example.ini" }
]

[project]
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"
Expand Down

0 comments on commit 69e00a4

Please # to comment.