Wordpress SVN Update Python Code

Wrote this python code to assist in updating Wordpress versions via SVN. The .py script, called update-wp.py, simply sits under your DocumentRoot folder. In this case, I have the directory set to www. Note that you must have installed your original Wordpress version using the SVN checkout command for any of this to work. More on that can be found here.

#!/usr/bin/python
#Update Wordpress from SVN
#Michael Bevilacqua 3/7/2009
 
import sys, subprocess
 
if len(sys.argv) < 2:
    print 'Please input version to update too (ie. 2.7.1)'
    sys.exit()
 
if sys.argv[1].startswith('--'):
    option = sys.argv[1][2:]
    # fetch sys.argv[1] but without the first two characters
    if option == 'version':
        print 'Version 1.0 3/7/2009 Michael Bevilacqua'
    elif option == 'help':
        print '''\
 
This program will update the Wordpress installation
in www to the latest version that you must specify
as the first argument like so:
./update-wp.py 2.7.1
 
You can find a list of Wordpress versions by browsing
to http://svn.automattic.com/wordpress/tags/
 
Options include:
--version : Prints the version number
--help    : Display this help'''
 
    else:
        print 'Unknown option.'
        sys.exit()
    else:
 
        version = sys.argv[1]
 
        print "Updating Wordpress installation in www to version %s" % version
 
        svn = 'svn sw http://svn.automattic.com/wordpress/tags/%s/ www/' % version
 
        subprocess.call(svn, shell=True)
 
        print ""
        print ""
        print "Please run wp-admin/upgrade.php to complete this update."