Home Download Buy Blog Forum Support

Sublime 2 crashes when I activate it with Applescript

Sublime 2 crashes when I activate it with Applescript

Postby gregor.hoch on Mon Oct 03, 2011 1:27 pm

Hi, I am making a small plugin to send code to other applications such as R, Stata and iTerm. I am using Applescript though the system command osascript to achieve this. When I want to reactivate Sublime Text 2 through applescript, it crashes. Below is a minimum example. Any suggestions?


Code: Select all
import sublime, sublime_plugin
import os

class ExampleCommand(sublime_plugin.TextCommand):
   def run(self, edit):
      cmd = """osascript -e 'tell app "Finder" to activate' """
      cmd2= """osascript -e 'tell app "Sublime Text 2" to activate' """
       
      os.system(cmd)
      os.system(cmd2)
gregor.hoch
 
Posts: 128
Joined: Sat Oct 01, 2011 7:54 pm

Re: Sublime 2 crashes when I activate it with Applescript

Postby gregor.hoch on Mon Oct 03, 2011 3:46 pm

Thanks sublimator. Your suggestions worked after adding the 'shell=True' argument to subprocess.Popen.

Code: Select all
subprocess.Popen("""osascript -e 'tell app "Sublime Text 2" to activate' """, shell=True)
gregor.hoch
 
Posts: 128
Joined: Sat Oct 01, 2011 7:54 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests