.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 3: The Awakening

Reply
 
Thread Tools Display Modes
  #11  
Old November 4th, 2006, 10:15 AM

PDF PDF is offline
Colonel
 
Join Date: Apr 2002
Location: Near Paris, France
Posts: 1,566
Thanks: 0
Thanked 0 Times in 0 Posts
PDF is on a distinguished road
Default Re: Automatic backup of turn files

Lolly,
Sure I did test it and it works fine under XP !
There's even a nice log file to knwo what happened .

About my request to change the path I've found where the script should be changed, in the Backup variable definition, but ain't sure about how to type those "\" or "/" according to this language conventions and with possible OSes incompatibilities... so I let you do it !

As for pbem there are in fact two different needs :
A simple player has to send its 2h file but doesn't "host" as such, and there's no means to detect if he wants to really end the turn and send it or if he would like to send it later... Plus there's only 1 simple mail with the .2h file to send to the hosting player. Maybe a small tool can help, but not much,as anyway the player has to make an action.
I was rather thinking of something for the hoster, who has to send all .trn files (+ ftherland , some don't but it makes a backup indeed !) to all of the players.
Some even make separate emails for each player with each turn file attached !
Here a tool would be great, and it could be easily automated to follow the hosting.
Make it in Python, Ruby, or whatever snake species or gem type you want, it'll be great anyway !

And what did reply your husband for the kiss btw ? ..
Reply With Quote
  #12  
Old November 4th, 2006, 02:45 PM

Lollipop Lollipop is offline
Private
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Lollipop is on a distinguished road
Default Re: Automatic backup of turn files

Incredible, but true. I did write some documentation, completely voluntary, without someone threatening me with a shotgun.

Here's the readme of the new version:
Code:
*Synopsis*

A python script to auto-backup your dom3 games

*Requirements*
python 2.4 or better. Get it from http://www.python.org/download/. If you have Civ 4,you have it
(I hope

zlib. Get it from http://gnuwin32.sourceforge.net/packages/zlib.htm. Linux has it (usually)

*Installation*

- extract dom3backup.py to your dominions3 directory

- Linux:
create a shell script like:
#!/bin/bash
./dom3 --scoredump --preexec './dom3backup.py -q' &

chmod +x <your name goes here> business as usual

-Windows:
-create a link of your dom3.exe (right drag to a location of your choice and select 'create link here')

-right click on your link, select 'properties' and find the line containing 'dom3.exe'

-add ' --scoredump --preexec "<Dom3 path>\dom3backup.py -q"'
the ' are only there to show blanks, don't enter. The " however are required.

-enter further arguments. Explained below

-Mac:
sorry, no idea

*Usage*
dom3backup always backups the game, you've last played. If you want to backup another game, use the
-g option.
dom3backup uses a simple substitution. Whenever you specify a directory, #name is replaced with the
current game name (either last game played or specified with -g), #turn is replaced with the
current turn-number.
Relative paths are relative to <dom3>/savedgames

-a ARCHIVE, --archive=ARCHIVE
create archive <name> now. Usually used from the commandline
-b BACKUPDIR, --backupdir=BACKUPDIR
create backup in backupdir. Default:
<dom3>/savedgames/#name.backup.
Example:
last game you played was 'ermor1'
no arguments:
backup all your files to <dom3>/savedgames/ermor1.backup/
-b ./#name/backup
backup all your files to <dom3>/savedgames/ermor1/backup/
-b c:/d3archive/#name
backup all your files to c:/d3archive/ermor1/
-b ../saved/#name.#turn
all your files to '<dom3>/saved/ermor.1',then <dom3>/saved/ermor.2' etc.
-b ../saved/#name/#turn
all your files to '<dom3>/saved/ermor/1',then <dom3>/saved/ermor/2' etc.
-d ARCHDIR, --archdir=ARCHDIR
create Zipfiles in archdir. archdir must exists.
Default: <dom3>/archivedgames. Absolute or relative paths as the -b option
-f FREQ, --freq=FREQ create a Zipfile every <n> turn(s). Default: 0 (no
zipfile)
-g GAME, --game=GAME backup game <name>. Otherwise backup latest game
-m MAXFILES, --maxfiles=MAXFILES
keep max. <n> Zipfiles. Delete oldest. Default: 0
(keep all)
-q, --quiet output messages are written to <dom3>/dom3backup.log
-r, --restore restore files form backup-dir. Use only from the command line
-t TURN, --turn=TURN assume turn <n>. Only useful with -r. Use from
commandline only
--nocopy don't copy files to backup-dir. Default: False

*Putting it all together*
Assuming windows...
Ex.1) dom3.exe --scoredump --preexec "<Dom3 path>\dom3backup.py -q"
once you hit 'e', your files are copied to <Dom3 path>\savedgames\<gamename>.backup
Ex.2) dom3.exe --scoredump --preexec "<Dom3 path>\dom3backup.py -q -f 1"
same as above, but every turn a zip file is created in <Dom3 path>/archivedgames
The zip-file is named <game-name>-Turn<turnnumber>.zip
Ex.3) dom3.exe --scoredump --preexec "<Dom3 path>\dom3backup.py -q -f 4"
same as above, but zip files are only created on Turn1, Turn 5, Turn9 etc.
Ex.4) dom3.exe --scoredump --preexec "<Dom3 path>\dom3backup.py -q -f 4 -m 2"
same as above, but only 2 zip-files are kept at any time. So if <name>-Turn9.zip is created, <name>-Turn1.zip is deleted
Ex.5) dom3.exe --scoredump --preexec "<Dom3 path>\dom3backup.py -q -b ../saved/#name"
your files are copied to '<dom3>/saved/<gamename>. Of course you're free to also create
zip files, see above
Ex.6) dom3.exe --scoredump --preexec "<Dom3 path>\dom3backup.py -q -b ../saved/#name/#turn"
copied to <dom3>/saved/<gamename>/1,<dom3>/saved/<gamename>/2 etc

