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

fixed Issue 54- UnicodeEncodeError when running via terminal in windows #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eranga-mohotty
Copy link

@eranga-mohotty eranga-mohotty commented Jan 21, 2024

Description

Fix for Issue #54 - UnicodeEncodeError when running via terminal in windows

Motivation and Context

When executing a python script via a batch script (.bat) and calling the function initialize_VPN(...) it will throw a UnicodeEncodeError this update will set the encoding to 'utf-8'. However this issue is only fixed for python versions 3.7 and above as the "sys.stdout.reconfigure()" method is available starting from 3.7

Changes Made

import sys [+line 10]

[+lines 129-136]

# Check if the platform is Windows
if platform.system() == 'Windows':
    # Change the encoding to 'utf-8' for Windows terminal
    if sys.version_info >= (3, 7):
        try:
            sys.stdout.reconfigure(encoding='utf-8')
        except Exception as e:
            print(f"An error occurred while reconfiguring stdout: {e}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant