2021.4 #19

Merged
edraft merged 237 commits from 2021.4 into master 2021-04-01 10:13:33 +02:00
34 changed files with 156 additions and 103 deletions
Showing only changes of commit 7ffd553709 - Show all commits

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2021",
"Minor": "04",
"Micro": "01-1"
"Micro": "01-2"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
@ -27,6 +27,7 @@
"watchdog==2.0.2"
],
"PythonVersion": ">=3.8",
"PythonPath": "",
"Classifiers": []
},
"BuildSettings": {

View File

@ -15,11 +15,11 @@ __title__ = 'sh_cpl.cpl'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.application'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -28,4 +28,4 @@ from .application_runtime_abc import ApplicationRuntimeABC
from .startup_abc import StartupABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -27,4 +27,4 @@ from .configuration_variable_name_enum import ConfigurationVariableNameEnum
from .console_argument import ConsoleArgument
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.console'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -27,4 +27,4 @@ from .foreground_color_enum import ForegroundColorEnum
from .spinner_thread import SpinnerThread
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.database'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -25,4 +25,4 @@ from .database_settings import DatabaseSettings
from .database_settings_name_enum import DatabaseSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.database.connection'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -24,4 +24,4 @@ from .database_connection import DatabaseConnection
from .database_connection_abc import DatabaseConnectionABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.database.context'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -24,4 +24,4 @@ from .database_context import DatabaseContext
from .database_context_abc import DatabaseContextABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.dependency_injection'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -25,4 +25,4 @@ from .service_provider import ServiceProvider
from .service_provider_abc import ServiceProviderABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.environment'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -25,4 +25,4 @@ from .environment_name_enum import EnvironmentNameEnum
from .application_environment import ApplicationEnvironment
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.logging'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -27,4 +27,4 @@ from .logging_settings import LoggingSettings
from .logging_settings_name_enum import LoggingSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.mailing'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -27,4 +27,4 @@ from .email_client_settings import EMailClientSettings
from .email_client_settings_name_enum import EMailClientSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl.time'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -24,4 +24,4 @@ from .time_format_settings import TimeFormatSettings
from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,13 +15,14 @@ __title__ = 'cpl.utils'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
from .credential_manager import CredentialManager
from .string import String
from .pip import Pip
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -5,12 +5,38 @@ from typing import Optional
class Pip:
_executable = sys.executable
@staticmethod
def get_package(package: str) -> Optional[str]:
"""
Getter
"""
@classmethod
def get_executable(cls) -> str:
return cls._executable
"""
Setter
"""
@classmethod
def set_executable(cls, executable: str):
if executable is not None:
cls._executable = executable
@classmethod
def reset_executable(cls):
cls._executable = sys.executable
"""
Public utils functions
"""
@classmethod
def get_package(cls, package: str) -> Optional[str]:
result = None
with suppress(Exception):
result = subprocess.check_output([sys.executable, "-m", "pip", "show", package], stderr=subprocess.DEVNULL)
result = subprocess.check_output([cls._executable, "-m", "pip", "show", package], stderr=subprocess.DEVNULL)
if result is None:
return None
@ -24,9 +50,13 @@ class Pip:
return f'{package}=={new_version}'
@staticmethod
def install(package: str, *args, source: str = None, stdout=None, stderr=None):
pip_args = [sys.executable, "-m", "pip", "install"]
@classmethod
def get_outdated(cls) -> bytes:
return subprocess.check_output([cls._executable, "-m", "pip", "list", "--outdated"])
@classmethod
def install(cls, package: str, *args, source: str = None, stdout=None, stderr=None, admin=None):
pip_args = [cls._executable, "-m", "pip", "install"]
for arg in args:
pip_args.append(arg)
@ -38,6 +68,6 @@ class Pip:
pip_args.append(package)
subprocess.run(pip_args, stdout=stdout, stderr=stderr)
@staticmethod
def uninstall(package: str, stdout=None, stderr=None):
subprocess.run([sys.executable, "-m", "pip", "uninstall", "--yes", package], stdout=stdout, stderr=stderr)
@classmethod
def uninstall(cls, package: str, stdout=None, stderr=None):
subprocess.run([cls._executable, "-m", "pip", "uninstall", "--yes", package], stdout=stdout, stderr=stderr)

View File

@ -15,7 +15,7 @@ __title__ = 'sh_cpl.cpl_cli'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -29,4 +29,4 @@ from .main import main
from .startup import Startup
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -28,4 +28,4 @@ from .publish_service import PublishService
from .version_service import VersionService
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -1,8 +1,6 @@
import json
import os
import subprocess
import sys
from typing import Optional
from cpl.application import ApplicationRuntimeABC
from cpl.configuration import ConfigurationABC
@ -85,6 +83,7 @@ class InstallService(CommandABC):
is_already_in_project = False
project: ProjectSettings = self._config.get_configuration(ProjectSettings)
build: BuildSettings = self._config.get_configuration(BuildSettings)
Pip.set_executable(project.python_path)
if project is None or build is None:
Error.error('The command requires to be run in an CPL project, but a project could not be found.')
@ -128,6 +127,8 @@ class InstallService(CommandABC):
project_file.write(json.dumps(config, indent=2))
project_file.close()
Pip.reset_executable()
def run(self, args: list[str]):
if len(args) == 0:
self._install_project()

View File

@ -64,6 +64,8 @@ class UninstallService(CommandABC):
Console.error(f'Usage: cpl uninstall <package>')
return
Pip.set_executable(self._project_settings.python_path)
package = args[0]
is_in_dependencies = False
@ -101,6 +103,4 @@ class UninstallService(CommandABC):
project_file.close()
Console.write_line(f'Removed {package}')
Pip.reset_executable()

View File

@ -20,15 +20,7 @@ class UpdateService(CommandABC):
self._project_settings = project_settings
@staticmethod
def _get_outdated() -> bytes:
return subprocess.check_output([sys.executable, "-m", "pip", "list", "--outdated"])
def _update_project_dependencies(self):
for package in self._project_settings.dependencies:
name = package
if '==' in package:
name = package.split('==')[0]
def _install_package(name: str):
if 'sh_cpl' in name:
Pip.install(
name,
@ -49,9 +41,17 @@ class UpdateService(CommandABC):
stderr=subprocess.DEVNULL
)
def _update_project_dependencies(self):
for package in self._project_settings.dependencies:
name = package
if '==' in package:
name = package.split('==')[0]
self._install_package(name)
new_package = Pip.get_package(name)
if new_package is None:
Console.error(f'Invalid name: {name}')
Console.error(f'Update for package {package} failed')
return
self._project_json_update_dependency(package, new_package)
@ -64,9 +64,10 @@ class UpdateService(CommandABC):
)
Console.write_line(f'Found {len(self._project_settings.dependencies)} dependencies.')
def _check_outdated(self):
@staticmethod
def _check_outdated():
table_str: bytes = Console.spinner(
'Analyzing for available package updates', self._get_outdated,
'Analyzing for available package updates', Pip.get_outdated,
text_foreground_color=ForegroundColorEnum.green,
spinner_foreground_color=ForegroundColorEnum.cyan
)
@ -78,7 +79,7 @@ class UpdateService(CommandABC):
Console.write_line(f'\t{row}')
Console.set_foreground_color(ForegroundColorEnum.yellow)
Console.write_line(f'\tUpdate with {sys.executable} -m pip install --upgrade <package>')
Console.write_line(f'\tUpdate with {Pip.get_executable()} -m pip install --upgrade <package>')
Console.set_foreground_color(ForegroundColorEnum.default)
def _project_json_update_dependency(self, old_package: str, new_package: str):
@ -98,8 +99,9 @@ class UpdateService(CommandABC):
project.close()
def run(self, args: list[str]):
# target update discord 1.5.1 to discord 1.6.0
Pip.set_executable(self._project_settings.python_path)
self._check_project_dependencies()
self._check_outdated()
Pip.reset_executable()
Console.write('\n')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -28,4 +28,4 @@ from .version_settings import VersionSettings
from .version_settings_name_enum import VersionSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -1,3 +1,5 @@
import os
import sys
import traceback
from typing import Optional
@ -26,6 +28,7 @@ class ProjectSettings(ConfigurationModelABC):
self._license_description: Optional[str] = None
self._dependencies: Optional[list[str]] = None
self._python_version: Optional[str] = None
self._python_path: Optional[str] = None
self._classifiers: Optional[list[str]] = None
@property
@ -80,6 +83,10 @@ class ProjectSettings(ConfigurationModelABC):
def python_version(self) -> str:
return self._python_version
@property
def python_path(self) -> str:
return self._python_path
@property
def classifiers(self) -> list[str]:
return self._classifiers
@ -99,6 +106,15 @@ class ProjectSettings(ConfigurationModelABC):
self._license_description = settings[ProjectSettingsNameEnum.license_description.value]
self._dependencies = settings[ProjectSettingsNameEnum.dependencies.value]
self._python_version = settings[ProjectSettingsNameEnum.python_version.value]
path = os.path.abspath(settings[ProjectSettingsNameEnum.python_path.value])
if os.path.isfile(path) or os.path.islink(path):
path = os.path.abspath(path)
else:
path = sys.executable
self._python_path = path
self._classifiers = settings[ProjectSettingsNameEnum.classifiers.value]
except Exception as e:
Console.set_foreground_color(ForegroundColorEnum.red)

View File

@ -15,4 +15,5 @@ class ProjectSettingsNameEnum(Enum):
license_description = 'LicenseDescription'
dependencies = 'Dependencies'
python_version = 'PythonVersion'
python_path = 'PythonPath'
classifiers = 'Classifiers'

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.live_server'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
@ -24,4 +24,4 @@ from .publisher_abc import PublisherABC
from .publisher_service import PublisherService
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.build'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.generate'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console.src'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console.src.tests'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1.post1'
__version__ = '2021.4.1.post2'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01-1')
version_info = VersionInfo(major='2021', minor='04', micro='01-2')

View File

@ -16,9 +16,10 @@
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"sh_cpl==2021.4.1"
"sh_cpl==2021.4.1.post2"
],
"PythonVersion": ">=3.8",
"PythonPath": "../../../../cpl-env/bin/python3.9",
"Classifiers": []
},
"BuildSettings": {