Your best friend for file transfer.

Fetch application logoFetch

applescript question (5 posts)

This is an archived topic. The information in it is likely to be out-of-date and no longer applicable to current versions of Fetch.
  • Started 20 years ago by guest
  • Latest reply 20 years ago from Jim Matthews
  • guest Registered Member

    hi. I have a problem in an applescript that controls fetch... it sometimes tries to close the transfer window while files are still uploading. This in turn throws up a dialog complaining "fetch is busy copying files and do I want to close the window?" and then halts all fetch processes. This script isn't monitored by humans on a regular basis so the whole process of uploading kinda grinds to a halt until someone notices a problem. Is there a way to see if the transfer window is busy doing something before I try to close the transfer window? Here's my code for the fetch stuff:
    tell application "Fetch 4.0.3"
    activate
    try
    delete url ((curdfurl & myfilename) as text)
    on error errMsg
    if (errMsg does not contain "non-existent") then
    my logfile(errorlog, {errMsg, "Fetch couldn't delete " & filetomove, myip})
    end if
    end try
    try
    put into url curdfurl item filetomove binary format Raw Data text format Raw Data
    set trashit to true
    my logfile(errorlog, {"Sent " & filetomove, myip})
    on error errMsg
    display dialog errMsg & filetomove giving up after 2
    my logfile(errorlog, {errMsg, "ERROR. Fetch couldn't send " & filetomove, myip})
    end try
    try
    close every transfer window
    end try
    end tell

    Posted 20 years ago #

  • guest Registered Member

    In other parts of the above script I get the name of transfer window 1 and I see there's a status somehow attached to windows but how do I use them?

    Posted 20 years ago #

  • Jim Matthews Administrator

    You can check the status of a transfer window by saying (for example):

    set curstatus to status of transfer window 1

    Note that AppleScript won't send a command to Fetch until the previous command is finished; so the "close every transfer window" won't be sent until the "put into url" line is done. So I'm not clear on why a transfer is happening when you get to "close every transfer window"; perhaps a transfer started by a different script?

    If you know you want to close all the transfer windows whether they are busy or not you can say:

    close every transfer window saving no

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 20 years ago #

  • guest Registered Member

    I agree that as written the script should finish the transfer and then close the window. But it doesn't work like that. I'm using fetch controlled by an idle handler applescript(the above script snippet is part of my ftp routine) to ftp postscript files to our RIPs. Some of these files are a decent size (>50mb) and its on these files that fetch transfers away and then ocassionally the applescript seems to startup again while fetch is still busy. That's why I use the "close every transfer window" command instead of "close transfer window 1" because sometimes I have more than one window to close. Maybe I need a "with timeout" clause wrapped around the fetch script commands? Or does fetch support transactions?
    This is the only script that runs on 7 machines. Each of the macs(6 g4cubes and one other g4) runs one application that hooks into several sybase databases, fetch and the applescript- nothing else. The problem isn't a show stopper (it happens a few times a week) but it is one of those annoying little things :+)

    Posted 20 years ago #

  • Jim Matthews Administrator

    Yes, I'd definitely use a with timeout clause. I bet that the transfer command is timing out, so you're falling into the on error clause, where it puts up a dialog for a couple minutes, logs the error, and then tries to close the (still busy) transfer window. Does your log show any timeout errors?

    Try something like:

    with timeout of 3600 seconds
    put into url...
    end timeout

    That'll give the transfer an hour to complete.

    Jim Matthews
    Fetch Softworks

    Posted 20 years ago #

Topic closed

This topic has been closed.