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

Convert windows line ending and previous PR #276

Merged
merged 19 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ All notable changes to the Zowe Client Python SDK will be documented in this fil
### Enhancements

- Added logger class to core SDK [#185](https://github.com/zowe/zowe-client-python-sdk/issues/185)
zFernand0 marked this conversation as resolved.
Show resolved Hide resolved
- Added classes for handling `Datasets`, `USSFiles`, and `FileSystems` in favor of the single Files class. [#264](https://github.com/zowe/zowe-client-python-sdk/issues/264)
zFernand0 marked this conversation as resolved.
Show resolved Hide resolved
- Refactored tests into proper folders and files [#265](https://github.com/zowe/zowe-client-python-sdk/issues/265)
- Fix the bug on `upload_file_to_dsn`. [#104](https://github.com/zowe/zowe-client-python-sdk/issues/104)

## `1.0.0-dev15`

Expand Down
7 changes: 3 additions & 4 deletions src/core/zowe/core_for_zowe_sdk/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import commentjson
import requests

import logging

from .logger import Log
from .credential_manager import CredentialManager
from .custom_warnings import ProfileNotFoundWarning, ProfileParsingWarning
from .exceptions import ProfileNotFound
Expand Down Expand Up @@ -73,7 +72,7 @@ class ConfigFile:
jsonc: Optional[dict] = None
_missing_secure_props: list = field(default_factory=list)

__logger = logging.getLogger(__name__)
__logger = Log.registerLogger(__name__)

@property
def filename(self) -> str:
Expand Down Expand Up @@ -212,7 +211,7 @@ def get_profile(
self.init_from_file(validate_schema)

if profile_name is None and profile_type is None:
self.__logger.error(f"Failed to load profile '{profile_name}' because Could not find profile as both profile_name and profile_type is not set")
self.__logger.error(f"Failed to load profile: profile_name and profile_type were not provided.")
raise ProfileNotFound(
profile_name=profile_name,
error_msg="Could not find profile as both profile_name and profile_type is not set.",
Expand Down
6 changes: 3 additions & 3 deletions src/core/zowe/core_for_zowe_sdk/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

from .exceptions import MissingConnectionArgs
import logging
from .logger import Log


class ApiConnection:
Expand All @@ -30,11 +30,11 @@ class ApiConnection:
"""

def __init__(self, host_url, user, password, ssl_verification=True):
logger = logging.getLogger(__name__)
__logger = Log.registerLogger(__name__)

"""Construct an ApiConnection object."""
if not host_url or not user or not password:
logger.error("Missing connection argument")
__logger.error("Missing connection argument")
raise MissingConnectionArgs()

self.host_url = host_url
Expand Down
4 changes: 2 additions & 2 deletions src/core/zowe/core_for_zowe_sdk/credential_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import commentjson

import logging
from .logger import Log

from .constants import constants
from .exceptions import SecureProfileLoadFailed
Expand All @@ -30,7 +30,7 @@

class CredentialManager:
secure_props = {}
__logger = logging.getLogger(__name__)
__logger = Log.registerLogger(__name__)

@staticmethod
def load_secure_props() -> None:
Expand Down
6 changes: 4 additions & 2 deletions src/core/zowe/core_for_zowe_sdk/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ class Log:
datefmt="%m/%d/%Y %I:%M:%S %p",
)

loggers = []
loggers = set()
zFernand0 marked this conversation as resolved.
Show resolved Hide resolved
@staticmethod
def registerLogger(name: str):
Log.loggers.append(logging.getLogger(name))
logger = logging.getLogger(name)
Log.loggers.add(logger)
return logger

@staticmethod
def setLoggerLevel(level: int):
Expand Down
10 changes: 5 additions & 5 deletions src/core/zowe/core_for_zowe_sdk/profile_manager.py
pem70 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import warnings
from copy import deepcopy
from typing import Optional
import logging
from .logger import Log

import jsonschema
from deepmerge import always_merger
Expand Down Expand Up @@ -59,7 +59,7 @@
self.project_config = ConfigFile(type=TEAM_CONFIG, name=appname)
self.project_user_config = ConfigFile(type=USER_CONFIG, name=appname)

self.__logger = logging.getLogger(__name__)
self.__logger = Log.registerLogger(__name__)
Log.registerLogger(__name__)

self.global_config = ConfigFile(type=TEAM_CONFIG, name=GLOBAL_CONFIG_NAME)
Expand Down Expand Up @@ -179,7 +179,7 @@
NamedTuple (data, name, secure_props_not_found)
"""

logger = logging.getLogger(__name__)
logger = Log.registerLogger(__name__)

cfg_profile = Profile()
try:
Expand All @@ -200,8 +200,8 @@
f"A type checker was asked to check a type it did not have registered, {exc}"
)
except jsonschema.exceptions.UnknownType as exc:
logger.error(f"Unknown type is found in schema_json, exc")
raise jsonschema.exceptions.UnknownType(f"Unknown type is found in schema_json, exc")
logger.error(f"Unknown type is found in schema_json, {exc}")
raise jsonschema.exceptions.UnknownType(f"Unknown type is found in schema_json, {exc}")

Check warning on line 204 in src/core/zowe/core_for_zowe_sdk/profile_manager.py

View check run for this annotation

Codecov / codecov/patch

src/core/zowe/core_for_zowe_sdk/profile_manager.py#L203-L204

Added lines #L203 - L204 were not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

Not sure if we should do a quick search across the board to make sure that we are interpolating/inserting the value of the error instead of the literal string of the variable name

except jsonschema.exceptions.FormatError as exc:
logger.error(f"Validating a format config_json failed for schema_json, {exc}")
raise jsonschema.exceptions.FormatError(f"Validating a format config_json failed for schema_json, {exc}")
Expand Down
4 changes: 2 additions & 2 deletions src/core/zowe/core_for_zowe_sdk/request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import requests
import urllib3
import logging
from .logger import Log

from .exceptions import InvalidRequestMethod, RequestFailed, UnexpectedStatus

Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(self, session_arguments, logger_name = __name__):
self.session_arguments = session_arguments
self.valid_methods = ["GET", "POST", "PUT", "DELETE"]
self.__handle_ssl_warnings()
self.__logger = logging.getLogger(logger_name)
self.__logger = Log.registerLogger(logger_name)

def __handle_ssl_warnings(self):
"""Turn off warnings if the SSL verification argument if off."""
Expand Down
5 changes: 2 additions & 3 deletions src/core/zowe/core_for_zowe_sdk/sdk_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
"""

import urllib
import logging
from .logger import Log

from . import session_constants
from .exceptions import UnsupportedAuthType
from .request_handler import RequestHandler
from .session import ISession, Session

Expand All @@ -29,7 +28,7 @@ def __init__(self, profile, default_url, logger_name = __name__):
session = Session(profile)
self.session: ISession = session.load()

self.logger = logging.getLogger(logger_name)
self.logger = Log.registerLogger(logger_name)

self.default_service_url = default_url
self.default_headers = {
Expand Down
4 changes: 2 additions & 2 deletions src/core/zowe/core_for_zowe_sdk/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from . import session_constants

import logging
from .logger import Log

@dataclass
class ISession:
Expand Down Expand Up @@ -43,7 +43,7 @@ class Session:

def __init__(self, props: dict) -> None:
# set host and port
self.__logger = logging.getLogger(__name__)
self.__logger = Log.registerLogger(__name__)

if props.get("host") is not None:
self.session: ISession = ISession(host=props.get("host"))
Expand Down
2 changes: 1 addition & 1 deletion src/core/zowe/core_for_zowe_sdk/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

import os
from typing import Optional, Union
from typing import Union

import commentjson
import requests
Expand Down
5 changes: 2 additions & 3 deletions src/core/zowe/core_for_zowe_sdk/zosmf_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@

import base64
import os.path
import sys

import yaml

import logging
from .logger import Log

from .connection import ApiConnection
from .constants import constants
Expand Down Expand Up @@ -55,7 +54,7 @@ def __init__(self, profile_name):
The name of the Zowe z/OSMF profile
"""
self.profile_name = profile_name
self.__logger = logging.getLogger(__name__)
self.__logger = Log.registerLogger(__name__)

@property
def profiles_dir(self):
Expand Down
3 changes: 3 additions & 0 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@

from . import constants, exceptions
from .files import Files
from .datasets import Datasets
from .uss import USSFiles
from .file_system import FileSystems
1 change: 1 addition & 0 deletions src/zos_files/zowe/zos_files_for_zowe_sdk/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

zos_file_constants = {
"MaxAllocationQuantity": 16777215,
"ZoweFilesDefaultEncoding": "utf-8",
}
from enum import Enum

Expand Down
Loading
Loading