I am trying to create a plugin for iChat in plex which needs some applescript coding. Now I know that python can execute some applescript via e.g. :
I also found [https://plexapp.lighthouseapp.com/projects/...-skin-xml-files](https://plexapp.lighthouseapp.com/projects/14382/tickets/119-add-scripting-directly-in-skin-xml-files)
where a ticket is opened for python code in xml files (still status new?)
And in [post="0"]While there is NO Plug-In development guide out there yet ...[/post] I read at the bottom of the first Post
[quote]
Missing items within this DOCUMENTATION:
- "exotic / advanced" things one can do from within a plug-in (e.g. run an
EXTERNAL function (dll etc.) / start - stop other programs, multithreading)
[/quote]
So now my question is: in what way can I include applescript code in “init.py” that will be executed when I select an item like a Media-Item
We prefer you don't use os.system, it would probably be better to use some of the built-in (on Leopard) Python/Applescript (see [http://pyobjc.sourceforge.net/)](http://pyobjc.sourceforge.net/)).
In order to execute it when hitting a media item, you can use the v1 of the framework and use a Function() item to call back into your plug-in. Check out any of the myriad of v1 plug-ins for good example code.
I’ve been wondering about the best way of providing AppleScript support in plug-ins. There’s an event bridge (py-appscript) that looks fairly promising, but it’s still in the very early stages of development, so may not be appropriate (I haven’t spent a great deal of time looking in to it - AppleScript support will be useful for a feature that’s a long way off yet, so it’s not top priority :))
I was also wondering about the same thing, applescript within python. Is pyobjc stuff bundled with Leopard now? Also do you know of any good places with examples of using the leopard built-in’s and applescript? Got a little pet project I’ve been working on for my own usage that I’d like to also get working in plex at some point.
Howdy, I’m new to Plex (as of a week ago), but it’s pretty awesome.
I write a lot of Python for my job (mostly for writing cross platform testing harnesses and the like) and though I haven’t written any python for Plex yet, I do have some experience with Python and AppleScript… The py-appscript stuff works quite well. The hardest part is translating the AppleScript code into what it should be for Python. Here’s a quick example (launch Safari from python and then tell Safari to load a url):
Is the py-appscript bundled with Leopard or is it required to add manually? I'd just be concerned that if we want to include something like this and users don't have it on their system it would require too much hoop jumping for them ...
We already use a bunch of stuff that isn’t bundled with OS X - that’s not an issue The plug-in framework & App Store make it very easy to push updates out to all users, including any new libraries we may come to rely upon. My only concern is the potential security implications - we’ll soon be starting to sandbox running plug-ins, preventing them from accessing the underlying system or unsafe modules. Allowing plug-ins to break out of the sandbox & run any AppleScript they like could cause all sorts of problems!
Also I took (again) a deeper look into Elan’s statement about PyObjC. For me this looks a bit more complicated. But okay if one of the two works, it’s fine.
I searched the net for some code and found that either:
“from appscript include *” for the py-appscript and also
“from InstantMessage import *” for PyObjC
would stop a plugin from loading. (Both lines work from the python command line)
So for now, I got no further in programming the plugin.
How can I include the py-appscript into plex. I read something in the PlexMediaFramework.pdf of “The Libraries directory”. Is it possible to put some py-appscript code there (and when yes, what exactly)? As you may read, I’m totally lost (and don’t program a lot)
You can create a directory called “Libraries” inside your plug-in’s “Contents” directory. Any Python libraries you put in this directory will be available to your code.
if I could place my appscript library there, against which version of Plex does it have to be compiled? Correct me if I am wrong, but for as I know, is OS X 10.6 shipped with Python 2.6 and OS X 10.5 shipped with 2.5
What does Plex use? Does it use the build in of OS X or does it come with it's own? And if so, which version?
Or am I thinking way to complicated?
I asume you mean “against which version of Python does it have to be compiled”?
We target the Python 2.5 installation that ships with OS X. Although OS X 10.6 includes Python 2.6, it still includes 2.5 and 2.3 in Python.framework (don’t ask what happened to 2.4).
Isn’t it possible to ‘save’ Applescript as an .app and run that from Plex?
(I created an applescript that opens the Dashboard - containing webcams - that closes after 10 seconds)
BTW, if someone has a working solution on how to run scripts/apps from a plugin, please add a message listing all steps you have to take to get it working (ideally with sample plugin file).