Launch an application from Python?

Discussion in 'Mac Programming' started by HiRez, Mar 20, 2007.

  1. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #1
    Hi, I know this is kind of obscure, but I'm trying to figure out how to launch an external application/process from Python code. Specifically, I'm trying to launch After Effects. Then, I want to be able to send a script (Javascipt) to it. Ideally, I'd like to do it directly from Python, using no additional frameworks such as PyObj, which seems quite heavyweight for what I need. A cursory Google search didn't reveal exactly what I was looking for. Is there some Python package that handles this stuff or do I have to maybe use an AppleScript bridge or something? Thanks in advance if you can help.
     
  2. macrumors 6502

    Joined:
    May 12, 2003
    #2
    My first idea would be to use AppleScript via the 'osascript' command line utility. I'm not exactly sure how to execute system commands in Python, maybe os.system? Google should be able to help if needed.
     
  3. macrumors member

    Joined:
    Apr 29, 2005
    #3
    Appscript is a quite pleasant way to get to AppleScript from Python apps. The syntax is kind of reversed compared to regular AppleScript, but it works well, and you could start an app by sending a message to the Finder I think
     
  4. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #4
    I assume Python can issue bash commands?

    If so, check out the open command
     
  5. macrumors 6502a

    Joined:
    Jan 13, 2004
    Location:
    UK
    #5
    Depends on which version of Python you are using. If you're using the 2.3 ( bundled with OSX ), you need be looking at the various os.open/exec calls. If you've installed 2.5, have a look at the subprocess module.
     
  6. thread starter macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #6
    Thanks for the suggestions, I'll check them out when I get time, hopefully this weekend. I know there's got to be some easy way to do this, prolly multiple ways.
     

Share This Page