Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
IngoMeyer441 committed Nov 9, 2023
2 parents a6d9305 + 3796561 commit daf416d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-python-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- name: Setup simple-term-menu on Python 3.5
run: python3.5 -m pip install .
- name: Run a simple-term-menu check on Python 3.5
run: TERM=dumb python3.5 -m simple_term_menu --version
run: python3.5 -m simple_term_menu --version
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ check-python-compatibility:py35:
image: sciapp/python-testing:latest-ubuntu-20.04
script:
- python3.5 -m pip install .
- TERM=dumb python3.5 -m simple_term_menu --version
- python3.5 -m simple_term_menu --version

build-linux-executable:
stage: build
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def run(self) -> None:


def get_version_from_pyfile(version_file: str = "simple_term_menu.py") -> str:
if "TERM" not in os.environ:
os.environ["TERM"] = "" # Avoid error messages when simple-term-menu is not installed on a terminal
file_globals = runpy.run_path(version_file)
return cast(str, file_globals["__version__"])

Expand Down
20 changes: 11 additions & 9 deletions simple_term_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,12 @@
except ImportError as e:
raise NotImplementedError('"{}" is currently not supported.'.format(platform.system())) from e

if "TERM" not in os.environ:
if "PYCHARM_HOSTED" in os.environ:
raise NotImplementedError(
"simple-term-menu does not work in the PyCharm output console. Use a terminal instead (Alt + F12) or "
'activate "Emulate terminal in output console".'
)
raise NotImplementedError("simple-term-menu can only be used in a terminal emulator")


__author__ = "Ingo Meyer"
__email__ = "[email protected]"
__copyright__ = "Copyright © 2021 Forschungszentrum Jülich GmbH. All rights reserved."
__license__ = "MIT"
__version_info__ = (1, 6, 2)
__version_info__ = (1, 6, 3)
__version__ = ".".join(map(str, __version_info__))


Expand Down Expand Up @@ -640,6 +632,15 @@ def __init__(
status_bar_style: Optional[Iterable[str]] = DEFAULT_STATUS_BAR_STYLE,
title: Optional[Union[str, Iterable[str]]] = None
):
def check_for_terminal_environment() -> None:
if "TERM" not in os.environ or os.environ["TERM"] == "":
if "PYCHARM_HOSTED" in os.environ:
raise NotImplementedError(
"simple-term-menu does not work in the PyCharm output console. Use a terminal instead (Alt + "
'F12) or activate "Emulate terminal in output console".'
)
raise NotImplementedError("simple-term-menu can only be used in a terminal emulator")

def extract_shortcuts_menu_entries_and_preview_arguments(
entries: Iterable[str],
) -> Tuple[List[str], List[Optional[str]], List[Optional[str]], List[int]]:
Expand Down Expand Up @@ -720,6 +721,7 @@ def setup_title_or_status_bar_lines(
lines.append(shortcut_hints_line)
return tuple(lines)

check_for_terminal_environment()
(
self._menu_entries,
self._shortcut_keys,
Expand Down

0 comments on commit daf416d

Please sign in to comment.