Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include legacy detection #159

Merged
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ ds.log
x_cli_code
timings
*dict_structure.json
*.code-workspace
.DDS_CLI.env
6 changes: 6 additions & 0 deletions dds_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import os
import pkg_resources
import prompt_toolkit
import rich.console


###############################################################################
# PROJECT SPEC ################################################# PROJECT SPEC #
Expand All @@ -14,6 +16,7 @@
__author__ = "SciLifeLab Data Centre"
__author_email__ = "[email protected]"
__license__ = "MIT"
__all__ = ["DDSEndpoint", "FileSegment", "dds_questionary_styles", "dds_on_legacy_console"]

###############################################################################
# CLASSES ########################################################### CLASSES #
Expand Down Expand Up @@ -92,3 +95,6 @@ class FileSegment:
("choice-required", "fg:ansired"),
]
)

# Determine if the user is on an old terminal without proper Unicode support
dds_on_legacy_console = rich.console.detect_legacy_windows()
26 changes: 16 additions & 10 deletions dds_cli/text_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Standard library
import logging
import pathlib
import dds_cli

# Installed

Expand Down Expand Up @@ -65,13 +66,18 @@ def task_name(file, step="", max_len=30):
task_name = "..." + task_name.split("...", 1)[-1][-max_len::]

# Different symbols to the left depending on current process
symbol = ""
if step == "encrypt":
symbol = ":lock:"
elif step == "put":
symbol = ":arrow_up: "
elif step == "get":
symbol = ":arrow_down: "
elif step == "decrypt":
symbol = ":unlock:"
return f"{symbol} {task_name}"
if dds_cli.dds_on_legacy_console:
symbols = {
"encrypt": "[bold]seal",
i-oden marked this conversation as resolved.
Show resolved Hide resolved
"put": "[bold]put",
"get": "[bold]get",
"decrypt": "[bold]open",
}
else:
symbols = {
"encrypt": ":lock:",
"put": ":arrow_up:",
"get": ":arrow_down:",
"decrypt": ":unlock:",
}
return f"{symbols.get(step, '')} {task_name}"