Added workspace handling to live dev server
This commit is contained in:
parent
3ba5c10fad
commit
4009c93353
@ -83,6 +83,10 @@ class LiveServerService(FileSystemEventHandler):
|
|||||||
:param args:
|
:param args:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
if self._build_settings.main == '':
|
||||||
|
Console.error('Project has no entry point.')
|
||||||
|
return
|
||||||
|
|
||||||
self._args = args
|
self._args = args
|
||||||
Console.write_line('** CPL live development server is running **')
|
Console.write_line('** CPL live development server is running **')
|
||||||
self._start()
|
self._start()
|
||||||
|
@ -38,7 +38,13 @@ class LiveServerThread(threading.Thread):
|
|||||||
Starts the CPL project
|
Starts the CPL project
|
||||||
:return:
|
: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')
|
self._main = os.path.join(self._path, f'{main}.py')
|
||||||
if not os.path.isfile(self._main):
|
if not os.path.isfile(self._main):
|
||||||
Console.error('Entry point main.py not found')
|
Console.error('Entry point main.py not found')
|
||||||
@ -53,11 +59,11 @@ class LiveServerThread(threading.Thread):
|
|||||||
|
|
||||||
env_vars = os.environ
|
env_vars = os.environ
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)};' \
|
env_vars['PYTHONPATH'] = f'{os.path.dirname(src_path)};' \
|
||||||
f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}'
|
f'{os.path.join(os.path.dirname(src_path), self._build_settings.source_path)}'
|
||||||
else:
|
else:
|
||||||
env_vars['PYTHONPATH'] = f'{os.path.dirname(self._path)}:' \
|
env_vars['PYTHONPATH'] = f'{os.path.dirname(src_path)}:' \
|
||||||
f'{os.path.join(os.path.dirname(self._path), self._build_settings.source_path)}'
|
f'{os.path.join(os.path.dirname(src_path), self._build_settings.source_path)}'
|
||||||
|
|
||||||
self._command = [sys.executable, self._main, ''.join(self._args)]
|
self._command = [sys.executable, self._main, ''.join(self._args)]
|
||||||
subprocess.run(self._command, env=env_vars)
|
subprocess.run(self._command, env=env_vars)
|
||||||
|
Loading…
Reference in New Issue
Block a user