Background: The 3D rendering divsion within our company needs a solution to automate the deployment of irradience maps to nodes in the farm. This process was being done by hand and was very time consuming. Given the fact that more nodes have been and will continue to be added a different process was needed.
Specifics:
¢ Script will be ran from a Mac.
¢ Render nodes are running XP Pro - 64 Bit
¢ Render nodes are sharing the root of their C: drive as C
¢ Maps must be place in the C:VRmaps folder
¢ IP’s are 10.2.2.x : x corresponds with the node number
Solution: This is the solution I came up with. It has NOT been thoroughly tested yet, but that is something I will be doing in the next day or two.
Help: Feel free to browse the script and let me know if you have any questions/suggestions/forseen problems/optimizations/etc.
And of course, Happy Scripting!
property Author : "James Nierodzik"
property Company : "FireStar Communications"
property ProjectName : "VRmap Push"
property FileName : " vr_map.scpt"
property version : "1.0.0"
property VersionDate : "2007_05_22"
property Created : "5/22/07"
property Updated : "5/23/07"
(* MAIN CODE BLOCK *)
property _startIP : 5
property _finishIP : 53
global _logRef
on run
set {_radianceMaps, _mapNames} to Build_Map_Info()
set _machineList to Build_Machine_List()
set _exclusionList to Build_Exclusion_List(_machineList, _mapNames)
Open_Log(_exclusionList, _mapNames)
Copy_Irradience_Maps(_radianceMaps, _exclusionList)
Close_Log()
end run
(* / MAIN CODE BLOCK *)
--=========================================================================================================
(* SUBROUTINE CODE BLOCK *)
on Build_Map_Info()
tell application "Finder"
set _mapNames to ""
activate
set _irradienceMaps to choose file with prompt "Please select the irradience map(s) to distribute." with multiple selections allowed
repeat with _singleMap in _irradienceMaps
set _mapNames to _mapNames & tab & "¢ " & (name of _singleMap) & return
end repeat
return {_irradienceMaps, _mapNames}
end tell
end Build_Map_Info
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on Build_Machine_List()
set _machineList to {}
repeat with i from _startIP to _finishIP
if i < 100 then
if i < 10 then
set i to "00" & i
else
set i to "0" & i
end if
end if
set end of _machineList to "Debris" & tab & tab & i
end repeat
return _machineList
end Build_Machine_List
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on Build_Exclusion_List(_machineList, _mapNames)
activate
set _namedExclusionList to choose from list _machineList with title "Select the nodes to exclude" with prompt ("For irradience map(s):" & return & _mapNames) ¬
cancel button name "Cancel" with multiple selections allowed and empty selection allowed
if _namedExclusionList is false then
stop
else
set _exclusionList to {}
repeat with _node in _namedExclusionList
set end of _exclusionList to ((text -3 through -1 of _node) as integer)
end repeat
return _exclusionList
end if
end Build_Exclusion_List
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on Copy_Irradience_Maps(_irradianceMaps, _exclusionList)
tell application "Finder"
repeat with _nodeNumber from _startIP to _finishIP
if _nodeNumber is not in _exclusionList then
try
mount volume "smb://<static user name>:<static password>@10.2.2." & _nodeNumber & "/C"
on error _errMsg number _errNum
my Write_To_Log(("Error mounting node: " & _nodeNumber & return & _errNum & ": " & _errMsg))
end try
repeat with _singleMap in _irradianceMaps
try
if name extension of _singleMap is "vrmap" then duplicate _singleMap to folder "C:VRmaps"
on error _errMsg number _errNum
my Write_To_Log((tab & tab & "Error copying: " & (name of _singleMap) & tab & tab & _errNum))
end try
end repeat
try
eject disk "C"
on error _errMsg number _errNum
my Write_To_Log(("Error ejecting node: " & _nodeNumber & return & _errNum & ": " & _errMsg))
my Close_Log()
display dialog "A critical error has occured." & return & "Please check the log for more information." buttons {"Ok"} default button "OK" with icon stop
stop
end try
end if
end repeat
end tell
end Copy_Irradience_Maps
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on Open_Log(_exclusionList, _mapNames)
set_deskPath to path to desktop as Unicode text
set _logPath to deskPath & "VR-Log.txt"
try
close access file _logPath
end try
set _logRef to (open for access file _logPath with write permission)
set eof _logRef to 0
set _divide to "======================================================"
set _header to _divide & return & ProjectName & tab & tab & tab & "Version: " & version & return & return
set _header to (_header & "Run Time: " & (current date) as string) & return & return
set _header to _header & _divide & return & return
if (count _exclusionList) is 0 then
set _exclusionList to "None"
else
set {TID, text item delimiters} to {text item delimiters, ", "}
set _exclusionList to _exclusionList as string
end if
set _header to _header & "Tagret nodes " & _startIP & " through " & _finishIP & tab & "Excluding: " & _exclusionList & return & return
set _header to _header & "Copying Maps:" & return & _mapNames
set _header to _header & _divide
write _header & return to _logRef
return _logRef
end Open_Log
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on Write_To_Log(_errString)
write _errString & return to _logRef
end Write_To_Log
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
on Close_Log()
write return & return & "Finished" to _logRef
close access _logRef
end Close_Log
(* /SUBROUTINE CODE BLOCK *)