mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Only construct info when needed + optimize "silent commands" lookup
- Lookup in "silent commands" as `set` - Do "silent commands" lookup only once instead of in the for loop - Move imports closer to where they are needed (e.g. don't import terminal if we don't use it)
This commit is contained in:
parent
50d1f8c4be
commit
b088e952e6
1 changed files with 21 additions and 20 deletions
41
start.py
41
start.py
|
|
@ -86,7 +86,7 @@ Todo:
|
|||
Move or remove bootstrapping environments out of the code.
|
||||
|
||||
Attributes:
|
||||
silent_commands (list): list of commands for which we won't print OpenPype
|
||||
silent_commands (set): list of commands for which we won't print OpenPype
|
||||
logo and info header.
|
||||
|
||||
.. _MongoDB:
|
||||
|
|
@ -202,8 +202,8 @@ from igniter.tools import (
|
|||
from igniter.bootstrap_repos import OpenPypeVersion # noqa: E402
|
||||
|
||||
bootstrap = BootstrapRepos()
|
||||
silent_commands = ["run", "igniter", "standalonepublisher",
|
||||
"extractenvironments"]
|
||||
silent_commands = {"run", "igniter", "standalonepublisher",
|
||||
"extractenvironments"}
|
||||
|
||||
|
||||
def list_versions(openpype_versions: list, local_version=None) -> None:
|
||||
|
|
@ -1057,29 +1057,30 @@ def boot():
|
|||
_print(" - for modules ...")
|
||||
set_modules_environments()
|
||||
|
||||
from openpype import cli
|
||||
from openpype.lib import terminal as t
|
||||
from openpype.version import __version__
|
||||
|
||||
assert version_path, "Version path not defined."
|
||||
info = get_info(use_staging)
|
||||
info.insert(0, f">>> Using OpenPype from [ {version_path} ]")
|
||||
|
||||
t_width = 20
|
||||
try:
|
||||
t_width = os.get_terminal_size().columns - 2
|
||||
except (ValueError, OSError):
|
||||
# running without terminal
|
||||
pass
|
||||
# print info when not running scripts defined in 'silent commands'
|
||||
if all(arg not in silent_commands for arg in sys.argv):
|
||||
from openpype.lib import terminal as t
|
||||
from openpype.version import __version__
|
||||
|
||||
_header = f"*** OpenPype [{__version__}] "
|
||||
info = get_info(use_staging)
|
||||
info.insert(0, f">>> Using OpenPype from [ {version_path} ]")
|
||||
|
||||
info.insert(0, _header + "-" * (t_width - len(_header)))
|
||||
for i in info:
|
||||
# don't show for running scripts
|
||||
if all(item not in sys.argv for item in silent_commands):
|
||||
t_width = 20
|
||||
try:
|
||||
t_width = os.get_terminal_size().columns - 2
|
||||
except (ValueError, OSError):
|
||||
# running without terminal
|
||||
pass
|
||||
|
||||
_header = f"*** OpenPype [{__version__}] "
|
||||
info.insert(0, _header + "-" * (t_width - len(_header)))
|
||||
|
||||
for i in info:
|
||||
t.echo(i)
|
||||
|
||||
from openpype import cli
|
||||
try:
|
||||
cli.main(obj={}, prog_name="openpype")
|
||||
except Exception: # noqa
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue