feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
# noqa: INP001
|
2024-03-20 12:55:40 +01:00
|
|
|
import os
|
|
|
|
import subprocess
|
2024-04-07 18:39:27 +02:00
|
|
|
import sys
|
2024-03-20 12:55:40 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import info
|
|
|
|
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Runner
|
|
|
|
####################
|
2024-04-07 18:39:27 +02:00
|
|
|
def run_blender(
|
|
|
|
py_script: Path | None,
|
|
|
|
load_devfile: bool = False,
|
|
|
|
headless: bool = True,
|
|
|
|
monitor: bool = False,
|
|
|
|
):
|
2024-03-20 12:55:40 +01:00
|
|
|
process = subprocess.Popen(
|
2024-04-07 18:39:27 +02:00
|
|
|
[
|
|
|
|
'blender',
|
|
|
|
*(['--background'] if headless else []),
|
|
|
|
*(
|
|
|
|
[
|
|
|
|
'--python',
|
|
|
|
str(py_script),
|
|
|
|
]
|
|
|
|
if py_script is not None
|
|
|
|
else []
|
|
|
|
),
|
|
|
|
*([info.PATH_ADDON_DEV_BLEND] if load_devfile else []),
|
|
|
|
],
|
2024-03-20 12:56:50 +01:00
|
|
|
env=os.environ | {'PYTHONUNBUFFERED': '1'},
|
2024-03-20 12:55:40 +01:00
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT,
|
|
|
|
text=True,
|
|
|
|
)
|
|
|
|
output = []
|
2024-04-07 18:39:27 +02:00
|
|
|
printing_live = monitor
|
2024-03-20 12:55:40 +01:00
|
|
|
|
|
|
|
# Process Real-Time Output
|
|
|
|
for line in iter(process.stdout.readline, b''):
|
|
|
|
if not line:
|
|
|
|
break
|
|
|
|
|
|
|
|
if printing_live:
|
|
|
|
print(line, end='') # noqa: T201
|
|
|
|
elif (
|
|
|
|
info.SIGNAL_START_CLEAN_BLENDER in line
|
2024-03-20 12:56:50 +01:00
|
|
|
# or 'Traceback (most recent call last)' in line
|
2024-03-20 12:55:40 +01:00
|
|
|
):
|
|
|
|
printing_live = True
|
|
|
|
print(''.join(output)) # noqa: T201
|
|
|
|
else:
|
|
|
|
output.append(line)
|
|
|
|
|
|
|
|
# Wait for the process to finish and get the exit code
|
|
|
|
process.wait()
|
|
|
|
return process.returncode, output
|
|
|
|
|
|
|
|
|
|
|
|
####################
|
2024-04-07 18:39:27 +02:00
|
|
|
# - Main
|
2024-03-20 12:55:40 +01:00
|
|
|
####################
|
2024-04-07 18:39:27 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
# Uninstall Addon
|
|
|
|
print(f'Blender: Uninstalling "{info.ADDON_NAME}"...')
|
|
|
|
return_code, output = run_blender(info.PATH_BL_DELETE_ADDON, monitor=False)
|
2024-03-20 12:55:40 +01:00
|
|
|
if return_code == info.STATUS_UNINSTALLED_ADDON:
|
2024-04-07 18:39:27 +02:00
|
|
|
print(f'\tBlender: Uninstalled "{info.ADDON_NAME}"')
|
|
|
|
elif return_code == info.STATUS_NOCHANGE_ADDON:
|
|
|
|
print(f'\tBlender: "{info.ADDON_NAME}" Not Installed')
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
|
2024-04-07 18:39:27 +02:00
|
|
|
# Install Addon
|
|
|
|
print(f'Blender: Installing & Enabling "{info.ADDON_NAME}"...')
|
|
|
|
return_code, output = run_blender(info.PATH_BL_INSTALL_ADDON, monitor=False)
|
|
|
|
if return_code == info.STATUS_INSTALLED_ADDON:
|
|
|
|
print(f'\tBlender: Install & Enable "{info.ADDON_NAME}"')
|
|
|
|
else:
|
|
|
|
print(f'\tBlender: "{info.ADDON_NAME}" Not Installed')
|
2024-04-19 16:53:24 +02:00
|
|
|
print(*output, sep='')
|
2024-04-07 18:39:27 +02:00
|
|
|
sys.exit(1)
|
2024-04-02 20:49:57 +02:00
|
|
|
|
2024-04-07 18:39:27 +02:00
|
|
|
# Run Addon
|
|
|
|
print(f'Blender: Running "{info.ADDON_NAME}"...')
|
|
|
|
return_code, output = run_blender(
|
|
|
|
None, headless=False, load_devfile=True, monitor=True
|
|
|
|
)
|