Skip to content

Commit

Permalink
Merge pull request #244 from aadityasinha-dotcom/encoding
Browse files Browse the repository at this point in the history
Default encoding for I/O operations should be UTF-8
  • Loading branch information
t1m0thyj authored Jan 9, 2024
2 parents c4e2a20 + c43d6b2 commit 2d79e9c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil

### 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)
- Fixed an issue with `list_jobs` user correlator parameter [#242](https://github.com/zowe/zowe-client-python-sdk/issues/242)
- Return response instead of raw from streamed requests [#245](https://github.com/zowe/zowe-client-python-sdk/pull/245)
- Fixed `Files.create_data_set` to accept "FBA", "FBM", "VBA", "VBM" as valid recfm [#240](https://github.com/zowe/zowe-client-python-sdk/issues/240)
- Fixed an issue with `Jobs.list_jobs` user correlator parameter [#242](https://github.com/zowe/zowe-client-python-sdk/issues/242)
- Fixed default encoding for I/O operations to be UTF-8 on Windows [#243](https://github.com/zowe/zowe-client-python-sdk/issues/243)

### Enhancements

- Next Breaking: Updated core SDK method `RequestHandler.perform_streamed_request` to return response object instead of raw buffer. [#245](https://github.com/zowe/zowe-client-python-sdk/pull/245)

## `1.0.0-dev12`

Expand Down
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 write_to_dsn(self, dataset_name, data, encoding=_ZOWE_FILES_DEFAULT_ENCODING
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:
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 write_to_uss(self, filepath_name, data, encoding=_ZOWE_FILES_DEFAULT_ENCODIN
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")
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 @@ -267,7 +267,7 @@ def submit_from_local_file(self, jcl_path):
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")
file_content = jcl_file.read()
jcl_file.close()
return self.submit_plaintext(file_content)
Expand Down Expand Up @@ -397,7 +397,7 @@ def get_job_output_as_files(self, status, output_dir):
_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")
_out_file.write(_dataset_content)
_out_file.close()

Expand All @@ -412,7 +412,7 @@ def get_job_output_as_files(self, status, output_dir):
_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")
_out_file.write(_dataset_content)
_out_file.close()

Expand Down

0 comments on commit 2d79e9c

Please sign in to comment.