Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(64)

Side by Side Diff: hooks/install

Issue 8999043: Fix charm for jujucharms.com use
Patch Set: Created 11 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « hooks/backend.py ('k') | hooks/utils.py » ('j') | hooks/utils.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python2 1 #!/usr/bin/env python2
2 # -*- python -*- 2 # -*- python -*-
3 3
4 import json 4 import json
5 from subprocess import check_call 5 import os
6 6
7 # If the user's environment has "juju-origin: ppa" set, they will 7 # If the user's environment has "juju-origin: ppa" set, they will
8 # automatically have access to python-charmhelpers and python-shelltoolbox. 8 # automatically have access to python-charmhelpers and python-shelltoolbox.
9 # However, we want to support environments that use the non-PPA environment as 9 # However, we want to support environments that use the non-PPA environment as
10 # well. To do so, we need to install the Juju PPA, which we will do with a 10 # well. To do so, we need to install the Juju PPA, which we will do with a
11 # couple of functions that are actually maintained in python-shelltoolbox. 11 # couple of functions that are actually maintained in python-shelltoolbox.
12 import bootstrap_utils 12 import bootstrap_utils
13 13
14 14
15 def get_config(): 15 def get_config():
16 output = bootstrap_utils.run('config-get', '--format', 'json') 16 output = bootstrap_utils.run('config-get', '--format', 'json')
17 return json.loads(output) 17 return json.loads(output)
18 18
19 config = get_config() 19 config = get_config()
20 allow_repos = config.get('allow-additional-deb-repositories', True) 20 allow_repos = config.get('allow-additional-deb-repositories', True)
21 if allow_repos: 21 if allow_repos:
22 bootstrap_utils.install_extra_repositories('ppa:juju/pkgs') 22 bootstrap_utils.install_extra_repositories('ppa:juju/pkgs')
23 23
24 # Python dependencies must be installed here so that the charm can import and 24 # Python dependencies must be installed here so that the charm can import and
25 # use required libraries. 25 # use required libraries.
26 PYTHON_DEPENDENCIES = ( 26 PYTHON_DEPENDENCIES = (
27 'python-apt', 'python-charmhelpers', 'python-launchpadlib', 27 'python-apt', 'python-charmhelpers', 'python-launchpadlib',
28 'python-shelltoolbox', 'python-tempita', 28 'python-shelltoolbox', 'python-tempita',
29 ) 29 )
30 check_call(('apt-get', 'install', '-y') + PYTHON_DEPENDENCIES) 30 bootstrap_utils.run(*(('apt-get', 'install', '-y') + PYTHON_DEPENDENCIES))
31 31
32 32
33 from utils import ( 33 from utils import (
34 config_json, 34 config_json,
35 log_hook, 35 log_hook,
36 ) 36 )
37 37
38 from backend import Backend 38 from backend import Backend
39 39
40 40
41 def main(): 41 def main():
42 # Run pre-install tasks, if available. Please do not rely on the
43 # exec.d interface without conferring with the Juju GUI team: it may
44 # change after upcoming discussion with Canonical IS.
45 if os.path.isdir('exec.d'):
46 for module in os.listdir('exec.d'):
benji 2013/04/27 20:29:30 Usually ".d" files are to be run in lexicographic
gary.poster 2013/04/28 01:48:15 Good idea in the abstract, and I changed it. FWIW
47 try:
48 bootstrap_utils.run(os.path.join('exec.d',module,'charm-pre-inst all'))
49 except OSError:
benji 2013/04/27 20:29:30 It would be safer if we knew which OSErrors in par
gary.poster 2013/04/28 01:48:15 OK, good point...I did it, because I agree with yo
50 pass
42 config = get_config() 51 config = get_config()
43 backend = Backend(config) 52 backend = Backend(config)
44 backend.install() 53 backend.install()
45 # Store current configuration. 54 # Store current configuration.
46 config_json.set(config) 55 config_json.set(config)
47 56
48 57
49 if __name__ == '__main__': 58 if __name__ == '__main__':
50 with log_hook(): 59 with log_hook():
51 main() 60 main()
OLDNEW
« no previous file with comments | « hooks/backend.py ('k') | hooks/utils.py » ('j') | hooks/utils.py » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b