forked from arkOScloud/genesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis-pkg
executable file
·71 lines (60 loc) · 1.92 KB
/
genesis-pkg
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
70
71
#!/usr/bin/env python
import os
import sys
import logging
from genesis.config import Config
from genesis.standalone import make_log
from genesis.plugmgr import PluginLoader, RepositoryManager
from genesis.utils import detect_platform
def main():
if len(sys.argv) < 2:
print 'Specify command'
sys.exit(1)
config_file = '/etc/genesis/genesis.conf'
if os.path.isfile(os.path.join(sys.path[0], 'genesis.conf')):
config_file = os.path.join(sys.path[0], 'genesis.conf')
log = make_log(debug=False)
print 'Loading plugins'
config = Config()
config.load(config_file)
PluginLoader.initialize(log, config.get('genesis', 'plugins'), detect_platform())
PluginLoader.load_plugins()
mgr = RepositoryManager(config)
if sys.argv[1] == 'list':
for i in mgr.installed:
print_one(i)
if sys.argv[1] == 'avail':
for i in mgr.available:
print_one(i)
if sys.argv[1] == 'remove':
for pkg in sys.argv[2:]:
print 'Removing', pkg
mgr.remove(pkg)
print 'Done'
if sys.argv[1] == 'get':
for pkg in sys.argv[2:]:
print 'Downloading', pkg
mgr.install(pkg)
print 'Done'
if sys.argv[1] == 'update':
print 'Downloading plugin list'
mgr.update_list()
print 'Done'
if sys.argv[1] == 'upgrade':
print 'Downloading plugin list'
mgr.update_list()
print 'Upgrading Genesis plugins'
for pkg in mgr.available:
for p in mgr.installed:
if pkg.id == p.id and pkg.version != p.version:
print 'Downloading', pkg.id
mgr.install(pkg.id)
print 'Done'
def print_one(i):
st = 'i..' if i.installed else '...'
if i.problem:
st = '..X'
print ' %s\t%s\t%s' % (st, i.version, i.id)
if i.problem:
print '\t\t\t\t' + str(i.problem)
main()