.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Dominions 3: The Awakening (http://forum.shrapnelgames.com/forumdisplay.php?f=138)
-   -   Backup tool (http://forum.shrapnelgames.com/showthread.php?t=39125)

MaxWilson June 5th, 2008 01:25 AM

Backup tool
 
I realized that one reason my turns go so slow even in SP is because, having spent hours or days developing a strong gaming position, I don't want to throw it away with stupid errors like forgetting to re-hire Obscuro when I badly need an air mage. It makes me paranoid and I check everything thrice. (It's sort of the same reason that makes Axis and Allies play so slowly if you're playing against someone who rigidly enforces the phases and won't let you attack if you make a noncombat move.) So, I decided to address this by writing a quick little Python script that backs up my files each turn.

Remember that the distinction between a script and a program is that a program is opaque and a script is transparent and meant to be fiddled with by the end user--i.e. my error handling in this script is not robust. Oh well. You may still find it useful. Save it to your dom3 root directory and run dom3 with the --preexec switch and the name of the game you'll be playing. On Windows this would be

dom3 --preexec "backup.py <gamename>"

Yeah, I know, having to type in the name of the directory to back up is onerous, etc. Maybe I'll fix it later but right now this is what I'm using.

-Max

edit: That's funny. The attachment is gone, and there's no option to create a new one. I'll paste in the text here directly, although now maybe I'll use Ich's version instead. My script:

import sys
import os
if len(sys.argv) != 2:
print "Usage: backup <gamename>"
exit()

def execute(cmd):
print cmd
os.system(cmd)

gamedir = 'savedgames\%s' % sys.argv[1]
print 'Backing up', gamedir
execute('cd %s' % gamedir)
execute('mkdir %s\\backup' % gamedir) # Could already exist, but oh well, ignore the error
execute('erase %s\\backup\\* /Q' % gamedir)
execute('copy %s\\* %s\\backup /Y' % (gamedir, gamedir))

SsSam June 5th, 2008 08:34 AM

Re: Backup tool
 
Silly me. Where can I dl the script?

lch June 5th, 2008 10:42 AM

Re: Backup tool
 
Quoting myself from the Tools & Tutorials thread:

Lollipop wrote a solution to automatically backup turns in Python.

lch June 5th, 2008 11:25 AM

Re: Backup tool
 
Quote:

MaxWilson said:
edit: That's funny. The attachment is gone, and there's no option to create a new one.

There is. When you edit your post, there's a checkbox titled "I want to preview my post and/or attach a file".

But your Python script is more like a wrapper for a shell script, anyway. Not really portable between system, I think.

MaxWilson June 5th, 2008 12:23 PM

Re: Backup tool
 
Absolutely. Lolly's is much better.

P.S. You're right, it gives you the option when you hit "Continue." I *did* tell it to attach the attachment. I even attached it again when I edited the post to add the script in the message body, but it's still not there. Strange.


All times are GMT -4. The time now is 05:57 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.