-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MONTEREY): add support for monterey
- Loading branch information
1 parent
75dfef5
commit 1ebf394
Showing
10 changed files
with
115 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import os | ||
import sys | ||
|
||
from mac_maker import cli | ||
from multiprocessing import freeze_support, set_start_method | ||
|
||
freeze_support() | ||
set_start_method('spawn') | ||
os.environ['SSL_CERT_FILE'] = os.path.join(sys._MEIPASS, 'lib', 'cert.pem') | ||
cli.cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Python interpreter discovery class.""" | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
|
||
class InterpreterNotFound(Exception): | ||
"""Raised when a valid Python interpreter is not found.""" | ||
|
||
|
||
class Interpreter: | ||
"""The local Python interpreter used by Ansible.""" | ||
|
||
options = [ | ||
Path("/usr/bin/python"), | ||
Path("/usr/bin/python3"), | ||
] | ||
|
||
def get_interpreter_path(self) -> Path: | ||
"""Return the path to a valid python interpreter on this system. | ||
:returns: The path to a valid python interpreter. | ||
""" | ||
|
||
for interpreter in self.options: | ||
if os.path.exists(interpreter): | ||
return interpreter | ||
|
||
raise InterpreterNotFound("No Python interpreter found.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Test the Interpreter class.""" | ||
|
||
from pathlib import Path | ||
from unittest import TestCase, mock | ||
|
||
from .. import interpreter | ||
|
||
INTERPRETER_MODULE = interpreter.__name__ | ||
|
||
|
||
class TestInterpreter(TestCase): | ||
"""Test the Interpreter class.""" | ||
|
||
def setUp(self) -> None: | ||
self.interpreter = interpreter.Interpreter() | ||
|
||
def test_initialize(self) -> None: | ||
for initialized_interpreter in self.interpreter.options: | ||
self.assertIsInstance(initialized_interpreter, Path) | ||
|
||
@mock.patch(INTERPRETER_MODULE + ".os") | ||
def test_first_interpreter_valid(self, m_os: mock.Mock) -> None: | ||
|
||
m_os.path.exists.side_effect = [True] | ||
self.assertEqual( | ||
self.interpreter.options[0], self.interpreter.get_interpreter_path() | ||
) | ||
|
||
@mock.patch(INTERPRETER_MODULE + ".os") | ||
def test_last_interpreter_valid(self, m_os: mock.Mock) -> None: | ||
m_os.path.exists.side_effect = [False, True] | ||
self.assertEqual( | ||
self.interpreter.options[1], self.interpreter.get_interpreter_path() | ||
) | ||
|
||
@mock.patch(INTERPRETER_MODULE + ".os") | ||
def test_no_interpreter_valid(self, m_os: mock.Mock) -> None: | ||
m_os.path.exists.side_effect = [False, False] | ||
with self.assertRaises(interpreter.InterpreterNotFound): | ||
self.interpreter.get_interpreter_path() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters