~moon127/charms/trusty/ceilometer/add-execd-preinstall

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/fetch/__init__.py

  • Committer: James Page
  • Date: 2013-11-06 01:06:52 UTC
  • Revision ID: james.page@canonical.com-20131106010652-akof8nnkati19skk
Resync charm-helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        subprocess.call(cmd)
80
80
 
81
81
 
 
82
def apt_hold(packages, fatal=False):
 
83
    """Hold one or more packages"""
 
84
    cmd = ['apt-mark', 'hold']
 
85
    if isinstance(packages, basestring):
 
86
        cmd.append(packages)
 
87
    else:
 
88
        cmd.extend(packages)
 
89
    log("Holding {}".format(packages))
 
90
    if fatal:
 
91
        subprocess.check_call(cmd)
 
92
    else:
 
93
        subprocess.call(cmd)
 
94
 
 
95
 
82
96
def add_source(source, key=None):
83
 
    if ((source.startswith('ppa:') or
84
 
         source.startswith('http:'))):
 
97
    if (source.startswith('ppa:') or
 
98
        source.startswith('http:') or
 
99
        source.startswith('deb ') or
 
100
        source.startswith('cloud-archive:')):
85
101
        subprocess.check_call(['add-apt-repository', '--yes', source])
86
102
    elif source.startswith('cloud:'):
87
103
        apt_install(filter_installed_packages(['ubuntu-cloud-keyring']),
118
134
    Note that 'null' (a.k.a. None) should not be quoted.
119
135
    """
120
136
    sources = safe_load(config(sources_var))
121
 
    keys = safe_load(config(keys_var))
122
 
    if isinstance(sources, basestring) and isinstance(keys, basestring):
 
137
    keys = config(keys_var)
 
138
    if keys is not None:
 
139
        keys = safe_load(keys)
 
140
    if isinstance(sources, basestring) and (
 
141
            keys is None or isinstance(keys, basestring)):
123
142
        add_source(sources, keys)
124
143
    else:
125
144
        if not len(sources) == len(keys):