Back to index

moin  1.9.0~rc2
152_to_1050300.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """
00003     Migration from moin 1.5.2 to moin 1.5.3
00004 
00005     We just make sure that there is a "meta" file in your data directory that
00006     stores the "revision" level of it (so future mig scripts can tell if they
00007     need to run or not [e.g. because you already have run them]).
00008 
00009     This is the last "old style" migration script.
00010 
00011     Steps for a successful migration:
00012 
00013         1. You do NOT need to stop your wiki for this mig script.
00014 
00015         2. Change directory to: .../MoinMoin/script/old/migration
00016 
00017         3. Run this script as a user who may write to the data_dir of your wiki
00018            and supply the pathes to the data_dir you want to migrate. If you
00019            have multiple wikis, you may specify multiple pathes on the command
00020            line:
00021 
00022            sudo -u www-data ./152_to_1050300.py /my/path/to/data
00023 
00024         4. That's it.
00025            Future mig scripts now can auto-detect the data_dir revision level.
00026 
00027     @copyright: 2006 Thomas Waldmann
00028     @license: GPL, see COPYING for details
00029 """
00030 import sys, os
00031 
00032 # Insert THIS moin dir first into sys path, or you would run another
00033 # version of moin!
00034 sys.path.insert(0, '../../../..')
00035 
00036 def migrate(dirlist):
00037     errors = warnings = success = 0
00038     for dir in dirlist:
00039         if not (os.path.exists(os.path.join(dir, 'pages')) and
00040                 os.path.exists(os.path.join(dir, 'user'))):
00041             print "Error: Skipping %s - does not look like a data_dir" % dir
00042             errors += 1
00043         else:
00044             fname = os.path.join(dir, 'meta')
00045             if os.path.exists(fname):
00046                 print "Warning: There already is a meta file there, skipping %s" % dir
00047                 warnings += 1
00048             else:
00049                 try:
00050                     f = open(fname, 'w')
00051                     f.write("data_format_revision: 01050300\n") # 01050300 = 1.5.3(.0)
00052                     f.close()
00053                     success += 1
00054                 except:
00055                     errors += 1
00056                     print "Error: Exception when migrating %s" % dir
00057     print "%d data_dirs successfully migrated, %d warnings, %d errors." % (success, warnings, errors)
00058 
00059 if __name__ == '__main__':
00060     if len(sys.argv) < 2:
00061         data_dirs = ['data', ]
00062     else:
00063         data_dirs = sys.argv[1:]
00064     migrate(data_dirs)
00065