Automatic acknowledgement/dismissal of warnings in scripting

LXConsole support and feedback
Post Reply
freadZdead
Posts: 211
Joined: Sat Jun 01, 2013 8:23 am
Location: Adelaide, Australia

Automatic acknowledgement/dismissal of warnings in scripting

Post by freadZdead »

I am working on a script that creates a structure of cues with referenced Groups automated from an Excel spreadsheet via AppleScript into LXConsole, and like in the past I noted a few instances where a warning/confirmation dialog interrupts the batch flow;

when I use something like
doCommand string "Group: " & (theIncludedGroup as text)
in my script, or when you use record (and the original cue exists), then an overwrite dialog does the same.

A lot of old command line tools offer a "silent" modifier that basically acknowledges/dismisses any warning dialogs automatically for batch processing. While I am aware of risks when using this, can there be some overarching modifier for warning dialog boxes from commands to go automatically get dismissed from AppleScript? It might be better to do it universally for all commands. I think I remember we came across this in OSC matters before.
Cheers,

Freddy
admin
Site Admin
Posts: 1643
Joined: Mon Nov 05, 2007 1:26 am
Contact:

Post by admin »

In the latest build, 3.8.5 (8904.2), you can add an exclamation point to bypass warnings when adding a group or recording a cue.

[r], [!] becomes "record!:" which will overwrite an existing cue without a warning sheet.

[G], [!] becomes "Group!:" and will include a group in the current cue without a warning sheet.

Don't try this without adult supervision :-)
freadZdead
Posts: 211
Joined: Sat Jun 01, 2013 8:23 am
Location: Adelaide, Australia

Post by freadZdead »

I will have to by my parents plane tickets to come over to Australia :)...

Sorry to be a pain, but can this be added for "record group!" as well (overwriting confirmation)?
Cheers,

Freddy
admin
Site Admin
Posts: 1643
Joined: Mon Nov 05, 2007 1:26 am
Contact:

Post by admin »

Done in Version 3.8.5 (8904.3) which is available for download as the latest build even though it may not appear as the latest on other pages of the website yet.

I've been requested to explain what I''ve been spending so much time on. So, can you tell me what show you are working on and what city?
freadZdead
Posts: 211
Joined: Sat Jun 01, 2013 8:23 am
Location: Adelaide, Australia

Post by freadZdead »

https://www.adelaidefestivalcentre.com. ... o-lessons/

It is a slightly unusual setting - a 2h+interval theatre show with music, that kicks off its tour (after laying 2 years dormant, and with little documentation surviving from the previous show, except for videos and the previous director aboard again who has a keen mind and went along for this ride) in a cabaret festival with all time pressures of a "rock'n'roll" ;) instead of theatre environment...

Since this is the beginning of the tour, the task was not only to squeeze every bit of time out of prepping before the plot in the room (i.e. us simplifying, describing cues as either full restores or variations where possible, paper plotting fade and follow times, creating the softpatch and lxcues file in advance with everything bar the actual levels), but to allow for quick bump-in and cascading effect in future plots of the tour... needless to say that the same machine runs QLab, calling audio and LX together. The result in figures: 91 cues, 87 LX cues with only 20 LX Cues to be programmed/adjusted in future venues, while the rest are restores or variations of previous cues, (some of them with a hierarchy of 4 included Groups/Cues), and of course a multi-sheeted excel extravaganza with circular references, sprinkled with a bit of AppleScript that automates the creation of QLab and LXCues based on the paper plot in the Excel Workbook - I'd say a new way of tracking without tracking, all thanks to you :)!

And now, stop wasting your time on this humble technician ;)... As always deep gratitude across the ocean!
Cheers,

Freddy
freadZdead
Posts: 211
Joined: Sat Jun 01, 2013 8:23 am
Location: Adelaide, Australia

Post by freadZdead »

An unfortunate error/bug report... when using "Group!: 0.3" in AppleScript's doCommand, it does not work - i.e. no error is reported, but the dynamic group is not included.

When all other syntax remain unchanged, except for removing the "!", it works, though it does then of course ask for confirmation.

While it looks like "record!: " and "record group: " seem to work fine, it might be worth checking if whatever is affecting "Group! :" is not affecting the other two?

Sorry to bother!
Cheers,

Freddy
admin
Site Admin
Posts: 1643
Joined: Mon Nov 05, 2007 1:26 am
Contact:

Post by admin »

Can you post your AppleScript? Or, at least the part that includes the group.

The "Group!: 0.3" command works just fine from the command line. So, there must be something in how the command is handled from AppleScript.

In any case, group 0.3 must exist before it can be included in a cue. Including a group from the command line that does not exist fails silently using either "Group:" or "Group!:"
freadZdead
Posts: 211
Joined: Sat Jun 01, 2013 8:23 am
Location: Adelaide, Australia

Post by freadZdead »

Hmm, strange - I will post the whole one in a minute, but above that, the excerpt in question... and yes, I had covered the "group should exist before you include it" by making any new groups first before going trough... I am a bit embarrassed, I haven't really looked into elegant ways to transfer a lot of data from Excel to Applescript, So I encode my cue information from the spreadsheed in this manner and use a variety of symbols to decode the information again in Applescript... talk about round-about fashion...:

lxCueNo-theWhen$theWhat-upTime/downTime%makeGroup/includeGroup1#includeGroup2#includeGroup3...

an example string straight from the press are these first few cues:

Code: Select all

0.1-p1, Q 0.1 # *Ready for* LX + SND Checks$LX Checks, House LX off-5/5%/;0.3-p,  # $Technical Cue: Strike all movers and Set to appropriate position-1/1%0.3/0.3;0.5-p,  # $Technical Cue: Douse all movers-1/1%0.5/0.3#0.5;0.9-p1, Q 0.9 # *Finish* LX + SND Checks$LX out, House LX on-5/5%/;1-p1, Q 1 # *Preshow*$30% BLUE BACKLIGHT + HOUSE LX-5/5%1/0.3#0.5#1;2-p1, Q 2 # *FoH Clearance*$HOUSE LIGHTS AND PRE SHOW STATE DOWN (BLACKOUT)-5/6%2/0.3#0.5#2
Here the snippet that counts:

Code: Select all

	--record the cue
	set theDoCommand to "record!: " & (cueNo as text)
	my execLXC(theDoCommand)
	--potentially include group(s)
	-- make sure we are still in live
	my modeLXC("live")
	--	if theIncludedGroups is not "" then
	set AppleScript's text item delimiters to "#"
	try
		set the item_list20 to every text item of theIncludedGroups
		set AppleScript's text item delimiters to ""
	on error testtt20
		display dialog testtt20
	end try
	repeat with eachIncludedGroup in item_list20
		if eachIncludedGroup is not "" then
			set theDoCommand to "Group: " & (eachIncludedGroup as text)
			my execLXC(theDoCommand)
		end if
	end repeat
In this bit, if I change "Group: " to "Group!: ", the group inclusion does not work, though no error is spat. I had briefly tried adding delays, thinking that maybe LXConsole did not react fast enough to have the cues there before they were included, but it does not seem like this is the issue...

Here for all suicidals, the full script:

Code: Select all

-- GENERATE DEPENDENT GROUP CUE V1
-- Select 2 or more channels (usually, an odd number looks nicer) in the order that you would like the fan to be applied,
-- and exectute script to create smooth static fans and chases

property alphaList : "abcdefghijklmnopqrstuvwxyz"'s items & reverse of "ABCDEFGHIJKLMNOPQRSTUVWXYZ"'s items

set tid to AppleScript's text item delimiters
try
	tell application "LXConsole"
		
		set i to 1
		repeat while i = 1
			set creationResults to ""
			set newLXQtxtPre to text returned of (display dialog "Please enter LX Cue number(s) encoded, seperated by semicola, hyphen to specify items:" default answer "")
			--- enumeration
			set AppleScript's text item delimiters to ";"
			try
				set the item_list to every text item of newLXQtxtPre
				set AppleScript's text item delimiters to ""
			on error testtt3
				display dialog testtt3
			end try
			repeat with eachPotentialTupel in item_list
				set AppleScript's text item delimiters to "-"
				try
					set the item_list2 to every text item of eachPotentialTupel
					--lxCueNo-pageNo, qLabCueNo # cuePoint $cueDescription-upTime/downTime%makeGroup/includeGroup1#includeGroup2#includeGroup3...
					set AppleScript's text item delimiters to ""
					set theMakeGroup to ""
					set theIncludeGroups to ""
					set upDownTimes to "0/0"
					
					set lxCue to first item of item_list2
					set lxNotes to second item of item_list2
					set upDownTimesAndGroups to last item of item_list2
					-- separating times from groups 
					set AppleScript's text item delimiters to "%"
					try
						set the item_list10 to every text item of upDownTimesAndGroups
						set AppleScript's text item delimiters to ""
						set x to 0
						set upDownTimes to first item of item_list10
						set theGroups to last item of item_list10
					on error testtt13
						display dialog "Bla13" & testtt13
					end try
					-- separating Makes from Includes of groups 
					set AppleScript's text item delimiters to "/"
					try
						set the item_list11 to every text item of theGroups
						set AppleScript's text item delimiters to ""
						set x to 0
						set theMakeGroupO to first item of item_list11
						set theIncludeGroupsO to last item of item_list11
					on error testtt7
						display dialog "Bla7" & testtt7
					end try
					-- separating up from down times 
					set AppleScript's text item delimiters to "/"
					try
						set the item_list9 to every text item of upDownTimes
						set AppleScript's text item delimiters to ""
						set x to 0
						set theUpTimeO to first item of item_list9
						set theDownTimeO to last item of item_list9
					on error testtt6
						display dialog testtt6
					end try
					-- separating cuePt from Description 
					set AppleScript's text item delimiters to "$"
					try
						set the item_list8 to every text item of lxNotes
						set AppleScript's text item delimiters to ""
						set x to 0
						set theWhenO to first item of item_list8
						set theWhatO to last item of item_list8
						if theWhen is theWhatO then
							set theWhatO to ""
						end if
					on error testtt5
						--						display dialog testtt5
					end try
					--- bolding cue points
					set AppleScript's text item delimiters to "*"
					try
						set the item_list7 to every text item of theWhenO
						set AppleScript's text item delimiters to ""
						set x to 0
						set theWhenO to ""
						repeat with eachTextPart in item_list7
							set eachTxtPt to eachTextPart as text
							set x to x + 1
							if x mod 2 is 0 then
								set eachTxtPt to "__" & (my changeCase(eachTxtPt, "upper")) & "__"
							end if
							set theWhenO to theWhenO & eachTxtPt
						end repeat
					on error testtt4
						display dialog testtt4
					end try
					
				on error testtt4
					display dialog testtt4
				end try
				-- INSERT HERE
				my writeCue(lxCue, theWhatO, theWhenO, theMakeGroupO, theIncludeGroupsO, theUpTimeO, theDownTimeO)
				--		my setWhat(10, "Bla")
				--set theDoCommand to "record: 10"
				--my execLXC(theDoCommand)
				
				
			end repeat
			set i to 0
		end repeat
	end tell
on error errMsg number errorNumber
	if the errorNumber is equal to 666 then
		display dialog "Oops, somewhat illegal character in channel selection… I can't understand: " & thisCharacter
	else
		display dialog ("An unknown error occurred:  " & errorNumber as text) & errMsg
	end if
	set AppleScript's text item delimiters to tid
end try


on convertCueNo(this_text)
	set newLXQtxt to my replace_chars(this_text, ".", ",")
	set newLXQtxt2 to my replace_chars(this_text, ",", ".")
	try
		set this_num to newLXQtxt2 as number
	on error testtt1
		try
			set this_num to newLXQtxt as number
		on error testtt2
			display dialog testtt1 & testtt2
		end try
	end try
	return this_num
