2021.4.post1 #31

Merged
edraft merged 92 commits from 2021.4.post1 into master 2021-05-19 09:00:40 +02:00
2 changed files with 15 additions and 5 deletions
Showing only changes of commit 4009c93353 - Show all commits

View File

@ -83,6 +83,10 @@ class LiveServerService(FileSystemEventHandler):
:param args:
:return:
"""
if self._build_settings.main == '':
Console.error('Project has no entry point.')
return
self._args = args
Console.write_line('** CPL live development server is running **')
self._start()

View File

@ -38,7 +38,13 @@ class LiveServerThread(threading.Thread):
Starts the CPL project
:return:
"""
main = self._build_settings.main.replace('.', '/')
src_path = ''
main = self._build_settings.main
if '.' in self._build_settings.main:
length = len(self._build_settings.main.split('.')) - 1
src_path = self._path.replace(f'{"/".join(self._build_settings.main.split(".")[:length])}/', '')
main = self._build_settings.main.split('.')[length]
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')
@ -53,11 +59,11 @@ class LiveServerThread(threading.Thread):
env_vars = os.environ
if sys.platform == 'win32':
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)};' \
f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}'
env_vars['PYTHONPATH'] = f'{os.path.dirname(src_path)};' \
f'{os.path.join(os.path.dirname(src_path), self._build_settings.source_path)}'
else:
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)}:' \
f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}'
env_vars['PYTHONPATH'] = f'{os.path.dirname(src_path)}:' \
f'{os.path.join(os.path.dirname(src_path), self._build_settings.source_path)}'
self._command = [sys.executable, self._main, ''.join(self._args)]
subprocess.run(self._command, env=env_vars)