From e46dd3fef49e9cb2a5a63da808347a11c84c85f2 Mon Sep 17 00:00:00 2001 From: Stefan Vogel Date: Tue, 11 Feb 2025 13:00:14 +0100 Subject: [PATCH] Remove Jira --- README.md | 3 +- doc/uml/architecture.puml | 10 - doc/uml/deployment.puml | 20 +- doc/uml/overview.puml | 7 +- pyproject.toml | 1 - requirements-dev.txt | 3 +- requirements.txt | 3 +- src/pyProfileMgr/cmd_profile.py | 85 ++---- src/pyProfileMgr/jira_server.py | 440 -------------------------------- src/pyProfileMgr/profile_mgr.py | 21 +- src/pyProfileMgr/ret.py | 2 - 11 files changed, 34 insertions(+), 561 deletions(-) delete mode 100644 src/pyProfileMgr/jira_server.py diff --git a/README.md b/README.md index 48f9ab0..e01ac5c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ pyProfileMgr is a Python module containing the Profile Manager component. It also provides CLI access for reading, writing, listing and updating profiles. -A profile can store Jira, Polarion and Superset server, credentials and certificate data. +A profile contains server URL, type, credentials (token or username/password) and certificate data. [![License](https://img.shields.io/badge/license-bsd-3.svg)](https://choosealicense.com/licenses/bsd-3-clause/) [![Repo Status](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip) [![CI](https://github.com/NewTec-GmbH/pyProfileMgr/actions/workflows/test.yml/badge.svg)](https://github.com/NewTec-GmbH/pyProfileMgr/actions/workflows/test.yml) @@ -43,7 +43,6 @@ Used 3rd party libraries which are not part of the standard Python package: | Library | Description | License | | ------- | ----------- | ------- | | [colorama](https://github.com/tartley/colorama) | ANSI color support | BSD-3 License | -| [jira](https://pypi.org/project/jira/) | Python library for interacting with JIRA via REST APIs | BSD License (BSD-2-Clause) | | [toml](https://github.com/uiri/toml) | Parsing [TOML](https://en.wikipedia.org/wiki/TOML) | MIT | Sections below, for Github only diff --git a/doc/uml/architecture.puml b/doc/uml/architecture.puml index c2878ee..7963d1c 100644 --- a/doc/uml/architecture.puml +++ b/doc/uml/architecture.puml @@ -2,27 +2,17 @@ package "pyProfileMgr" { component "Main entry point" as main - component "Jira server" as jira_server component "Profile command" <> as cmd_profile component "Profile manager" as profile_mgr } -package "Python Jira" { - component "jira.client.JIRA" as jira -} - package "Python" as python { component "Argparse" as argparse component "Requests" as requests } main o--> cmd_profile -cmd_profile o--> jira_server cmd_profile o--> profile_mgr -jira_server o--> profile_mgr main *--> argparse -jira_server *--> jira -jira *--> requests - @enduml diff --git a/doc/uml/deployment.puml b/doc/uml/deployment.puml index fc3e036..7eedf48 100644 --- a/doc/uml/deployment.puml +++ b/doc/uml/deployment.puml @@ -1,36 +1,20 @@ @startuml DeploymentDiagram -node "Jira" <> as jira_vm { - node "Jira server" as jira_server { - database "Jira database" as jira_db - } - - interface "Jira REST API" as jira_rest_api - jira_server -- jira_rest_api -} - node "Continuous integration server" <> { package "Scripts" { component "pyJiraCli" as jira_cli #White component "pyMetricCli" as metric_cli #White component "pyProfileMgr" as profile_mgr + ProfileMgr - [profile_mgr] } folder Filesystem { file "Profile data" as profile_data_files } - ProfileMgr - [profile_mgr] - jira_cli -> ProfileMgr + jira_cli --> ProfileMgr metric_cli --> ProfileMgr profile_mgr -- profile_data_files } -jira_rest_api )-- profile_mgr - -' Notes -note top of jira_server - Issue tracking system -end note - @enduml diff --git a/doc/uml/overview.puml b/doc/uml/overview.puml index f6e2c63..8ae0f17 100644 --- a/doc/uml/overview.puml +++ b/doc/uml/overview.puml @@ -1,4 +1,4 @@ -@startuml pyJiraCli_components +@startuml pyProfileMgr_components top to bottom direction skinparam Linetype ortho @@ -14,10 +14,6 @@ package "pyProfileMgr" { profile_data .down...> cmd_profile : <> -database "Jira server" as jira_server { - file "Jira issue" as jira_issue -} - folder Filesystem { file "Profile data" as profile_data_files } @@ -26,7 +22,6 @@ main .down.> cmd_profile : <> cmd_profile ...down.> profile_mgr : <>\n<> profile_mgr ...down.> profile_data_files : <>\n<> -profile_mgr .down...> jira_server : <> 'Notes note top of profile_data diff --git a/pyproject.toml b/pyproject.toml index 122a125..287aba9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ classifiers = [ dependencies = [ "colorama>=0.4.6", - "jira>=3.8.0", "toml>=0.10.2" ] diff --git a/requirements-dev.txt b/requirements-dev.txt index eb6455d..5a1e4ba 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,4 @@ colorama==0.4.6 -jira==3.8.0 m2r>=0.3.1 myst-parser>=4.0.0 pyinstaller>=6.11.1 @@ -11,4 +10,4 @@ sphinx-rtd-theme>=3.0.1 Sphinx>=8.1.3 sphinxcontrib-plantuml>=0.30 toml>=0.10.2 -tomlkit>=0.13.2 \ No newline at end of file +tomlkit>=0.13.2 diff --git a/requirements.txt b/requirements.txt index e993001..dc2451b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ colorama==0.4.6 -jira==3.8.0 -toml==0.10.2 \ No newline at end of file +toml==0.10.2 diff --git a/src/pyProfileMgr/cmd_profile.py b/src/pyProfileMgr/cmd_profile.py index ce2743d..e68d87a 100644 --- a/src/pyProfileMgr/cmd_profile.py +++ b/src/pyProfileMgr/cmd_profile.py @@ -1,7 +1,7 @@ """ Command for the profile function. - This module can add, remove or configure server profiles. + This module can add, remove, modify and list server profiles. The profiles contain server url, login data, the server certificate - and configuration data for a specific jira server instance. + and configuration data for a specific server instance. """ # BSD 3-Clause License # @@ -38,9 +38,7 @@ import argparse from pyProfileMgr.profile_mgr import ProfileMgr -from pyProfileMgr.profile_mgr import ProfileType -from pyProfileMgr.jira_server import Server from pyProfileMgr.printer import Printer, PrintType from pyProfileMgr.ret import Ret @@ -102,7 +100,7 @@ def register(subparser) -> argparse.ArgumentParser: type=str, metavar='', required=True, - help="The Jira server URL to connect to." + help="The server URL to connect to." ) sub_parser_add.add_argument( @@ -111,7 +109,7 @@ def register(subparser) -> argparse.ArgumentParser: type=str, metavar='', required=False, - help="The token to authenticate at the Jira server." + help="The token to authenticate at the server." ) sub_parser_add.add_argument( @@ -120,7 +118,7 @@ def register(subparser) -> argparse.ArgumentParser: type=str, metavar='', required=False, - help="The user to authenticate at the Jira server." + help="The user to authenticate at the server." ) sub_parser_add.add_argument( @@ -129,7 +127,7 @@ def register(subparser) -> argparse.ArgumentParser: type=str, metavar='', required=False, - help="The password to authenticate at the Jira server." + help="The password to authenticate at the server." ) sub_parser_add.add_argument( @@ -182,7 +180,7 @@ def register(subparser) -> argparse.ArgumentParser: type=str, required=False, metavar='', - help="The Jira server URL to connect to." + help="The server URL to connect to." ) sub_parser_update.add_argument( @@ -191,7 +189,7 @@ def register(subparser) -> argparse.ArgumentParser: type=str, required=False, metavar='', - help="The token to authenticate with the Jira server." + help="The token to authenticate with the server." ) sub_parser_update.add_argument( @@ -200,7 +198,7 @@ def register(subparser) -> argparse.ArgumentParser: type=str, required=False, metavar='', - help="The user to authenticate at the Jira server." + help="The user to authenticate at the server." ) sub_parser_update.add_argument( @@ -209,7 +207,7 @@ def register(subparser) -> argparse.ArgumentParser: type=str, required=False, metavar='', - help="The password to authenticate at the Jira server." + help="The password to authenticate at the server." ) sub_parser_update.add_argument( @@ -253,20 +251,12 @@ def _profile_add(args) -> Ret.CODE: ret_status = Ret.CODE.RET_OK # Do not overwrite existing profiles. - profile_handler = ProfileMgr() - profile_list = profile_handler.get_profiles() + profile_mgr = ProfileMgr() + profile_list = profile_mgr.get_profiles() if args.profile_name in profile_list: - ret_status = Ret.CODE.RET_ERROR_PROFILE_ALREADY_EXISTS + return Ret.CODE.RET_ERROR_PROFILE_ALREADY_EXISTS - # Buffer profile name so the check can be run without it. - if ret_status is Ret.CODE.RET_OK: - temp_profile_name = args.profile_name - args.profile_name = None - ret_status = _check_jira_profile(args) - args.profile_name = temp_profile_name - - if ret_status is Ret.CODE.RET_OK: - ret_status = _add_profile(args) + ret_status = _add_profile(args) return ret_status @@ -307,36 +297,7 @@ def _profile_update(args) -> Ret.CODE: Returns: Ret.CODE: The return status of the module. """ - ret_status = _check_jira_profile(args) - - if ret_status is Ret.CODE.RET_OK: - ret_status = _update_profile(args) - - return ret_status - - -def _check_jira_profile(args) -> Ret.CODE: - """ Checks whether the profile information is valid by login to Jira. - - Returns: - Ret.CODE: If successful it will return Ret.CODE.RET_OK otherwise a error. - """ - - # Check if the profile type is 'jira' if given (note that not all - # commands require a profile type, so it is not mandatory). - if (args.profile_type is not None) and (args.profile_type != ProfileType.JIRA): - return Ret.CODE.RET_ERROR_INVALID_PROFILE_TYPE - - server = Server() - # Login to the server (prefer token over user/password). - if args.token is not None: - ret_status = server.login( - args.profile_name, args.server, args.token, None, None) - else: - ret_status = server.login( - args.profile_name, args.server, None, args.user, args.password) - - return ret_status + return _update_profile(args) def _add_profile(args) -> Ret.CODE: @@ -349,7 +310,7 @@ def _add_profile(args) -> Ret.CODE: Ret.CODE: Status code indicating the success or failure of the profile addition. """ ret_status = Ret.CODE.RET_OK - _profile = ProfileMgr() + profile_mgr = ProfileMgr() if args.server is None: ret_status = Ret.CODE.RET_ERROR_NO_SERVER_URL @@ -367,7 +328,7 @@ def _add_profile(args) -> Ret.CODE: user = args.user password = args.password certificate = args.cert - ret_status = _profile.add( + ret_status = profile_mgr.add( profile_name, profile_type, server, token, user, password, certificate) return ret_status @@ -380,11 +341,10 @@ def _list_profiles() -> Ret.CODE: Ret.CODE: Status code indicating the success or failure of the command. """ ret_status = Ret.CODE.RET_OK - profile_handler = ProfileMgr() - profile_list = profile_handler.get_profiles() - print("Profiles:") + profile_list = ProfileMgr().get_profiles() + print("Profiles:") for profile_name in profile_list: print(f"\t{profile_name}") @@ -418,11 +378,12 @@ def _update_profile(args) -> Ret.CODE: """ # Update cert if args.cert is not None: - _profile = ProfileMgr() - ret_status = _profile.load(args.profile_name) + profile_mgr = ProfileMgr() + ret_status = profile_mgr.load(args.profile_name) if ret_status == Ret.CODE.RET_OK: # profile exists - ret_status = _profile.add_certificate(args.profile_name, args.cert) + ret_status = profile_mgr.add_certificate( + args.profile_name, args.cert) return ret_status diff --git a/src/pyProfileMgr/jira_server.py b/src/pyProfileMgr/jira_server.py deleted file mode 100644 index e7b26e1..0000000 --- a/src/pyProfileMgr/jira_server.py +++ /dev/null @@ -1,440 +0,0 @@ -"""Jira server connection module""" - -# BSD 3-Clause License -# -# Copyright (c) 2024 - 2025, NewTec GmbH -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -################################################################################ -# Imports -################################################################################ -import os -import sys -from typing import Optional - -import certifi -import urllib3 - -from jira import JIRA, exceptions -from requests import exceptions as reqex -from urllib3 import exceptions as urlex - -from pyProfileMgr.profile_mgr import ProfileMgr - -from pyProfileMgr.printer import Printer, PrintType -from pyProfileMgr.ret import Ret, Warnings - -# pylint: disable=E0401 -if os.name == 'nt': - import msvcrt -else: - import tty - import termios -# pylint: enable=E0401 - -################################################################################ -# Variables -################################################################################ - -################################################################################ -# Classes -################################################################################ - - -class Server: - """This class handles connection to the Jira server. - - Args: - timeout (float): The timeout for the requests in seconds. Default is 10 seconds. - Shorter timeout can result in failed requests, - depending on the speed of the server and the size of the request. - """ - - def __init__(self, timeout: float = 10): - self._jira_obj = None - self._search_result = None - self._cert_path = None - self._server_url = None - self._user = None - self._max_retries = 0 - self._timeout = timeout - - urllib3.disable_warnings() - - # pylint: disable=R0913, R0917 - def login(self, - arg_profile_name: Optional[str], - arg_server_url: Optional[str], - arg_token: Optional[str], - arg_username: Optional[str], - arg_password: Optional[str]) -> Ret.CODE: - """ Login to Jira server with user info or login info from - stored token or user file. - - Args: - arg_profile_name (str): The server profile that shall be used. - arg_server_url (str): The URL of the server to log in to. - arg_token (str): The API token used for authentication. - arg_username (str): The username for authentication. - arg_password (str): The password for authentication. - - returns: - Ret: Returns Ret.CODE.RET_OK if successful or else the corresponding error code. - """ - ret_status = Ret.CODE.RET_OK - _printer = Printer() - - # Login using settings from profile - if arg_profile_name is not None: - ret_status = self._login_using_profile(arg_profile_name) - - # Else login with command line parameters - elif arg_server_url is not None: - - ret_status = self._login_using_direct_args( - arg_server_url, arg_token, arg_username, arg_password) - - else: - # Neither profile nor command line information given - ret_status = Ret.CODE.RET_ERROR - print("Missing server URL to connect to.") - _printer.print_error( - PrintType.ERROR, Ret.CODE.RET_ERROR_JIRA_LOGIN) - - if Ret.CODE.RET_OK == ret_status: - if self._user is not None: - _printer.print_info( - 'Login successful. Logged in as: ', self._user) - else: - _printer.print_info('Login successful.') - - return ret_status - - def get_handle(self) -> JIRA: - """ Return the handle to the jira rest api. - - Returns: - JIRA: The jira object. - """ - return self._jira_obj - - def search(self, search_str: str, max_results: int, fields: list[str]) -> Ret.CODE: - """ Search for jira issues with a search string. - The maximum of found issues can be set. - - Args: - search_str (str): The string by which to search issues for. - max_results (int): The maximum number of search results. - fields (list[str]): The fields to search for in the work items. - - Returns: - Ret.CODE: Returns Ret.CODE.RET_OK if successful or else the corresponding error code. - """ - - ret_status = Ret.CODE.RET_OK - - if self._jira_obj is None: - ret_status = Ret.CODE.RET_ERROR - - else: - try: - self._search_result = self._jira_obj.search_issues(search_str, - maxResults=max_results, - fields=fields) - - except exceptions.JIRAError as e: - print(e.text) - ret_status = Ret.CODE.RET_ERROR_INVALID_SEARCH - - return ret_status - - def get_search_result(self) -> list: - """ Return the results from a - successful search. - - Returns: - list: A list with all the found issues from the last search. - """ - return self._search_result - - def _login_using_profile(self, profile_name: str) -> Ret.CODE: - ''' Login to Jira server using the profile settings.''' - _printer = Printer() - _profile_mgr = ProfileMgr() - - ret_status = _profile_mgr.load(profile_name) - - if ret_status == Ret.CODE.RET_OK: - self._cert_path = _profile_mgr.get_cert_path() - self._server_url = _profile_mgr.get_server_url() - api_token = _profile_mgr.get_api_token() - - _printer.print_info('Logging in to Jira server:', self._server_url) - - if self._cert_path is None: - _printer.print_error( - PrintType.WARNING, Warnings.CODE.WARNING_UNSAVE_CONNECTION) - - # Use token (preferred) - if api_token is not None: - _printer.print_info('Using token for login.') - - ret_status = self._login_with_token(api_token) - # Else user/password - else: - _printer.print_info('Using user/password for login.') - - self._user = _profile_mgr.get_user() - password = _profile_mgr.get_password() - - ret_status = self._login_with_password(self._user, password) - - return ret_status - - def _login_using_direct_args(self, server_url: str, - token: str, username: str, password: str) -> Ret.CODE: - ''' Login to Jira server using the command line arguments directly. ''' - self._server_url = server_url - - _printer = Printer() - ret_status = Ret.CODE.RET_OK - - if self._cert_path is None: - _printer.print_error( - PrintType.WARNING, Warnings.CODE.WARNING_UNSAVE_CONNECTION) - - _printer.print_info('Login in to:', self._server_url) - - if token is not None: - # Login with token - ret_status = self._login_with_token(token) - elif (username is not None) and (password is not None): - # Login with user and password - ret_status = self._login_with_password( - username, password) - else: - # No credentials given - ret_status = Ret.CODE.RET_ERROR - print("Missing credentials (token or user/password) to login.") - _printer.print_error( - PrintType.ERROR, Ret.CODE.RET_ERROR_JIRA_LOGIN) - - return ret_status - - def _login_with_token(self, token: str) -> Ret.CODE: - """ Login to jira with API token. - - Args: - token (str): The API token for login. - - Returns: - Ret.CODE: Returns Ret.CODE.RET_OK if successful or else the corresponding error code. - """ - - user = None - ret_status = Ret.CODE.RET_OK - - os.environ["SSL_CERT_FILE"] = certifi.where() - - try: - if self._cert_path is None: - self._jira_obj = JIRA(server=self._server_url, - options={'verify': False}, - token_auth=token, - max_retries=self._max_retries, - timeout=self._timeout) - else: - self._jira_obj = JIRA(server=self._server_url, - options={'verify': self._cert_path}, - token_auth=token, - max_retries=self._max_retries, - timeout=self._timeout) - - user = self._jira_obj.current_user() - - self._jira_obj.verify_ssl = False - - except (exceptions.JIRAError, - urlex.MaxRetryError, - reqex.ConnectionError, - reqex.MissingSchema, - reqex.InvalidSchema, - reqex.InvalidURL) as e: - # print error - ret_status = Ret.CODE.RET_ERROR_JIRA_LOGIN - - if isinstance(e, exceptions.JIRAError): - print(e.text) - - elif isinstance(e, (reqex.InvalidSchema, - reqex.MissingSchema, - reqex.InvalidURL)): - ret_status = Ret.CODE.RET_ERROR_INVALID_URL - - else: - print(str(e)) - - if user is None: - ret_status = Ret.CODE.RET_ERROR_JIRA_LOGIN - - self._user = user - - return ret_status - - def _login_with_password(self, user: str, pw: str) -> Ret.CODE: - """ Login to jira with username and password. - - Args: - user (str): Username for login. - pw (str): Password for login. - - Returns: - Ret.CODE: Returns Ret.CODE.RET_OK if successful or else the corresponding error code. - """ - - ret_status = Ret.CODE.RET_OK - - os.environ["SSL_CERT_FILE"] = certifi.where() - - try: - if self._cert_path is None: - self._jira_obj = JIRA(server=self._server_url, - basic_auth=(user, pw), - options={'verify': False}, - max_retries=self._max_retries, - timeout=self._timeout) - else: - self._jira_obj = JIRA(server=self._server_url, - basic_auth=(user, pw), - options={'verify': self._cert_path}, - max_retries=self._max_retries, - timeout=self._timeout) - - user = self._jira_obj.current_user() - - self._jira_obj.verify_ssl = False - - except (exceptions.JIRAError, - urlex.MaxRetryError, - reqex.ConnectionError, - reqex.MissingSchema, - reqex.InvalidSchema, - reqex.InvalidURL) as e: - # print error - ret_status = Ret.CODE.RET_ERROR_JIRA_LOGIN - - if isinstance(e, exceptions.JIRAError): - print(e.text) - - elif isinstance(e, (reqex.InvalidSchema, - reqex.MissingSchema, - reqex.InvalidURL)): - ret_status = Ret.CODE.RET_ERROR_INVALID_URL - - else: - print(str(e)) - - self._user = user - - return ret_status - -################################################################################ -# Functions -################################################################################ - - -def _get_user_credentials() -> tuple[str, str]: - """Prompt the user to enter a username and a password. - The password input is masked with '*' characters. - - Returns: - tuple[str, str]: A tuple containing the username and the password. - """ - username = input("Enter your username: ") - - print("Enter your password: ", end="", flush=True) - password = _get_password() - print('\r', end='') - - return username, password - - -if os.name == 'nt': - def _get_password() -> str: - """Prompt the user to enter a password with '*' masking for Windows. - - Returns: - str: The entered password. - """ - - password = "" - while True: - char = msvcrt.getch() - if char in {b'\n', b'\r'}: - break - - if char == b'\x08': # Backspace - if len(password) > 0: - password = password[:-1] - sys.stdout.write('\b \b') - else: - password += char.decode('utf-8') - sys.stdout.write('*') - sys.stdout.flush() - print() - return password - -else: - def _get_password() -> str: - """Prompt the user to enter a password with '*' masking for Unix-based systems. - - Returns: - str: The entered password. - """ - - fd = sys.stdin.fileno() - old_settings = termios.tcgetattr(fd) - try: - tty.setraw(fd) - password = "" - while True: - char = sys.stdin.read(1) - if char in ('\n', '\r'): - break - - if char == '\b' or ord(char) == 127: - if len(password) > 0: - password = password[:-1] - sys.stdout.write('\b \b') - else: - password += char - sys.stdout.write('*') - sys.stdout.flush() - print() - finally: - termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) - return password diff --git a/src/pyProfileMgr/profile_mgr.py b/src/pyProfileMgr/profile_mgr.py index 00bff1a..cba889f 100644 --- a/src/pyProfileMgr/profile_mgr.py +++ b/src/pyProfileMgr/profile_mgr.py @@ -52,6 +52,7 @@ class StrEnum(str, Enum): from pyProfileMgr.ret import Ret, Warnings from pyProfileMgr.printer import Printer, PrintType + ################################################################################ # Variables ################################################################################ @@ -84,7 +85,7 @@ class ProfileType(StrEnum): class ProfileMgr: """ The ProfileMgr class handles all processes regarding server profiles. - This includes adding, deleting or configuring profile data. + This includes adding, deleting or configuring profile data. """ def __init__(self): @@ -97,6 +98,7 @@ def __init__(self): self._profile_cert = None # pylint: disable=R0912, R0913, R0917 + def add(self, profile_name: str, profile_type: ProfileType, @@ -127,7 +129,7 @@ def add(self, SERVER_URL_KEY: server_url, } - # Check if the token is provided and add it to the profile. + # If the token is provided, add it to the profile. if token is not None: write_dict[TOKEN_KEY] = token # Else require user/password for authentication. @@ -313,19 +315,6 @@ def load(self, profile_name: str) -> Ret.CODE: return ret_status - def get_config_data(self) -> dict: - """ This function will format and return all available config data so that it can - be used by the other modules. - - Returns: - dict: A dictionary containing all formatted configuration data. - """ - config_dict = {} - - # code goes here - - return config_dict - def delete(self, profile_name: str) -> None: """_summary_ @@ -405,11 +394,11 @@ def get_profiles(self) -> [str]: return profile_names + ################################################################################ # Functions ################################################################################ - def _add_new_profile(write_dict: dict, profile_path: str, cert_path: str) -> Ret.CODE: """ Adds a new server profile to the configuration. diff --git a/src/pyProfileMgr/ret.py b/src/pyProfileMgr/ret.py index 2690742..0e486fc 100644 --- a/src/pyProfileMgr/ret.py +++ b/src/pyProfileMgr/ret.py @@ -62,7 +62,6 @@ class CODE(IntEnum): RET_ERROR_CREATING_TICKET_FAILED = 10 RET_ERROR_INVALID_SEARCH = 11 RET_ERROR_INVALID_URL = 12 - RET_ERROR_JIRA_LOGIN = 13 RET_ERROR_BOARD_NOT_FOUND = 14 RET_ERROR_PROFILE_ALREADY_EXISTS = 15 RET_ERROR_INVALID_PROFILE_TYPE = 16 @@ -84,7 +83,6 @@ class CODE(IntEnum): CODE.RET_ERROR_CREATING_TICKET_FAILED: "creating the ticket on the Jira server failed", CODE.RET_ERROR_INVALID_SEARCH: "search string returned a Jira error", CODE.RET_ERROR_INVALID_URL: "The provided server url is invalid", - CODE.RET_ERROR_JIRA_LOGIN: "Login to Jira server was not possible", CODE.RET_ERROR_BOARD_NOT_FOUND: "The Jira board does not exist or " + "you have no access to it.", CODE.RET_ERROR_PROFILE_ALREADY_EXISTS: "The profile you want to add already exists.\n" +