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

Default encoding for I/O operations should be UTF-8 #244

Merged
merged 12 commits into from
Jan 9, 2024
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil

## Recent Changes

<<<<<<< HEAD
- Bug: Default encoding for I/O operations should be UTF-8
- Feature: Added method to load profile properties from environment variables
=======
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is still a merge conflict here 😋

Copy link
Contributor Author

@aadityasinha-dotcom aadityasinha-dotcom Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes my bad, I forgot to resolve them 😋
It should be good now

### Bug Fixes

- Fixed 'create_data_set' to accept "FBA", "FBM", "VBA", "VBM" as valid recfm [#240](https://github.com/zowe/zowe-client-python-sdk/issues/240)
Expand Down Expand Up @@ -32,3 +36,4 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil
- Fixed profile merge order to match Node.js SDK [#190](https://github.com/zowe/zowe-client-python-sdk/issues/190)
- Fixed issue for datasets and jobs with special characters in URL [#211](https://github.com/zowe/zowe-client-python-sdk/issues/211)
- Fixed exception handling in session.py [#213](https://github.com/zowe/zowe-client-python-sdk/issues/213)
>>>>>>> 80c6a66785746ec730684d04aa70064b2da6e397
4 changes: 2 additions & 2 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@
def download_dsn(self, dataset_name, output_file):
"""Retrieve the contents of a dataset and saves it to a given file."""
raw_response = self.get_dsn_content_streamed(dataset_name)
with open(output_file, "w") as f:
with open(output_file, 'w', encoding="utf-8") as f:

Check warning on line 520 in src/zos_files/zowe/zos_files_for_zowe_sdk/files.py

View check run for this annotation

Codecov / codecov/patch

src/zos_files/zowe/zos_files_for_zowe_sdk/files.py#L520

Added line #L520 was not covered by tests
shutil.copyfileobj(raw_response, f)

def download_binary_dsn(self, dataset_name, output_file, with_prefixes=False):
Expand Down Expand Up @@ -564,7 +564,7 @@
def upload_file_to_uss(self, input_file, filepath_name, encoding=_ZOWE_FILES_DEFAULT_ENCODING):
"""Upload contents of a given file and uploads it to UNIX file"""
if os.path.isfile(input_file):
in_file = open(input_file, "r")
in_file = open(input_file, 'r', encoding="utf-8")

Check warning on line 567 in src/zos_files/zowe/zos_files_for_zowe_sdk/files.py

View check run for this annotation

Codecov / codecov/patch

src/zos_files/zowe/zos_files_for_zowe_sdk/files.py#L567

Added line #L567 was not covered by tests
file_contents = in_file.read()
response_json = self.write_to_uss(filepath_name, file_contents)
else:
Expand Down
6 changes: 3 additions & 3 deletions src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
A JSON containing the result of the request execution
"""
if os.path.isfile(jcl_path):
jcl_file = open(jcl_path, "r")
jcl_file = open(jcl_path, "r", encoding="utf-8")

Check warning on line 269 in src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py

View check run for this annotation

Codecov / codecov/patch

src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py#L269

Added line #L269 was not covered by tests
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added encoding="utf-8" for all open()` ☺️

file_content = jcl_file.read()
jcl_file.close()
return self.submit_plaintext(file_content)
Expand Down Expand Up @@ -396,7 +396,7 @@
_output_file = os.path.join(output_dir, _job_name, _job_id, "jcl.txt")
_data_spool_file = self.get_jcl_text(_job_correlator)
_dataset_content = _data_spool_file["response"]
_out_file = open(_output_file, "w")
_out_file = open(_output_file, "w", encoding="utf-8")

Check warning on line 399 in src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py

View check run for this annotation

Codecov / codecov/patch

src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py#L399

Added line #L399 was not covered by tests
_out_file.write(_dataset_content)
_out_file.close()

Expand All @@ -411,7 +411,7 @@
_output_file = os.path.join(output_dir, _job_name, _job_id, _stepname, _ddname)
_data_spool_file = self.get_spool_file_contents(_job_correlator, _spoolfile_id)
_dataset_content = _data_spool_file["response"]
_out_file = open(_output_file, "w")
_out_file = open(_output_file, "w", encoding="utf-8")

Check warning on line 414 in src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py

View check run for this annotation

Codecov / codecov/patch

src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py#L414

Added line #L414 was not covered by tests
_out_file.write(_dataset_content)
_out_file.close()

Expand Down