#!/usr/bin/env python2.4 import sys import os import site import optparse if sys.version_info < (2, 4): print >> sys.stderr, '%s: need Python 2.4 or later.' % sys.argv[0] print >> sys.stderr, 'Your python is %s' % sys.version sys.exit(1) # Parse Options parser = optparse.OptionParser(usage="usage: %prog [options]") parser.add_option("-i", "--install", dest="INSTALL", action="store_true", default=False, help=("Automatically enable new plugins.\n" "(Use --force to avoid prompts)")) parser.add_option("-f", "--force", dest="FORCE", action="store_true", default=False, help=("Automatically enable newly installed plugins\n" "without prompting. (Use with --install)")) (options, args) = parser.parse_args() here = os.path.dirname(os.path.realpath(__file__)) plugins_available = os.path.join(here, 'plugins_available') plugins_enabled = os.path.join(here, 'plugins_enabled') eggs = os.path.join(here, 'eggs') src = os.path.join(here, 'src') egg_files = filter(lambda x: x.endswith('.egg'), sys.argv) for egg in egg_files: cmd = 'PYTHONPATH=%s:%s easy_install-2.4 -S %s --install-dir=%s %s' % (eggs, src, eggs, eggs, egg) print cmd os.system(cmd) print """ ********************************* ** ** ** PLUGINS AVAILABLE ** ** ** ********************************* The following plugins are now available: """ for egg in filter(lambda x: x.endswith('.egg'), sys.argv): print " ", os.path.split(egg)[-1] if not options.INSTALL: print """ These plugins must now be enabled. To enable them, create a symbolic link to the appropriate *-configure.zcml in the plugins_available directory and put it into the plugins_enabled directory. """ print "" for egg in [os.path.split(f)[-1] for f in egg_files]: for root, dirs, files in os.walk(os.path.join(eggs, egg)): slugs = filter(lambda x: x.endswith("-configure.zcml"), files) for slug in slugs: cmd = 'cp %s %s' % (os.path.join(root, slug), os.path.join(plugins_available, slug)) os.system(cmd) if options.INSTALL: if not options.FORCE: install = raw_input("\n\nShould I enable the %s package (y/n): " % slug[:-15]) print else: install = 'y' if install.lower() == 'y': cmd = 'cp %s %s' % (os.path.join(plugins_available, slug), os.path.join(plugins_enabled, slug)) print cmd os.system(cmd)