I already wrote a very simple version of this function. As for every other
script I ever wrote - it's not finished and pretty straight forward.
Of course, it doesn't answer your question. Still, it relates, so here it
is.
By the way, it's designed to be added as a onScriptClose function.
def remAutosave():
script = nuke.Root()['name'].getValue()
autoS = script + '.autosave'
if os.path.isfile(autoS):
ask = nuke.ask('Autosave file found.\nDelete?')
if ask == True:
os.remove(autoS)
Ron Ganbar
email: [email protected]
tel: +44 (0)7968 007 309 [UK]
+972 (0)54 255 9765 [Israel]
url: http://ronganbar.wordpress.com/
On 18 November 2011 18:00, Abraham Schneider <[email protected]> wrote:
> Hi there!
>
> I wanted to write a callback function to automatically delete
> the .autosave file, if the script was closed correctly. I find it very
> irritating to get the 'there is a newer autosave' message when loading
> a script, even if the script was closed properly and on purpose
> without saving it when closing. I'd only like to keep the autosave
> file if Nuke crashes or something like that.
>
> Problem is: my scripting skills aren't that good. I wanted to start
> with checking if an autosave file exists. To do this, I wanted to use
> the actual value for the AutoSaveName set in the preferences. By
> default, this value is set to '[firstof [value root.name] [getenv
> NUKE_TEMP_DIR]/].autosave'. I'm able to get the string from the
> preferences with something like:
>
> myprefs = nuke.toKnob('preferences')
> print myprefs.knob('AutoSaveName').**getValue()
>
> or
>
> print nuke.tcl('value preferences.AutoSaveName')
>
>
> that always gives me the string '[firstof [value root.name] [getenv
> NUKE_TEMP_DIR]/].autosave'. But what I'd really want to get is the
> evaluated value of the string, so I tried it with 'eval', 'expr',
> 'expression', etc., but didn't get any result. The only way a got a
> result was when I used "print nuke.tcl('eval [value
> preferences.AutoSaveName]')":
>
> print nuke.tcl('eval [value preferences.AutoSaveName]')
> # Result:
> Traceback (most recent call last):
> File "<string>", line 1, in <module>
> RuntimeError: Syntax error at "/mnt/frozone/projects/vier_**hunde_1234"
>
> So it IS doing something, but there seems to be an syntax error. But I
> can't see what the error is.
>
> Can anyone explain to me why that doesn't work and/or how to get the
> proper result that Nuke also uses internally as the path for the
> autosave file? Or better: what would be a good way to delete the
> autosave file of the script that I'm closing on purpose without saving?
>
> Thanks for any help and sorry if the code above hurts your eyes, I'm
> just starting to script in Nuke and find the mixture of TCL and Python
> still very confusing.
>
> Best regards,
>
> Abraham
>
>
> Abraham Schneider
> Senior VFX Compositor
>
>
> ARRI Film & TV Services GmbH
> Tuerkenstr. 89
> D-80799 Muenchen / Germany
>
> Phone +49 89 3809-1269
>
> EMail [email protected]
> www.arri.de/filmtv
> ______________________________**__
>
>
> ARRI Film & TV Services GmbH
> Sitz: München Registergericht: Amtsgericht München
> Handelsregisternummer: HRB 69396
> Geschäftsführer: Franz Kraus, Dr. Martin Prillmann, Josef Reidinger
> ______________________________**_________________
> Nuke-python mailing list
> Nuke-python@support.**thefoundry.co.uk<[email protected]>,
> http://forums.thefoundry.co.**uk/ <http://forums.thefoundry.co.uk/>
> http://support.thefoundry.co.**uk/cgi-bin/mailman/listinfo/**nuke-python<http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python