Hey there,
How would i go about writing a python file that will delete a folder on the slave after a task is completed.
For some reason the 3dsmax 2009 profile (enu folder) keeps getting corrupted and the fix is to just delete it. I want to automate this deleting after each task completes. is a .py file the best way to do this? i have no idea what the code would be. would it be simple?
Thanks
Chris
import os
os.system(‘rd /s /q “/Documents and Settings/All Users/Application Data/Autodesk/3DSMAX/11/ENU”’)
os.system(‘rd /s /q “/Documents and Settings/render/Application Data/Autodesk/3DSMAX/11/ENU”’)
os.system(‘rd /s /q “/Documents and Settings/render/Local Settings/Application Data/Autodesk/3dsmax/2009 - 32bit/enu”’)
the code does the trick within the pyton software but when the slave runs it it get the below error
0: INFO: Executing Post Task Script: \Deadline-host\deadlinerepository\scripts\Slaves\delete.py
0: WARNING: Failed to execute the script because: Python Error: No module named os (IronPython.Runtime.Exceptions.PythonImportErrorException)
(System.Exception)
would it be easier to add the delete folder instructions into the 3ds max plugin after the shutdown is complete?
Hi Chris,
Deadline uses IronPython, which is essentially python written on top of .NET. IronPython only implements the built in libraries. To access standard libraries like os, you need to install python on the machine and configure some things so that IronPython sees them. More details are explained in this thread I found:
lists.ironpython.com/pipermail/u … 04762.html
However, because IronPython supports almost all .NET classes, you could use .NET code in your IronPython script to accomplish what you want (note that this code hasn’t been tested, but you should get the idea):
from System.IO import *
Directory.Delete( "C:/Documents and Settings/All Users/Application Data/Autodesk/3DSMAX/11/ENU", True )
Directory.Delete( "C:/Documents and Settings/render/Application Data/Autodesk/3DSMAX/11/ENU", True )
Directory.Delete( "C:/Documents and Settings/render/Local Settings/Application Data/Autodesk/3dsmax/2009 - 32bit/enu", True )
Here is some documentation on Directory.Delete():
msdn.microsoft.com/en-us/library/fxeahc5f.aspx
You could add also add the code directly to the 3dsmax.py file in the 3dsmax plugin folder when it’s shutting down max.
Cheers,
Great.
will use the .net code. have installed ironpython and the example code u sent seems to work. Where within the 3dsmax.py should this code be? I needs to happen once max has been closed (either forced or not).
I think the best place for it would be in the EndJob function found around line 56:
def EndJob( self ):
LogInfo( "End Job called - shutting down 3dsmax plugin" )
# End the 3dsmax job (unloads the scene file, etc).
self.MyMaxController.ResetBitmapPager()
self.MyMaxController.EndMaxJob()
# Shutdown 3dsmax.
self.MyMaxController.ShutdownMax()
The System.IO import line is already declared at the top of the python script, so you would just need to add the delete calls to this function.
def EndJob( self ):
LogInfo( "End Job called - shutting down 3dsmax plugin" )
# End the 3dsmax job (unloads the scene file, etc).
self.MyMaxController.ResetBitmapPager()
self.MyMaxController.EndMaxJob()
# Shutdown 3dsmax.
self.MyMaxController.ShutdownMax()
Directory.Delete( "C:/Documents and Settings/All Users/Application Data/Autodesk/3DSMAX/11/ENU", True )
Directory.Delete( "C:/Documents and Settings/render/Application Data/Autodesk/3DSMAX/11/ENU", True )
Directory.Delete( "C:/Documents and Settings/render/Local Settings/Application Data/Autodesk/3dsmax/2009 - 32bit/enu", True )
well the .net code works but i need an if switch as it errors if the file dosen’t exist. sorry about this… thanks for the help.
Something like this should do the trick:
if Directory.Exists( "C:/Documents and Settings/All Users/Application Data/Autodesk/3DSMAX/11/ENU" ):
Directory.Delete( "C:/Documents and Settings/All Users/Application Data/Autodesk/3DSMAX/11/ENU", True )
Hurrah seems to be working fine…
this means max opens up like a fresh install every time so hopefully no more crashes from corrupt max profiles
Would it not be better to work out why the corruption is taking place as it might be causing your renders to be wrong?
Are you using local profile or root profile for your 3dsmax.ini?
From your previous posts it looks like you are using the local profile based (default) system. Have you tried switching the flag:
[Least User Privilege]
useUserProfiles=1 to 0
in the file:
C:\3dsMax2009x64\InstallSettings.ini or whereever you install 3dsMax to…
to try and fix the corruption of I guess, the 3dsmax.ini file?
From experience, 3dsMax runs a lot smoother in root rather than user profile mode…especially in 3dsMax2008+
MIke
we have a lot of freelancers in and out of the building which given the chance would install every plugin/trial-software under the sun so the farm (and client computers) auto logs into a render profile (roaming) with ‘user rights’ and a global policy to to tweak a few things (prevent registry changes etc).
If any of the clients suites are unused for a length of time they auto log into the same render profile. It’s not an option to give any user admin rights so the render profile is givven permission to all autodesk/frantic folders locally and within the registry.
As for the ENU files, we still don’t know why they’re getting corrupted though 3ds max is often terminated forcefully by deadline which may be the cause. ALl i know is that deleting the ENU (3dsmax profile) allows 3ds max to open again. The only downside is that i can’t do this for user profiles and they would loose there personalized settings within max as this is held within the enu folder.