Restoring backups:
If you don't used -b, the *last* turn from <Dom3 path>\savedgames\<gamename>.backup is
restored.
Same as above, if you used -b *and* no #turn substitution
If you used #turn substitution, you *must* use the -t argument

So start a shell and:
Ex.1) python dom3backup.py -r
= restore last turn
Ex.5) python dom3backup.py -r -b ../saved/#name
same as above
Ex.6) now you must pass a turn number
python dom3backup.py -r -b ../saved/#name/#turn --turn 1
start from scratch
*Caveats*
Windows: you must use -q
Windows: use / in pathnames, not \
All: if you mess around with the savedgames directory, the auto-detection might no longer work.
Files containing a '.' and newlords are ignored, but if you copy the 'MyFavoritePorns' folder
to savedgames, your pbem-partner might be up for a surprise

GPL applies......

Comments to ZarahNeander at t-online dot de

04/11/06 Pia Kraft


Attached Files
File Type: zip 467045-dom3backup.zip (4.6 KB, 140 views)
Reply With Quote
  #13  
Old November 4th, 2006, 03:22 PM

Lollipop Lollipop is offline
Private
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Lollipop is on a distinguished road
Default Re: Automatic backup of turn files

Quote:
PDF said:
Lolly,
Sure I did test it and it works fine under XP !
There's even a nice log file to knwo what happened .
Thanks much, good to know

Quote:
About my request to change the path I've found where the script should be changed, in the Backup variable definition, but ain't sure about how to type those "\" or "/" according to this language conventions
Done. See the new attachment. The substitute mechanism is quite flexible and should satisfy even you

Regarding / and \. Internally I only used /, so it seems, that python is smart enough to convert / to \ under XP. It *might* even necessary to use / in arguments passed to the script.

