Skip to content

Commit

Permalink
Merge pull request #10 from dls-controls/fix_shebang
Browse files Browse the repository at this point in the history
Fix shebang
  • Loading branch information
UrszulaNeuman committed Mar 28, 2023
2 parents 1c50436 + d88ac3f commit c0024d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 3 additions & 2 deletions converter/motionarea.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import List, Optional, Tuple

from converter.indent import Indenter
from pmac_motorhome._version_git import __version__

from .pipemessage import IPC_FIFO_NAME, get_message
from .shim.plc import PLC
Expand Down Expand Up @@ -353,8 +354,8 @@ def glob_files(*patterns: str):

def get_shebang(self):
# get the python path for shebang
python_path = subprocess.check_output("which python", shell=True).strip()
python_path = python_path.decode("utf-8")
module_path_elements = ['/dls_sw','prod','python3', 'RHEL7-x86_64','pmac_motorhome', __version__, 'lightweight-venv', 'bin','python3']
python_path = '/'.join(module_path_elements)
text = f"#!/bin/env {python_path}"
return text

Expand Down
8 changes: 3 additions & 5 deletions tests/unittests/converter/test_motionarea.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
from unittest.mock import patch

from converter.motionarea import MotionArea
from pmac_motorhome._version_git import __version__


class TestMotionArea(unittest.TestCase):
@patch("subprocess.check_output")
def test_shebang_looks_as_expected(self, mock_subprocess):
def test_shebang_looks_as_expected(self):
# Arrange
python_path = "/bin/python"
expected_shebang = "#!/bin/env /bin/python"
mock_subprocess.return_value = python_path.encode("UTF-8")
expected_shebang = "#!/bin/env /dls_sw/prod/python3/RHEL7-x86_64/pmac_motorhome/"+__version__+"/lightweight-venv/bin/python3"
motionarea = MotionArea(Path("/tmp"))
# Act
content = motionarea.get_shebang()
Expand Down

0 comments on commit c0024d3

Please sign in to comment.