Progress bar cocoa or ObjectC

Thanks a lot for the reply. I’m a bit new in ASObjC so sorry for asking but do I need to have the ASObjC Explorer for Mavericks to run Sahne’s Runner or could it work with only Apple script?

Thanks again

If you are looking to write the AppleScriptObjC-based libraries yourself then you could use the Explorer editor. And while I have only used a trial of Explorer in a few instances, it seems like a great tool overall.

But you don’t need Explorer to use the Runner application and can call it from a pure AppleScript application.

hanks again, I’m gonna try it in Applescript for now

So I did try the Shane’s runner progress bar and it seems pretty good. the only weird thing is that this progress bar seem to run after the rsync instead of during. I guess this is due to the fact that the update occurs after the Rsync. Do you know of a way that the progress bar can run during the Rsync (so we can monitor the rsync progress)?

Here’s the script I’ve used

set sourceFolder to POSIX path of (choose folder with prompt "Choose a folder to copy:")
set targetFolder to POSIX path of (choose folder with prompt "And where do you want it to go?")
set {TID, text item delimiters} to {text item delimiters, "/"}
set sourceFolderName to text item -2 of sourceFolder
set text item delimiters to TID


property defaultGroups : {"Family", "Friends"}
property defaultLabels : {}

tell application "ASObjC Runner"
	-- set up dialog and show it
	reset progress
	set properties of progress window to {button title:"Cancel", button visible:true, message:"Rsync Progress", detail:"More text can go here", indeterminate:false, max value:100, current value:0}
	activate
	show progress
end tell
delay 0.5
repeat with i from 1 to 100
	do shell script "/usr/bin/rsync -vautE " & quoted form of text 1 thru -2 of sourceFolder & space & quoted form of targetFolder
	delay 1 -- for effect
	-- update dialog
	tell application "ASObjC Runner"
		activate
		set properties of progress window to {detail:"This is number " & i, current value:i}
		if button was pressed of progress window then
			exit repeat
		end if
	end tell
end repeat
-- hide dialog
tell application "ASObjC Runner" to hide progress

Thanks

You need an asynchronous task like mentioned in the first post of x74353: http://macscripter.net/viewtopic.php?pid=173170#p173170

The variable newString contains the output you can see when you run the script in Terminal.app.
You have to parse the output and populate / update the progress bar

PS:

I wrote a quick & dirty Cocoa wrapper for rsync as a faceless scriptable application

Download and description in the Code Exchange section

http://macscripter.net/viewtopic.php?id=42723

Hi Stefan,

thanks a lot for the reply and sorry for the delay on my feedback as I was out of the country for the past 3 weeks. I did try the Cocoa wrapper but I have 2 little questions.

Right now, when trying the example code you provided, I can see that it’s displaying a progress bar (yeah :-)) but it’s seems to be statics and there’s also and empty dialog box with only an ‘‘ok’’ and ‘‘Cancell’’ button. Is it normal?

Also, should I place this code somewhere in particular? Right now I’ve tested right after my ''do shell script "/usr/bin/rsync -vautE " & quoted form of text 1 thru -2 of sourceFolder & space & quoted form of targetFolder<< line, but it does’t seems to work as the progress bar is waiting for the rsync to be finished before to start.

thanks a lot
Frederico

the Cocoa wrapper is a standalone solution, there is no shell script needed

You have to change this line


   set {exit code:exitCode, error message:errorMessage, items transferred:filesCopied, statistics:stats} to rsync from source "/path/to/source" to destination "/path/to/destination" arguments {"-au", "--exclude=.DS_Store"}

replace “/path/to/source” with the source path
replace “/path/to/destination” with the destination path
replace {“-au”, “–exclude=.DS_Store”} with just {“-au”}, omit the v, t and E switches or keep the expression if you want to exclude the invisible .DS_Store files

for example


set sourceFolder to (choose folder with prompt "Choose a folder to copy:")
set targetFolder to (choose folder with prompt "And where do you want it to go?")
tell application "Rsync Wrapper"
	activate
	set {exit code:exitCode, error message:errorMessage, items transferred:filesCopied, statistics:stats} to rsync from source sourceFolder to destination targetFolder arguments {"-au", "--exclude=.DS_Store"}
