59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/osaka/scriptrunner.rb', line 59
def self.execute(applescript)
script_commands = applescript.gsub("\"", "\\\"").split(';')
escaped_commands = ""
script_commands.each { |l|
escaped_commands += " -e \"#{l.strip}\""
}
print_debug_info_for_escaped_commands(applescript, escaped_commands)
output = ""
begin
output = CommandRunner::run("osascript#{escaped_commands}")
rescue Osaka::SystemCommandFailed => ex
if ex.message =~ /assistive devices/
puts " Osaka execution failed with the error: \#{ex.message}\n The reason for this is probably that you didn't enable the acess for assistive devices.\n Without this enabled, Osaka won't be able to execute applescript and thus won't work.\n You can turn this on (in mountain lion) under:\n system preferences -> Accessibility -> Enable access for assistive devices\n If you are under snow leopard, it is under:\n system preferences -> Universal Access -> Enable access for assistive devices\n\n Osaka will not continue as it won't work without this enabled. Please enable it and re-run.\n eom\n exit\n return\n end\n raise(Osaka::ScriptRunnerError, \"Error received while executing: \\\"\#{applescript}\\\" with message \\\"\#{ex.message}\\\"\")\n end\n print_debug_info_for_additional_output(output)\n output\nend\n"
|