#!/usr/bin/python"""Code under GPL, (c) Luc Stepniewski <lstep@adelux.fr>Using instructions from Bill Woodward, onhttp://groups.google.com/group/turbogears/msg/24bf35000bfe01f4Will reinstall all the dependencies of TurboGears on your system.ATTENTION: This code will erase some of your modules, *please*pay attention to what this code does, You are responsible forexecuting this code. I am in no way responsible in the eventualcase where this code erases all of your hard disk."""import os, glob, shutil, syspackageList = ['CherryPy-*', 'cherry*', 'FormEncode-*', 'SQLObject-*', 'kid-*', 'TestGear-*', 'nose-*', 'PasteDeploy-*', 'PasteScript-*', 'PyProtocols-*', 'RuleDispatch-*', 'TurboGears-*']# Order of thirdPartyDir is importantthirdPartyDir = ['formencode', 'kid', 'sqlobject', 'cherrypy']pythonPath = '/usr/lib/python2.4/site-packages'# Change this to the location of your svn repositoryturboGearsTrunk = '/home/foobar/work/SVN/TURBOGEARS/trunk'######### Nothing to be changed after this line ############################if not os.path.exists(turboGearsTrunk): print "The specified path (%s) does not exist" % turboGearsTrunk print "You have to set the path to your local svn in the variable turboGearsTrunk" sys.exit(1)print "will remove the following directories from your system:"print [glob.glob(os.path.join(pythonPath,package)) for package in packageList]print "Are you sure? [y/N]"if raw_input() != 'y': sys.exit(1)# Fist, remove the packagesfor package in packageList: for fileNDir in glob.glob(os.path.join(pythonPath,package)): print "Will remove directory",fileNDir if os.path.isdir(fileNDir): shutil.rmtree(fileNDir) else: os.remove(fileNDir)# Remove TurboGears.egg-infotry: shutil.rmtree(os.path.join(turboGearsTrunk,'TurboGears.egg-info'))except: pass# Reinstall the TurboGears.egg-info directoryos.chdir(turboGearsTrunk)os.system('python setup.py egg_info')# Install all the third-party packagesthirdpartyBaseDir = os.path.join(turboGearsTrunk,'thirdparty')for p in thirdPartyDir: chemin = os.path.join(thirdpartyBaseDir, p) if os.path.exists(os.path.join(chemin,'setup.py')): print "Will install package", p os.chdir(chemin) if p == 'cherrypy': f = open(os.path.join(chemin,'setup.py'),'r') data = f.readlines() f.close() f = open(os.path.join(chemin,'setup.py'),'w') for line in data: if line == 'from distutils.core import setup\n': f.write('from setuptools import setup\n') else: f.write(line) f.close() # Install it os.system('python setup.py install')# Install RuleDispatch from PJE's website, as it is not yet found on CheeseShopos.system('easy_install -Zf http://peak.telecommunity.com/snapshots/ RuleDispatch')# Finally install TurboGears itselfos.chdir(turboGearsTrunk)os.system('python setup.py install')