Folder Actions on Mac OSX Leopard?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • squishywaffle@gmail.com

    Folder Actions on Mac OSX Leopard?

    Greetings,

    I've been trying to figure out if it's possible to attach a Python
    script to an action via Mac OSX Leopard's File Actions system. I'm
    wanting to call a Python script every time a file is added to the
    monitored folder. Just adding a .py file doesn't seem to do anything
    at all, and I can't find any log output anywhere to see what's going
    on.

    I'm more just looking to see if this is or is not possible. I'm not
    interested in other solutions, as I already have them lined up in case
    this is a no-go, but I'd really love to be able to do it this way if
    anyone has any experience. Googling around revealed pretty much
    nothing.

    Any help is much appreciated,
    Greg
  • Diez B. Roggisch

    #2
    Re: Folder Actions on Mac OSX Leopard?

    squishywaffle@g mail.com schrieb:
    Greetings,
    >
    I've been trying to figure out if it's possible to attach a Python
    script to an action via Mac OSX Leopard's File Actions system. I'm
    wanting to call a Python script every time a file is added to the
    monitored folder. Just adding a .py file doesn't seem to do anything
    at all, and I can't find any log output anywhere to see what's going
    on.
    >
    I'm more just looking to see if this is or is not possible. I'm not
    interested in other solutions, as I already have them lined up in case
    this is a no-go, but I'd really love to be able to do it this way if
    anyone has any experience. Googling around revealed pretty much
    nothing.
    You mean this?



    *I* would use ctypes to access Carbon Core. But then that's just me -
    I'm sure you find a better way...

    Diez

    Comment

    • Sean DiZazzo

      #3
      Re: Folder Actions on Mac OSX Leopard?

      On Sep 24, 12:31 pm, "squishywaf...@ gmail.com"
      <squishywaf...@ gmail.comwrote:
      Greetings,
      >
      I've been trying to figure out if it's possible to attach a Python
      script to an action via Mac OSX Leopard's File Actions system. I'm
      wanting to call a Python script every time a file is added to the
      monitored folder. Just adding a .py file doesn't seem to do anything
      at all, and I can't find any log output anywhere to see what's going
      on.
      >
      I'm more just looking to see if this is or is not possible. I'm not
      interested in other solutions, as I already have them lined up in case
      this is a no-go, but I'd really love to be able to do it this way if
      anyone has any experience. Googling around revealed pretty much
      nothing.
      >
      Any help is much appreciated,
      Greg
      I always wondered about Folder Actions... I just tested. You can
      have applescript call python scripts via `do shell script`. But it
      seemed a bit flakey.

      I would either go with applescript all the way, or look in to your
      other options.

      ~Sean

      Comment

      • has

        #4
        Re: Folder Actions on Mac OSX Leopard?

        On 25 Sep, 00:30, Sean DiZazzo <half.ital...@g mail.comwrote:
        I always wondered about Folder Actions...  I just tested.  You can
        have applescript call python scripts via `do shell script`.  But it
        seemed a bit flakey.
        Should work in theory. For which values of flakey? e.g. Is it a
        technical problem with Folder Actions, AppleScript, 'do shell script,
        and/or Python, or just your AppleScript code that needs some work
        (e.g. there are some common gotchas with using 'do shell script' that
        often trip up AppleScript newcomers).

        FWIW, I would second the suggestion to look into FSEvents as a
        possible alternative to Folder Actions. There's also kqueue which is
        lower level but may have/have had Python bindings already written for
        it.

        Alternatively, if the OP really wants to use FAs, there are a couple
        of other options for that:

        1. I've got a simple py2app-based application shell and an AppleScript
        that automatically forwards FA events to that application - just
        insert your Python code into the application shell and build it,
        attach the AppleScript to some folders, and you're good to go. Email
        me directly if you want a copy.

        2. If you're brave, you could try using the PyOSA component on the
        appscript website, which allows you to write OSA scripts in Python.
        FAs will work with any kind of OSA script (.scpt files), not just
        AppleScript ones. PyOSA is officially discontinued due to some
        intractable limitations in its/CPython's design (specifically the
        inability of an in-process Python interpreter to sandbox unrelated
        scripts so that they can't interfere with each others' modules, file
        handles, etc). However, it's reasonably functional and should be
        usable for FAs with a little care.


        HTH

        has
        --
        Control AppleScriptable applications from Python, Ruby and ObjC:


        Comment

        Working...