mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
removed previous implementation of Application object
This commit is contained in:
parent
52b1619b50
commit
6fa65a9bf8
1 changed files with 0 additions and 88 deletions
|
|
@ -235,94 +235,6 @@ class ApplicationExecutable:
|
|||
return bool(self._realpath())
|
||||
|
||||
|
||||
class Application:
|
||||
"""Hold information about application.
|
||||
|
||||
Object by itself does nothing special.
|
||||
|
||||
Args:
|
||||
app_group (str): App group name.
|
||||
e.g. "maya", "nuke", "photoshop", etc.
|
||||
app_name (str): Specific version (or variant) of host.
|
||||
e.g. "maya2020", "nuke11.3", etc.
|
||||
host_name (str): Name of host implementation.
|
||||
app_data (dict): Data for the version containing information about
|
||||
executables, label, variant label, icon or if is enabled.
|
||||
Only required key is `executables`.
|
||||
manager (ApplicationManager): Application manager that created object.
|
||||
"""
|
||||
|
||||
def __init__(self, app_group, app_name, host_name, app_data, manager):
|
||||
self.app_group = app_group
|
||||
self.app_name = app_name
|
||||
self.host_name = host_name
|
||||
self.app_data = app_data
|
||||
self.manager = manager
|
||||
|
||||
self.label = app_data.get("label") or app_name
|
||||
self.variant_label = app_data.get("variant_label") or None
|
||||
self.icon = app_data.get("icon") or None
|
||||
self.enabled = app_data.get("enabled", True)
|
||||
self.is_host = app_data.get("is_host", False)
|
||||
|
||||
_executables = app_data["executables"]
|
||||
if not _executables:
|
||||
_executables = []
|
||||
|
||||
elif isinstance(_executables, dict):
|
||||
_executables = _executables.get(platform.system().lower()) or []
|
||||
|
||||
_arguments = app_data["arguments"]
|
||||
if not _arguments:
|
||||
_arguments = []
|
||||
|
||||
elif isinstance(_arguments, dict):
|
||||
_arguments = _arguments.get(platform.system().lower()) or []
|
||||
|
||||
executables = []
|
||||
for executable in _executables:
|
||||
executables.append(ApplicationExecutable(executable))
|
||||
|
||||
self.executables = executables
|
||||
self.arguments = _arguments
|
||||
|
||||
@property
|
||||
def full_label(self):
|
||||
"""Full label of application.
|
||||
|
||||
Concatenate `label` and `variant_label` attributes if `variant_label`
|
||||
is set.
|
||||
"""
|
||||
if self.variant_label:
|
||||
return "{} {}".format(self.label, self.variant_label)
|
||||
return str(self.label)
|
||||
|
||||
def find_executable(self):
|
||||
"""Try to find existing executable for application.
|
||||
|
||||
Returns (str): Path to executable from `executables` or None if any
|
||||
exists.
|
||||
"""
|
||||
for executable in self.executables:
|
||||
if executable.exists():
|
||||
return executable
|
||||
return None
|
||||
|
||||
def launch(self, *args, **kwargs):
|
||||
"""Launch the application.
|
||||
|
||||
For this purpose is used manager's launch method to keep logic at one
|
||||
place.
|
||||
|
||||
Arguments must match with manager's launch method. That's why *args
|
||||
**kwargs are used.
|
||||
|
||||
Returns:
|
||||
subprocess.Popen: Return executed process as Popen object.
|
||||
"""
|
||||
return self.manager.launch(self.app_name, *args, **kwargs)
|
||||
|
||||
|
||||
@six.add_metaclass(ABCMeta)
|
||||
class LaunchHook:
|
||||
"""Abstract base class of launch hook."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue