Skip to content

Commit

Permalink
Merge branch 'main' into validate_schema
Browse files Browse the repository at this point in the history
Signed-off-by: Aaditya Sinha <[email protected]>
  • Loading branch information
aadityasinha-dotcom authored Oct 10, 2023
2 parents 0e3b5c4 + 72c68e7 commit 0f2eda8
Show file tree
Hide file tree
Showing 49 changed files with 1,403 additions and 968 deletions.
8 changes: 6 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF
formats:
formats:
- pdf

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil

## Recent Changes

- Bug: Fixed profile merge order to match Node.js SDK
- Feature: Added method to load profile properties from environment variables
- Bugfix: Fixed exception handling in session.py [#213] (https://github.com/zowe/zowe-client-python-sdk/issues/213)
- Feature: Added a CredentialManager class to securely retrieve values from credentials and manage multiple credential entries on Windows [#134](https://github.com/zowe/zowe-client-python-sdk/issues/134)
- Feature: Added method to Save profile properties to zowe.config.json file [#73](https://github.com/zowe/zowe-client-python-sdk/issues/73)
- Feature: Added method to Save secure profile properties to vault [#72](https://github.com/zowe/zowe-client-python-sdk/issues/72)
- Bugfix: Fixed issue for datasets and jobs with special characters in URL [#211] (https://github.com/zowe/zowe-client-python-sdk/issues/211)
- Bugfix: Fixed exception handling in session.py [#213] (https://github.com/zowe/zowe-client-python-sdk/issues/213)
- Feature: Added method to load profile properties from environment variables
- BugFix: Validation of zowe.config.json file matching the schema [#192](https://github.com/zowe/zowe-client-python-sdk/issues/192)
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ This project follows the [PEP 8](https://www.python.org/dev/peps/pep-0008/) styl

This project also uses `flake8` for code linting. Make sure to run `flake8` on your code before submitting a pull request.

We recommend using `black` as a code formatter. Please format your code using `black` before creating a pull request.
We recommend using `black` and `isort` as code formatters. Please format your code using these tools before creating a pull request.
62 changes: 33 additions & 29 deletions docs/source/_ext/zowe_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,15 @@ def main():
py_name = os.path.basename(py_file)
if py_name == "__init__.py":
continue
with open(py_file, 'r', encoding="utf-8") as f:
with open(py_file, "r", encoding="utf-8") as f:
py_contents = f.read()
class_names = re.findall(r"^class (\w+)\b", py_contents, re.MULTILINE)
if len(class_names) == 1:
rst_name = f"{py_name[:-3]}.rst"
rst_contents = render_template(CLASS_TEMPLATE, {
"fullname": f"{sdk_name}.{pkg_name}.{class_names[0]}",
"header": class_names[0]
})
with open(f"docs/source/classes/{sdk_name}/{rst_name}", 'w', encoding="utf-8") as f:
rst_contents = render_template(
CLASS_TEMPLATE, {"fullname": f"{sdk_name}.{pkg_name}.{class_names[0]}", "header": class_names[0]}
)
with open(f"docs/source/classes/{sdk_name}/{rst_name}", "w", encoding="utf-8") as f:
f.write(rst_contents)
rst_names.append(rst_name)
elif len(class_names) > 1:
Expand All @@ -70,39 +69,44 @@ def main():
child_rst_names = []
for class_name in sorted(class_names):
rst_name = f"{class_name.lower()}.rst"
rst_contents = render_template(CLASS_TEMPLATE, {
"fullname": f"{sdk_name}.{pkg_name}.{module_name}.{class_name}",
"header": class_name
})
with open(f"docs/source/classes/{sdk_name}/{module_name}/{rst_name}", 'w', encoding="utf-8") as f:
rst_contents = render_template(
CLASS_TEMPLATE,
{"fullname": f"{sdk_name}.{pkg_name}.{module_name}.{class_name}", "header": class_name},
)
with open(f"docs/source/classes/{sdk_name}/{module_name}/{rst_name}", "w", encoding="utf-8") as f:
f.write(rst_contents)
child_rst_names.append(rst_name)
rst_name = f"{module_name}/index.rst"
rst_contents = render_template(INDEX_TEMPLATE, {
"filelist": "\n ".join(name[:-4] for name in child_rst_names),
"header": f"{module_name.replace('_', ' ').title()} classes",
"maxdepth": 2
})
with open(f"docs/source/classes/{sdk_name}/{rst_name}", 'w', encoding="utf-8") as f:
rst_contents = render_template(
INDEX_TEMPLATE,
{
"filelist": "\n ".join(name[:-4] for name in child_rst_names),
"header": f"{module_name.replace('_', ' ').title()} classes",
"maxdepth": 2,
},
)
with open(f"docs/source/classes/{sdk_name}/{rst_name}", "w", encoding="utf-8") as f:
f.write(rst_contents)
parent_rst_names.append(rst_name)

rst_contents = render_template(INDEX_TEMPLATE, {
"filelist": "\n ".join(name[:-4] for name in rst_names + parent_rst_names),
"header": pkg_name,
"maxdepth": 2
})
with open(f"docs/source/classes/{sdk_name}/index.rst", 'w', encoding="utf-8") as f:
rst_contents = render_template(
INDEX_TEMPLATE,
{
"filelist": "\n ".join(name[:-4] for name in rst_names + parent_rst_names),
"header": pkg_name,
"maxdepth": 2,
},
)
with open(f"docs/source/classes/{sdk_name}/index.rst", "w", encoding="utf-8") as f:
f.write(rst_contents)
sdk_names.append(sdk_name)
print("done")

rst_contents = render_template(INDEX_TEMPLATE, {
"filelist": "\n ".join(f"{name}/index" for name in sdk_names),
"header": "Classes",
"maxdepth": 3
})
with open(f"docs/source/classes/index.rst", 'w', encoding="utf-8") as f:
rst_contents = render_template(
INDEX_TEMPLATE,
{"filelist": "\n ".join(f"{name}/index" for name in sdk_names), "header": "Classes", "maxdepth": 3},
)
with open(f"docs/source/classes/index.rst", "w", encoding="utf-8") as f:
f.write(rst_contents)


Expand Down
34 changes: 18 additions & 16 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
import os
import sys
from datetime import date
sys.path.insert(0, os.path.abspath('../../src'))
sys.path.append(os.path.abspath('./_ext'))
from _version import __version__

sys.path.insert(0, os.path.abspath("../../src"))
sys.path.append(os.path.abspath("./_ext"))
from _version import __version__

# -- Project information -----------------------------------------------------

project = 'Zowe Client Python SDK'
copyright = f'{date.today().year}, Contributors to the Zowe Project'
author = 'Contributors to the Zowe Project'
project = "Zowe Client Python SDK"
copyright = f"{date.today().year}, Contributors to the Zowe Project"
author = "Contributors to the Zowe Project"

# The full version, including alpha/beta/rc tags
release = __version__
Expand All @@ -33,12 +33,14 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.napoleon',
'sphinx_rtd_theme',
'sphinxcontrib.spelling',
'zowe_autodoc']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.napoleon",
"sphinx_rtd_theme",
"sphinxcontrib.spelling",
"zowe_autodoc",
]

# Napoleon options
napoleon_google_docstring = False
Expand All @@ -56,7 +58,7 @@


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -69,11 +71,11 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

html_logo = '_static/zowe-white.png'
html_logo = "_static/zowe-white.png"
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.black]
line-length = 120

[tool.isort]
profile = "black"
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
black
certifi==2023.7.22
chardet==4.0.0
colorama==0.4.4
commentjson==0.9.0
coverage==5.4
deepmerge==1.1.0
flake8==3.8.4
idna==2.10
importlib-metadata==3.6.0
isort
jsonschema==4.17.3
keyring
lxml==4.9.3
Expand All @@ -24,10 +27,9 @@ six==1.15.0
snowballstemmer==2.1.0
typing-extensions==4.0.1
Unidecode==1.2.0
urllib3==1.26.5
urllib3==1.26.17
wheel
zipp==3.4.0
black
-e ./src/core
-e ./src/zos_console
-e ./src/zos_files
Expand Down
11 changes: 3 additions & 8 deletions samples/SampleConsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

# Change <xxxx> below to the name of your zosmf profile

connection = {
"plugin_profile": "xxxx"
}
connection = {"plugin_profile": "xxxx"}

my_console = Console(connection)
command = 'D IPLINFO'
command = "D IPLINFO"
command_result = my_console.issue_command(command)
command_output = command_result['cmd-response'].replace('\r','\n')
command_output = command_result["cmd-response"].replace("\r", "\n")

print(f"Command: {command} \n Output: \n\n{command_output}")



15 changes: 6 additions & 9 deletions samples/SampleFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@

# Change <xxxx> below to the name of your zosmf profile

connection = {
"plugin_profile": "xxxx"
}
connection = {"plugin_profile": "xxxx"}

# -----------------------------------------------------
# print list of zos datasets
# -----------------------------------------------------
# -----------------------------------------------------
print("...SYS1 datasets\n")
my_files = Files(connection)
my_dsn_list = my_files.list_dsn("SYS1.**.*")
datasets = my_dsn_list['items']
datasets = my_dsn_list["items"]
for ds in datasets:
print(ds['dsname'])
print(ds["dsname"])

# -----------------------------------------------------
# Now try the uss side... Not in the SDK in GitHub yet

# -----------------------------------------------------
# -----------------------------------------------------
print("...files in /etc\n")
my_file_list = my_files.list_files("/etc")
files = my_file_list["items"]
Expand All @@ -28,8 +26,7 @@

# -----------------------------------------------------
# Get the content of one of the files.
# -----------------------------------------------------
# -----------------------------------------------------
print("...content of a file\n")
my_file_content = my_files.get_file_content("/z/tm891807/file.txt")
print(my_file_content["response"])

36 changes: 17 additions & 19 deletions samples/SampleJobs.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
from zowe.zos_jobs_for_zowe_sdk import Jobs
import time
import os
import time

from zowe.zos_jobs_for_zowe_sdk import Jobs

# -----------------------------------------------------
# Test drive the jobs SDK with jcl from a file
# -----------------------------------------------------
# -----------------------------------------------------
# Change <xxxx> below to the name of your zosmf profile

connection = {
"plugin_profile": "xxxx"
}
connection = {"plugin_profile": "xxxx"}


print("...Submit a sleeper job\n")
my_jobs = Jobs(connection)
job = my_jobs.submit_from_local_file("jcl\sleep.jcl")
job_name = job['jobname']
job_id = job['jobid']
job_name = job["jobname"]
job_id = job["jobid"]
print(f"Job {job_name} ID {job_id} submitted")

# -----------------------------------------------------
# Wait until the job completes
# -----------------------------------------------------
# -----------------------------------------------------

boolJobNotDone = True
while boolJobNotDone:
status = my_jobs.get_job_status(job_name,job_id)
job_status = status['status']
if job_status != 'OUTPUT':
status = my_jobs.get_job_status(job_name, job_id)
job_status = status["status"]
if job_status != "OUTPUT":
print(f"Status {job_status}")
time.sleep(5)
else:
boolJobNotDone = False

# -----------------------------------------------------
# Get the return code
# -----------------------------------------------------
job_retcode = status['retcode']
job_correlator = status['job-correlator']
# Get the return code
# -----------------------------------------------------
job_retcode = status["retcode"]
job_correlator = status["job-correlator"]
print(f"Job {job_name} ID {job_id} ended with {job_retcode}")

# -----------------------------------------------------
# Get all the spool files and dump them in <output_dir>
# -----------------------------------------------------
output_dir = './output'
my_jobs.get_job_output_as_files(status,output_dir)
# -----------------------------------------------------
output_dir = "./output"
my_jobs.get_job_output_as_files(status, output_dir)
4 changes: 3 additions & 1 deletion src/core/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys
from setuptools import setup, find_namespace_packages

from setuptools import find_namespace_packages, setup

sys.path.append("..")
from _version import __version__

Expand Down
6 changes: 3 additions & 3 deletions src/core/zowe/core_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
Zowe Python SDK - Core package
"""

from .config_file import ConfigFile
from .connection import ApiConnection
from .constants import constants
from .credential_manager import CredentialManager
from .exceptions import *
from .profile_manager import ProfileManager
from .request_handler import RequestHandler
from .sdk_api import SdkApi
from .session_constants import *
from .session import Session
from .session_constants import *
from .zosmf_profile import ZosmfProfile
from .config_file import ConfigFile
from .credential_manager import CredentialManager
Loading

0 comments on commit 0f2eda8

Please sign in to comment.