1.1 --- a/archive_wiki.py Tue Jan 08 18:25:47 2008 +0100
1.2 +++ b/archive_wiki.py Tue Jan 08 18:47:43 2008 +0100
1.3 @@ -1,8 +1,14 @@
1.4 #!/usr/bin/env python
1.5
1.6 -import sys, os
1.7 +import sys, os, commands
1.8
1.9 -wiki_dir, archive_dir = sys.argv[1:3]
1.10 +try:
1.11 + wiki_dir, archive_dir = sys.argv[1:3]
1.12 +except ValueError:
1.13 + print "For archiving, please specify the Wiki directory and a target archive directory."
1.14 + print "For restoring, please specify the archive directory and a target Wiki directory."
1.15 + sys.exit(1)
1.16 +
1.17 dry_run = ("-n" in sys.argv)
1.18
1.19 pages = os.path.join(wiki_dir, "wiki", "data", "pages")
1.20 @@ -59,7 +65,9 @@
1.21 finally:
1.22 f.close()
1.23
1.24 - cmd = "cp %s %s" % (os.path.join(page_revisions, current), os.path.join(archive_page_revisions, "00000001"))
1.25 + cmd = "cp %s %s" % tuple(
1.26 + map(commands.mkarg, (os.path.join(page_revisions, current), os.path.join(archive_page_revisions, "00000001")))
1.27 + )
1.28 print cmd
1.29 if not dry_run:
1.30 os.system(cmd)
1.31 @@ -72,7 +80,9 @@
1.32 if not dry_run and not os.path.exists(archive_attachments_dir):
1.33 os.mkdir(archive_attachments_dir)
1.34
1.35 - cmd = "cp %s %s" % (os.path.join(attachments_dir, "*"), archive_attachments_dir)
1.36 + cmd = "cp %s %s" % (
1.37 + os.path.join(commands.mkarg(attachments_dir), "*"), commands.mkarg(archive_attachments_dir)
1.38 + )
1.39 print cmd
1.40 if not dry_run:
1.41 os.system(cmd)
1.42 @@ -80,6 +90,6 @@
1.43 print
1.44
1.45 print "Now run the following, if adding to a live Wiki:"
1.46 -print "chown -R www-data: %s/www %s/wiki" % (archive_dir, archive_dir)
1.47 +print "chown -R www-data: %s" % os.path.join(archive_dir, "wiki")
1.48
1.49 # vim: tabstop=4 expandtab shiftwidth=4