Skip to content

pre_launch_args

TvpaintPrelaunchHook

Bases: PreLaunchHook

Launch arguments preparation.

Hook add python executable and script path to tvpaint implementation before tvpaint executable and add last workfile path to launch arguments.

Existence of last workfile is checked. If workfile does not exists tries to copy templated workfile from predefined path.

Source code in client/ayon_tvpaint/hooks/pre_launch_args.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class TvpaintPrelaunchHook(PreLaunchHook):
    """Launch arguments preparation.

    Hook add python executable and script path to tvpaint implementation before
    tvpaint executable and add last workfile path to launch arguments.

    Existence of last workfile is checked. If workfile does not exists tries
    to copy templated workfile from predefined path.
    """
    app_groups = {"tvpaint"}
    launch_types = {LaunchTypes.local}

    def execute(self):
        # Pop tvpaint executable
        executable_path = self.launch_context.launch_args.pop(0)

        # Pop rest of launch arguments - There should not be other arguments!
        remainders = []
        while self.launch_context.launch_args:
            remainders.append(self.launch_context.launch_args.pop(0))

        new_launch_args = get_ayon_launcher_args(
            "run", self.launch_script_path(), executable_path
        )

        # Append as whole list as these areguments should not be separated
        self.launch_context.launch_args.append(new_launch_args)

        if remainders:
            self.log.warning((
                "There are unexpected launch arguments in TVPaint launch. {}"
            ).format(str(remainders)))
            self.launch_context.launch_args.extend(remainders)

    def launch_script_path(self):
        from ayon_tvpaint import get_launch_script_path

        return get_launch_script_path()