Quote:
I was rather thinking of something for the hoster, who has to send all .trn files (+ ftherland , some don't but it makes a backup indeed !) to all of the players.
Some even make separate emails for each player with each turn file attached !
Here a tool would be great, and it could be easily automated to follow the hosting.
I see. Thanks for elaborating. Shouldn't be too hard. The only problem, while I don't run unit tests and such, I like to test my software at least rudimentary, which means, I have to host a pbem game. And a pbem with only a host is somewhat pointless. And I don't want to incur the eternal wrath of players by using a real pbem as my testbed. So I'm looking for some kind of sacrificial lamb...


Quote:
And what did reply your husband for the kiss btw ? ..
Let me put it this way: I won't give away my age, suffice to say, I'm seasoned, quite seasoned
Reply With Quote
  #14  
Old November 4th, 2006, 08:10 PM

PDF PDF is offline
Colonel
 
Join Date: Apr 2002
Location: Near Paris, France
Posts: 1,566
Thanks: 0
Thanked 0 Times in 0 Posts
PDF is on a distinguished road
Default Re: Automatic backup of turn files

Hi again Lolly,
Well, the new version is even better, thanks !
I just have have a problem, the -d (archive dir) option doesn't work for me, whatever I specify all archive zips end up in savedgames directly !

Could I just ask (again) for a direct "restore" command to which one would just have to say (type rather)
"restore <game> <turn>" ?

I'm volunteer to test a pbem tool with you also

And I kiss you whatever your age may be, I'm not that young either !
Reply With Quote
  #15  
Old November 4th, 2006, 09:23 PM

Lollipop Lollipop is offline
Private
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Lollipop is on a distinguished road
Default Re: Automatic backup of turn files

Hi PDF,

The -d thingie is weird, it works for me. The zip file is created in savedgames and then moved to <archdir>, so it's safe to say, that the 'move' command failed.

- the archdir *must* exist. This is an anachronism from the early development, and it also means, that the #turn substitution doesn't work (except you're busy creating directorys). I'll fix that soon.

- It might be a /\ problem. Unfortunately I don't have XP at home.

You might fire up a shell and start dom3backup manually. Most likely it throws an exception & most likely 'path not found' (shame on me, I didn't catch exceptions)

With regard to a 'restore' command, I image that dom3backup on XP with it's stone age shell is really hard to use. However the public interest isn't exactly overwhelming. I admit that the thing is hard to setup (only partly my fault) and that writing user documentation isn't my strongest side. But atm I'm not sure if I continue public development. Programming is fun for me, writing documentation not.

I will however try my hands on the pbem tool, if only cause I'm curious how python handles mime (which seems quite reasonable, another chance lost to bash python on #python-lang ). So thanks for volunteering.

Pia
Reply With Quote
  #16  
Old November 5th, 2006, 01:26 PM

PDF PDF is offline
Colonel
 
Join Date: Apr 2002
Location: Near Paris, France
Posts: 1,566
Thanks: 0
Thanked 0 Times in 0 Posts
PDF is on a distinguished road
Default Re: Automatic backup of turn files

Hi again !
I'd a look at the code, maybe there's a problem with the way default archdir is defined as ../archivedgames ... but I can't get any path to work with archdir ! OTOH the backup path system works perfectly.
Additionaly I can't see the messages because the window closes too fast, and not everything is traced in the log...

I've tried to run the script in debug mode with IDLE to see the variables but I don't know how to "trace variable" in the debugger.

Well I think I'll don't bother anymore and let my archives accumulate in savedgames folder !
Reply With Quote
  #17  
Old November 5th, 2006, 04:10 PM

Lollipop Lollipop is offline
Private
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Lollipop is on a distinguished road
Default Re: Automatic backup of turn files

send you a PM, PDF
Reply With Quote
  #18  
Old June 10th, 2007, 09:09 AM
lch's Avatar

lch lch is offline
General
 
Join Date: Feb 2007
Location: R'lyeh
Posts: 3,861
Thanks: 144
Thanked 403 Times in 176 Posts
lch is on a distinguished road
Default Re: Automatic backup of turn files

Nice python scripts, thanks.

I have been using some crude bash scripting myself, you could drop this in your ~/.bashrc if you dare:

Code:
function archive {
if test $# -lt 1; then return; fi
tar czvf $(basename $1)-$(date +%s).tgz $@
}

function archive-title {
if test $# -lt 2; then return; fi
argv=($@)
tar czvf $(date +%s)-$1.tgz ${argv[@]:1}
}


The first "archive" command takes as parameter the path to your game in your savegame directory (you could chmod into the savegame directory first to save typing) and adds a timestamp to the archive, the second "archive-title" command expects some title as first parameter for the savegame and prefixes it with a timestamp (in case you want to have a better view over what the savegame is about, like "SpammedMindHunt").

Yes, that code is ugly and I never went around to improve it, so you better use the python script instead.
__________________
Come to the Dom3 Wiki and help us to build the biggest Dominions-centered knowledge base on the net.
Visit my personal user page there, too!
Pretender file password recovery
Emergency comic relief
Reply With Quote
  #19  
Old June 10th, 2007, 01:21 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Automatic backup of turn files

I set every game to run a --preexec and a --postexec which usually start out as blanks. But that way if the game gets interesting I can easily add commands to those. Such as having the pre exec do a zip of the game before each hosting.

Thats one of the many MANY reasons that I pushed to get those added to the command line. It handles so many things
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 07:58 AM.


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