Page 1 of 2

The future of AppleScript and Indigo Announcement

PostPosted: Sun Sep 17, 2017 8:55 pm
by nev
Hi All,
I read this announcement and need to clarify if I only need to convert embedded AppleScript to Python or any AppleScript including a "Execute Script (Script & File Actions)" if that also points to an AppleScript. Embedded only means a good amount of work, but if its both, then I'm just going to start over as its a stupid amount of work i'd have to do.

http://www.indigodomo.com/blog/2017/09/09/future-applescript-and-indigo/

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sun Sep 17, 2017 9:27 pm
by hamw
I think this is a terrible mistake. I have too much that depends on AppleScript. Changing everything to python will be unbelievably difficult; I am not a programmer by nature but through a lot of hard work including hours of rewriting things I have made some very effective scripts. Why are you doing this unless it is absolutely necessary? I will not be able to upgrade beyond 7.1, obviously.

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sun Sep 17, 2017 10:35 pm
by ckeyes888
Same here. I have, with the help of many here, years of work into Applescripts.
If 7.1 is the last of the support for it then that's it for any continuation with Indigo and me.

Carl

Re: The future of AppleScript and Indigo Announcement

PostPosted: Mon Sep 18, 2017 1:16 am
by Shutter
I too use a number of AppleScripts, which I found over the years on this forum - I can't code so have no chance converting them to Python. I did, over the last year, reduce my dependance on AppleScript, and tried to find Python equivalents, but still not 100%

It would be nice if we had a Python repository of scripts that people could use, and which if commented might be modifiable even by those who can't code.

Just a thought. Anyone willing to share?

Re: The future of AppleScript and Indigo Announcement

PostPosted: Mon Sep 18, 2017 1:25 am
by citysnaps
Looks like I'll be staying with 7.1 for awhile.

Re: The future of AppleScript and Indigo Announcement

PostPosted: Mon Sep 18, 2017 3:35 pm
by matt (support)
There are a lot of reasons we are pushing users to transition away from AppleScript:

• Apple is dropping support for 32-bit binaries in June and Indigo's AppleScript integration is built on top of a 3rd party 32-bit library and Apple 32-bit framework that aren't being updated to 64-bit. We would have to completely rewrite our AppleScript integration layer to a different framework, a task which would take significant engineering and QA time.

• Apple's ongoing commitment to AppleScript appears weak. Even if we were able to update Indigo to support AppleScript on 64-bit only macOS releases, how much longer will Apple continue to support and maintain AppleScript going forward? We think the writing is on the wall for its deprecation.

• Python has proven to be a much more reliable scripting environment, and has a strong community of developers. Additionally, Python is open source and even if Apple no longer included Python in a future macOS release we could embed our own version.

Note again that only AppleScripts that target Indigo will need attention. AppleScripts that are being used to command/control other macOS apps will work (although they might have to be saved as external AppleScript files instead of being embedded). We know the transition won't be trivial for some of our users, but we are here to help answer any questions you might have on converting your AppleScripts.

For some examples on controlling Indigo via Python and converting AppleScripts to Python, see the scripting tutorial, the devices object model documentation, and variables object mode documentation. There are also some forum threads with good discussions and examples and feel free to post any AppleScripts you are struggling to convert on the forum here.

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sat Sep 23, 2017 10:34 am
by nev
Thanks for the additional info on reasoning behind the change, this helps! I think like anything, people (including myself) are somewhat change resistant initially and especially when it means a great deal of work to switch everything over we have customized. Perhaps if we can get a little assistance with some core functions, it would make the transition to a new language easier. We really appreciate the assistance!

Running a curl script using a indigo variable value:

applescript
Code: Select all
tell application "IndigoServer"
   set MakerKey to the value of variable "MakerKey"
end tell
do shell script "curl -X POST https://maker.ifttt.com/trigger/some_light_off/with/key/" & MakerKey


python (not working)
Code: Select all
#! /usr/bin/env python
import commands,os,random,sys
myvar = indigo.variables[1234..]
os.system(curl -X POST https://maker.ifttt.com/trigger/some_light_off/with/key/ & myvar)

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sat Sep 23, 2017 12:04 pm
by autolog
Without checking your curl code, I can spot one thing - to get the value of the variable you have to specify:
Code: Select all
myvar = indigo.variables[1234..].value

For more detail on variables see this documentation page: http://wiki.indigodomo.com/doku.php?id=indigo_7_documentation:variable_class :)

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sat Sep 23, 2017 1:19 pm
by matt (support)
What Jon said, but also take a look at using the python requests library for making the HTTPS call. Something like this (untested):

Code: Select all
import requests

myvar = indigo.variables[1234].value
url = "https://maker.ifttt.com/trigger/some_light_off/with/key/" + myvar
r = requests.get(url)

# Example of logging to Indigo the HTTP result status code and text:
indigo.server.log("result status: %d, text: %s" % (r.status_code, r.text))

And here is some more information (and examples) on using the requests library.

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sat Sep 23, 2017 4:17 pm
by jay (support)
The requests library (which we include with Indigo 7+) makes using curl satisfying only for masochists.

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sat Sep 23, 2017 10:08 pm
by nev
Your combine posts filled in the gaps and its working well! One script done, many more to go... but at least I'll still have time to do it. Thanks for the quick info!!!

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sun Sep 24, 2017 8:38 am
by Korey
How about a Applescript to Python converter / Plugin :wink:

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sun Sep 24, 2017 10:17 am
by Colorado4Wheeler
Korey wrote:
How about a Applescript to Python converter / Plugin :wink:


That would be quite an undertaking. My take on this was similar though, it might be nice to have a feature in Indigo that says - perhaps in 7.0.5 or something - "list AppleScript dependancies" or something that we can pull a report and start converting. There's a lot of my old stuff that just simply still works so I have had no desire to reinvent the wheel when the old wheel is still rolling. This is to say I have probably 30-40 AppleScript things still on Indigo and it's going to take some effort to locate them all and fix them.

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sun Sep 24, 2017 10:21 am
by nev
Right on the money as usual Colorado4Wheeler!!! A report like that would assist greatly. As we make our way through converting everything, a report would allow us to see what we missed vs waiting until something breaks and investigating why.

Re: The future of AppleScript and Indigo Announcement

PostPosted: Sun Sep 24, 2017 1:29 pm
by DaveL17
Colorado4Wheeler wrote:
My take on this was similar though, it might be nice to have a feature in Indigo that says - perhaps in 7.0.5 or something - "list AppleScript dependancies" or something that we can pull a report and start converting.


Seems like it may be as simple as searching the Indigo database for the XML tag AppleScriptSCPT. I think that would give you the nodes that contain AppleScript, and then you could print out whatever aspects of the node you wanted.