[ANSWERED]: My Applescript no longer working with Yosemite

Posted on
Thu Oct 30, 2014 8:56 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

[ANSWERED]: My Applescript no longer working with Yosemite

I have some simple Applescript that checks iCal for a specific event ("Guest" ) in order to set a mode for guests staying over at the house. It has worked for about a year, but recently stopped working after the upgrade to Yosemite. I receive an error: timeout waiting for server response for request ExecuteScriptSource, and the code doesn't execute properly.

Here's the code:

Code: Select all
set {year:y, month:m, day:d} to current date
set str to (m as string) & " " & (d as string) & " " & (y as string)
set today to date str
set tomorrow to today + (60 * 60 * 24)

tell application "Calendar"
   tell calendar "My Home Calendar"
      set curr to every event whose start date is greater than or equal to today and start date is less than or equal to tomorrow
      delay 10
      if (count of items of curr) is greater than 0 then
         repeat with b in curr
            set a to summary of b
            if a is equal to "Guest" then
               tell application "IndigoServer"
                  if value of variable guestMode is not equal to "true" then
                     set value of variable "guestMode" to "true"
                  else
                     log "Not setting guestMode again, repeat"
                  end if
               end tell
            else
               tell application "IndigoServer"
                  set value of variable "guestMode" to "false"
                  log "Looks like no sleepover tonight!"
               end tell
            end if
         end repeat
      else
         tell application "IndigoServer"
            set value of variable "guestMode" to "false"
            log "Looks like no sleepover tonight!"
         end tell
      end if
   end tell
end tell


Posted on
Sun Nov 02, 2014 5:20 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: My Applescript no longer working with Yosemite

Hi Ryan,

I wonder if it is just taking too long to execute. Try saving it into a script file (via the Script Editor application), then have Indigo execute the script file instead of having the script embedded in the action dialog. Indigo will then execute it in its own process, which will not have a time limit.

If that doesn't work, then you'll need to add some debug logging to the script or start commenting out sections of the script to narrow down the problem.

Image

Posted on
Mon Nov 03, 2014 7:04 am
DomoPat offline
User avatar
Posts: 210
Joined: Jul 17, 2010
Location: Toulouse, France

Re: [ANSWERED]: My Applescript no longer working with Yosemi

I was surprised by your code because I remember how difficult it was for me to get results from ical, so i tried it in Script editor.

At first I had an error on the date format (may be because I use a French OS) so I had to do this change:

Code: Select all
set today to current date
set tomorrow to today + (60 * 60 * 24)


It worked, but on first run I get a window asking me 'to authorize script editor to access iCal database'. After that it runs well but very slow (even with removing of the delay 10).
May be that authorization request is blocking the execution ?

This is where I realized I do sort of the same thing in one if my scripts, to check if we are in school vacation time. I use iCalBuddy to makes things easier and wanted to see if it will work under Yosemite, and it does. And look how much more simple (and fast) the script is:

Code: Select all
set LaString to (do shell script "/usr/local/bin/icalbuddy -nc -ic Famille eventsToday")
if LaString contains "Libéré" or LaString contains "Vacances" then
   set value of variable "VacancesScolaire" to "Oui"
   else
   set value of variable "VacancesScolaire" to "Non"
end if


iCalBuddy is a command lin,e utility with a lot of options to give you exactly the events of the iCal database that you need. It works so well I completely forgot about it !

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 26 guests