1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/usr/bin/env python
import sys
import os
import optparse
# 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 -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)
|