end tell
if exitCode is not 0 then
	display dialog errorMessage
else
	display dialog stats
end if

Oups, stupid me :-p

working now :slight_smile:

thanks again

Hi,

Be careful. If you delete the .DS_Store files located into the application, some applications don’t work anymore. Example: PCalc

Thanks Titanium.

Stefan,

I did try to run the Rsync Wrapper on some of my other CPU and for some reason didm’t seem able to do so.

The first I tried came back with an error saying ‘‘couldn’t find Rsync Wrapper application’’. I thought this was due to the fact that this station was running under 10.8.4, so I tried on another station running under 10.9.3 and still wasn’t able to run it. This time, my script came up with a ‘‘Error of type -10810’’

Any idea on what I’m n=missing?

Thanks

Also,

I was wondering if it was normal the the RSYNC seems to slow down the transfer? I did some tests with a 16 gig folder and when it took me around 5 minutes to copy when using the finder (just drag and drop) It took almost 7 minutes to transfer it using the RSYNC command.

thanks
Frédérico

I guess the verbose output to get all the file information is responsible for the delay

That was my feeling too. Do you know if this delay is exponential (the larger the folder the longer the delay)?

Also, do you have any idea why I can’t seem to be able to use the Rsync Wrapper on other station (one not finding the Rsync wrapper and the other one giving a -10810 error’'? Do I need to install something else in order for the Rsnc to work?

Frederico

I have no idea, but I assume it’s linear

Maybe you have to launch the app once manually to “register” the dictionary or try to drag Rsync Wrapper.app onto the icon of AppleScript Editor

so I did a couple of tests and realize that to get rid of the -10810 error, I have to go back to my script and add “.app” to the line “tell application “Rsync Wrapper”” so it becomes “tell application “Rsync Wrapper.app””. Though when I compile it the .app seem to disappear, I no longer have the -10810 error. But the Rsync doesn’t seem to work, as soon as it launch, I have an empty dialog window with only two button ok" and “cancelled”.

I also realize that the station which seem to work fine run under Applescript editor 2.6.1, while the others are running under Applescript editor 2.5.1

Is it possible that the RsyncWrapper.app only work under 2.6.1? And if so, does that mean that we need to run OS Maverick? (As I don’t think we can update Applescript Editor by it’s own)

Thanks
Frederico

I changed the deployment system of project and target to 10.7 and recompiled the source (build 2)
Same link

So I did try to re download it,

it’s seems to work better than the prior one (doesn’t have the -10810 error anymore) But I still have this strange dialog box when running script. No message, just the ‘‘ok’’ and '‘cancel’ button. If I hit ‘‘ok’’ all it seems to do is skip the rsync command so th next command (checking the mhl) is failing (since the rsync never occurred). If I hit ‘‘cancel’’ then it only cancel my script, the progress bar stays at ‘‘preparing’’ for ever and I have to kill it using the Activity monitor.

did try to look at the events while running the script and did find some odd things. The events seems ole at the beginning, but when it reach the Rsync wrapper line it seems to act strangely. Instead of haven an event '‘tell application ‘‘Rsync Wrapper’’’. I’m having a ''tell application Applescript editor"" with the following lines

tell application “AppleScript Editor”
activate
«event RsyWSYnc» given «class Krtn»:{«class RYsc»:“exitCode”, «class RYeR»:“errorMessage”, «class RYnf»:“filesCopied”, «class RYtt»:“stats”}, «class FRsc»:alias “iTunes01:Users:voduser:Desktop:J001:”, «class TOds»:alias “iTunes01:Users:voduser:Desktop:dg:”, «class SArg»:{“-au”, “–exclude=.DS_Store”}
→ {error message:“”, statistics:“”, exit code:5, items transferred:0}
end tell
tell application “AppleScript Editor”
display dialog “”

Please guys, i got the same issue over here, i guess it’s that i am using the “ASObjC Runner” Additions, and when i run it from inside the Apple Script Editor it runs perfectly fine, but when i try running it compiled as an application it doesn’t run at all! It gives me the 10810 Error, i think it’s because it’s not finding that resource, so i tried adding it to the resources folder inside the applet, and added a reference to there inside the script, didn’t work, still did not get anything… This is annoying…