Skip to content

launch_script

Script wraps launch mechanism of Harmony implementations.

Arguments passed to the script are passed to launch function in host implementation. In all cases requires host app executable and may contain workfile or others.

on_invalid_args(script_not_found)

Show to user message box saying that something went wrong.

Tell user that arguments to launch implementation are invalid with arguments details.

Parameters:

Name Type Description Default
script_not_found bool

Use different message based on this value.

required
Source code in client/ayon_harmony/api/launch_script.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def on_invalid_args(script_not_found):
    """Show to user message box saying that something went wrong.

    Tell user that arguments to launch implementation are invalid with
    arguments details.

    Args:
        script_not_found (bool): Use different message based on this value.
    """

    title = "Invalid arguments"
    joined_args = ", ".join("\"{}\"".format(arg) for arg in sys.argv)
    if script_not_found:
        submsg = "Where couldn't find script path:\n\"{}\""
    else:
        submsg = "Expected Host executable after script path:\n\"{}\""

    message = "BUG: Got invalid arguments so can't launch Host application."
    detail_message = "Process was launched with arguments:\n{}\n\n{}".format(
        joined_args,
        submsg.format(CURRENT_FILE)
    )

    show_error_messagebox(title, message, detail_message)

show_error_messagebox(title, message, detail_message=None)

Function will show message and process ends after closing it.

Source code in client/ayon_harmony/api/launch_script.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def show_error_messagebox(title, message, detail_message=None):
    """Function will show message and process ends after closing it."""
    from qtpy import QtWidgets, QtCore
    from ayon_core import style

    app = QtWidgets.QApplication([])
    app.setStyleSheet(style.load_stylesheet())

    msgbox = QtWidgets.QMessageBox()
    msgbox.setWindowTitle(title)
    msgbox.setText(message)

    if detail_message:
        msgbox.setDetailedText(detail_message)

    msgbox.setWindowModality(QtCore.Qt.ApplicationModal)
    msgbox.show()

    sys.exit(app.exec_())