Skip to content

Commit

Permalink
Check terminal encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Aug 26, 2024
1 parent 2ac1d0e commit c2688e7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ethstaker_deposit/deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ def check_python_version() -> None:
sys.exit()


def check_term_encoding() -> None:
'''
Checks that the terminal uses utf-8 encoding and exits if not. This is done to avoid issues with passwords
'''
encoding = sys.stdin.encoding
if encoding not in ('utf-8', 'UTF-8'):
click.pause(
'Your terminal is using %s encoding which can present problems with passwords. '
'Please use "utf-8".' % encoding
)
sys.exit()


def check_connectivity() -> None:
'''
Checks if there is an internet connection and warns the user if so.
Expand Down Expand Up @@ -109,6 +122,7 @@ def cli(ctx: click.Context, language: str, non_interactive: bool, ignore_connect
def run() -> None:
freeze_support() # Needed when running under Windows in a frozen bundle
check_python_version()
check_term_encoding()

try:
cli()
Expand Down

0 comments on commit c2688e7

Please sign in to comment.