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

added a new python script that could run on windows #86

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

UrAmico3000
Copy link

  • Copied and created a new file and then changed a parameter of an open() method to "rb" from "r" since it was giving encoding errors on windows
  • Updated the environment from python3 (viz for mac) to python so that the script can be executed using ./
  • Updated the README.md for the windows users

@danner26
Copy link
Member

danner26 commented Mar 24, 2023

Hello @UrAmico3000, as mentioned in the pre-release notice, v2.0.0 was released today. The DeviceType Library Import script has been updated to version 2, bringing performance improvements, enhanced logging, and other upgrades. We have bumped the release by a major version due to the significant changes to the codebase.

Thus, you will need to reevaluate how your PR is written and what files have been modified. I would be glad to assist if needed.

Also, as a note for next time; please create a FR in the issues tab before creating a PR. This allows for better tracking and serves as a conversation place so that the PR doesn't get cluttered. Thank you.

@danner26 danner26 added the status: revisions needed This issue requires additional information to be actionable label Mar 24, 2023
@AravindhStanley
Copy link

AravindhStanley commented Mar 28, 2023

@danner26 I have tested it against the pre-release-newbase branch and the decoding error on windows platform still persists.

UnicodeDecodeError: 'charmap' codec cannot decode byte 0x9d in position 179: character maps to <undefined>.

Changing the file reading mode to "read bytes" seems to fix the issue, as I suggested in the slack chat.

In the pre-release branch, its in the repo.py file in DTL parse_file method.

def parse_files(self, files: list, slugs: list = None):
        deviceTypes = []
        for file in files:
            [OLD] with open(file, 'r') as stream:
            [NEW] with open(file, 'rb') as stream: 
            ## OR SHOULD WE JUST SPECIFY THE ENCODING EXPLICITLY
                try:
                    data = yaml.safe_load(stream)
                except yaml.YAMLError as excep:
                    self.handle.verbose_log(excep)
                    continue

I can successfully import all the devices after the suggested modification and tested it on both mac and windows.

@UrAmico3000 As for changing the shebang line, I'm not sure, if we should change it to python. For folks running this on a global env with python2 installed, that is gonna be problem. I suggest we rather update the documentation to use python(3) nb-import.py to launch the script.

Since its minor change, I'm not creating a PR for now. @danner26 Let me know you want me to create an issue and close it with a PR.

@illgetmine16
Copy link

Still learning to use Github, so not sure where this would go. I was having encoding issues on my windows 11 PC and fixed it by doing the following:

change line 88 of repo.py:
Old: with open(file, 'r') as stream:
New: with open(file, 'r', encoding='utf-8') as stream:

After doing that, was able to run the script without any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: revisions needed This issue requires additional information to be actionable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants