0

Keeps command prompt when launching apps in Windows

I would like to debug my scripts in Maya, but it crashes without showing anything in script editor. I've tried launch_maya with tank command, but it seems it start another process without keeping its command prompt dialog. How can I keep my command prompt when launching any app with shotgun?

Thanks!

7 comments

  • 0
    Avatar
    KP

    Hi Daniel,

    You can turn on debug logging by setting `debug_logging: true` in your environment config. Assuming you're launching Maya from a Task:

    In /path/to/sgtk/software/shotgun\<your_project>/config/env/shot_step.yml

      ...
      engines:
        ...
        tk-maya:
        ...
        debug_logging: true

    This will turn on debugging output in the script editor which you can examine. If you're having any issues that we can help with, please don't hesitate to reply back and let me know!

  • 0
    Avatar
    Daniel Wong

    Thanks, I've found some clues. But is it able for to keep "windows command prompt" when launching app? Some apps like Nuke, prompts its error messages in the stdout. It will be so helpful if we can read those.

  • 0
    Avatar
    Benoit Leveau

    Hi Daniel,

    I use the following code to achieve this. Override the hook_app_launch of tk-multi-launchapp with code like this:

    # construct command to launch app
    cmd = "%s %s" % (app_path, app_args)
    # construct command to popup a terminal
    term_cmd = '%s; echo -e "\\n-- You can close this window --\\n"' % (cmd)
    window_title = "Shotgun - %s" % os.path.basename(app_path).capitalize()
    full_cmd = 'xterm -hold -title "%s" -e /bin/bash -c "%s" &' % (window_title, quote_string(term_cmd))

    # run the command to launch the app
    exit_code = os.system(full_cmd) def quote_string(s):
    """Escape a string."""
    return s.replace('\\', '\\\\').replace('"', '\\"')

     

  • 0
    Avatar
    Benoit Leveau

    This gives you a window like this screenshot. The "You can close this window" line appears when the application has exited, so if you've launched several apps you know which ones you can close.

  • 0
    Avatar
    Benoit Leveau

    You can remove "-hold" if you want the window to close when the app exits. But  prefer to keep it open so if there's a crash you can have a look at the console.

    Hope it helps,

    Benoit

  • 0
    Avatar
    Daniel Wong

    Oh I've missed this hook. Thanks and I can keep my command prompt now! 

  • 0
    Avatar
    KP

    Another great answer... thanks Benoit!

Please sign in to leave a comment.