2021.4 #19

Merged
edraft merged 237 commits from 2021.4 into master 2021-04-01 10:13:33 +02:00
4 changed files with 39 additions and 16 deletions
Showing only changes of commit 960de880ee - Show all commits

View File

@ -9,7 +9,6 @@ from watchdog.observers import Observer
from cpl.console.console import Console
from cpl.environment.application_environment_abc import ApplicationEnvironmentABC
from cpl_cli.configuration.build_settings import BuildSettings
from cpl_cli.configuration.project_type_enum import ProjectTypeEnum
from cpl_cli.live_server.live_server_thread import LiveServerThread
@ -71,7 +70,7 @@ class LiveServerService(FileSystemEventHandler):
def _start(self):
self._start_observer()
self._ls_thread = LiveServerThread(self._src_dir)
self._ls_thread = LiveServerThread(self._src_dir, self._build_settings)
self._ls_thread.start()
self._ls_thread.join()
Console.close()
@ -81,9 +80,5 @@ class LiveServerService(FileSystemEventHandler):
Starts the CPL live development server
:return:
"""
if self._build_settings.project_type == ProjectTypeEnum.library.value:
Console.error(f'Project cannot be a {ProjectTypeEnum.library.value} to be started')
return
Console.write_line('** CPL live development server is running **')
self._start()

View File

@ -6,11 +6,12 @@ from datetime import datetime
from cpl.console.console import Console
from cpl.console.foreground_color_enum import ForegroundColorEnum
from cpl_cli.configuration import BuildSettings
class LiveServerThread(threading.Thread):
def __init__(self, path: str):
def __init__(self, path: str, build_settings: BuildSettings):
"""
Thread to start the CPL project for the live development server
:param path:
@ -18,13 +19,15 @@ class LiveServerThread(threading.Thread):
threading.Thread.__init__(self)
self._path = path
self._build_settings = build_settings
self._main = ''
self._command = []
@property
def command(self) -> list[str]:
return self._command
@property
def main(self) -> str:
return self._main
@ -34,7 +37,8 @@ class LiveServerThread(threading.Thread):
Starts the CPL project
:return:
"""
self._main = os.path.join(self._path, 'main.py')
main = self._build_settings.main.replace('.', '/')
self._main = os.path.join(self._path, f'{main}.py')
if not os.path.isfile(self._main):
Console.error('Entry point main.py not found')
return
@ -46,5 +50,9 @@ class LiveServerThread(threading.Thread):
Console.write_line(f'Started at {now.strftime("%Y-%m-%d %H:%M:%S")}\n\n')
Console.set_foreground_color(ForegroundColorEnum.default)
env_vars = os.environ
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)}:' \
f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}'
self._command = [sys.executable, self._main, ''.join(sys.argv[2:])]
subprocess.run(self._command)
subprocess.run(self._command, env=env_vars)

View File

@ -1,9 +1,6 @@
import importlib
import os
import shutil
import sys
import traceback
from importlib import util
from string import Template as stringTemplate
import setuptools
@ -13,10 +10,8 @@ from setuptools import sandbox
from cpl.console.foreground_color_enum import ForegroundColorEnum
from cpl.console.console import Console
from cpl.environment.application_environment_abc import ApplicationEnvironmentABC
from cpl.utils.string import String
from cpl_cli.configuration.build_settings import BuildSettings
from cpl_cli.configuration.project_settings import ProjectSettings
from cpl_cli.configuration.project_type_enum import ProjectTypeEnum
from cpl_cli.publish.publisher_abc import PublisherABC
from cpl_cli.templates.build.init_template import InitTemplate
from cpl_cli.templates.publish.setup_template import SetupTemplate

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
sh_cpl sh-edraft Common Python library
~~~~~~~~~~~~~~~~~~~
sh-edraft Common Python library
:copyright: (c) 2020 - 2021 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'cpl_cli.templates.new.console.src.name'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.0rc3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='0rc3')