end convertCueNo

on replace_chars(this_text, search_string, replacement_string)
	set AppleScript's text item delimiters to the search_string
	set the item_list to every text item of this_text
	set AppleScript's text item delimiters to the replacement_string
	set this_text to the item_list as string
	set AppleScript's text item delimiters to ""
	return this_text
end replace_chars


on textItems from t
	try
		t's text items
	on error number -2706
		tell (count t's text items) div 2 to my (textItems from (t's text 1 thru text item it)) & my (textItems from (t's text from text item (it + 1) to -1))
	end try
end textItems

on changeCase(t, c)
	if (count t) is 0 then return t
	considering case
		if c is not in {"upper", "lower", "title", "sentence"} then
			error "The word \"" & c & "\" is not a valid option. Please use \"upper\", \"lower\", \"title\" or \"sentence\"."
		else if c is "upper" then
			set n to 1
		else
			set n to -1
		end if
		set d to text item delimiters
		repeat with n from n to n * 26 by n
			set text item delimiters to my alphaList's item n
			set t to textItems from t
			set text item delimiters to my alphaList's item -n
			tell t to set t to beginning & ({""} & rest)
		end repeat
		if c is in {"title", "sentence"} then
			if c is "title" then
				set s to space
			else
				set s to ". "
			end if
			set t to (t's item 1 & s & t)'s text 2 thru -1
			repeat with i in {s, tab, return, ASCII character 10}
				set text item delimiters to i
				if (count t's text items) > 1 then repeat with n from 1 to 26
					set text item delimiters to i & my alphaList's item n
					if (count t's text items) > 1 then
						set t to textItems from t
						set text item delimiters to i & my alphaList's item -n
						tell t to set t to beginning & ({""} & rest)
					end if
				end repeat
			end repeat
			set t to t's text ((count s) + 1) thru -1
		end if
		set text item delimiters to d
	end considering
	return t
end changeCase

on twoDigits(intensity)
	if intensity < 10 then
		return "0" & &#40;intensity as text&#41;
	else
		return &#40;intensity as text&#41;
	end if
end twoDigits

on writeCue&#40;cueNo, theWhat, theWhen, theMakeGroup, theIncludedGroups, theUpTime, theDownTime&#41;
	&#40;*	display dialog "LX Cue No&#58; " & cueNo & "
Make Group No&#58; " & theMakeGroup & "
Included Group Nos&#58; " & theIncludedGroups & "
Up time&#58; " & theUpTime & "
Down time&#58; " & theDownTime & "
The What&#58; " & theWhat & "
The When&#58; " & theWhen
*&#41;
	my modeLXC&#40;"live"&#41;
	--potentially make group
	if theMakeGroup is not "" then
		set theDoCommand to "record group!&#58; " & &#40;theMakeGroup as text&#41;
		my execLXC&#40;theDoCommand&#41;
		my modeLXC&#40;"live"&#41;
	end if
	--record the cue
	set theDoCommand to "record!&#58; " & &#40;cueNo as text&#41;
	my execLXC&#40;theDoCommand&#41;
	--potentially include group&#40;s&#41;
	-- make sure we are still in live
	my modeLXC&#40;"live"&#41;
	--	if theIncludedGroups is not "" then
	set AppleScript's text item delimiters to "#"
	try
		set the item_list20 to every text item of theIncludedGroups
		set AppleScript's text item delimiters to ""
	on error testtt20
		display dialog testtt20
	end try
	repeat with eachIncludedGroup in item_list20
		if eachIncludedGroup is not "" then
			set theDoCommand to "Group&#58; " & &#40;eachIncludedGroup as text&#41;
			my execLXC&#40;theDoCommand&#41;
		end if
	end repeat
	--	end if
	--set theWhat, theWhen and times
	tell application "LXConsole"
		tell the front document
			--			display dialog the when of currentCue as text
			set theCue to currentCue
			--			display dialog &#40;cueNumber of theCue&#41; as text
			if theWhat is "" then set theWhat to " "
			if theWhen is "" then set theWhen to " "
			if theUpTime is "" then set theUpTime to "5"
			if theDownTime is "" then set theDownTime to theUpTime
			set the what of theCue to &#40;theWhat as text&#41;
			set the when of theCue to &#40;theWhen as text&#41;
			set the upTime of theCue to &#40;theUpTime as real&#41;
			set the downTime of theCue to &#40;theDownTime as real&#41;
		end tell
	end tell
end writeCue

on execLXC&#40;theDoCommand&#41;
	tell application "LXConsole"
		if the front document exists then
			activate
			tell the front document to doCommand string theDoCommand
			--			display dialog theDoCommand as text
		end if
	end tell
end execLXC

on modeLXC&#40;theMode&#41;
	--   display dialog theMode as text
	tell application "LXConsole"
		if the front document exists then
			activate
			setMode the front document to &#40;theMode as text&#41;
		end if
	end tell
end modeLXC
There is probably still some tidying up for me to do, but my sore thumb has proven that it works like a treat (after acknowledging stupid amounts of Group Includes ;)...

Thanks for checking up on this :)!
Cheers,

Freddy
admin
Site Admin
Posts: 1643
Joined: Mon Nov 05, 2007 1:26 am
Contact:

Post by admin »

I've had a show today and not been able to go through your scripting. The key difference could be the way AppleScript works with threading and Grand Central Dispatch (how OS X divides and coordinates tasks). Stopping for the warning sheet allows other processes to catch up.

Are you running your script in "Live" or "Cues" mode? As I recall, some scripts that step between cues work best (or only work) in "Cues" (blind) mode.
freadZdead
Posts: 211
Joined: Sat Jun 01, 2013 8:23 am
Location: Adelaide, Australia

Post by freadZdead »

Yes, I operated in Live mode... because we are teching now, I've just had to confirm those dialogs and go with it, but will have a fiddle with running it in cues and report :)!
Cheers,

Freddy
admin
Site Admin
Posts: 1643
Joined: Mon Nov 05, 2007 1:26 am
Contact:

Post by admin »

The latest build (8905.2) contains two fixes for commands executed from AppleScript. The following script now works correctly:

Code: Select all

tell application "LXConsole"
	
	my modeLXC&#40;"live"&#41;
	set eachIncludedGroup to 1001
	set newPreset to 1000
	
	set theDoCommand to "record group!&#58; " & &#40;eachIncludedGroup as text&#41;
	my execLXC&#40;theDoCommand&#41;
	
	my modeLXC&#40;"live"&#41;
	
	set theDoCommand to "record cue!&#58; " & &#40;newPreset as text&#41;
	my execLXC&#40;theDoCommand&#41;
	
	set theDoCommand to "Group!&#58; " & &#40;eachIncludedGroup as text&#41;
	my execLXC&#40;theDoCommand&#41;
	
end tell

on execLXC&#40;theDoCommand&#41;
	tell application "LXConsole"
		if the front document exists then
			activate
			tell the front document to doCommand string theDoCommand
			--         display dialog theDoCommand as text 
		end if
	end tell
end execLXC

on modeLXC&#40;theMode&#41;
	--   display dialog theMode as text 
	tell application "LXConsole"
		if the front document exists then
			activate
			setMode the front document to &#40;theMode as text&#41;
		end if
	end tell
end modeLXC
freadZdead
Posts: 211
Joined: Sat Jun 01, 2013 8:23 am
Location: Adelaide, Australia

Post by freadZdead »

Thank you, amazing!

The show went up, and from focussing specials until recording the entire show, we did it in 2h20 :)! I guess it is a good model that certainly wouldn't fit all shows, but under these particular circumstances was quite a saving grace...

Thanks for the fix, too - will save my thumb for the future :)!
Cheers,

Freddy
Post Reply