~corey.bryant/charms/trusty/keystone/sync-ch

« back to all changes in this revision

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

  • Committer: Corey Bryant
  • Date: 2015-07-16 20:17:38 UTC
  • Revision ID: corey.bryant@canonical.com-20150716201738-73cix6kgva39a8kv
Sync charm-helpers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
    def can_handle(self, source):
78
78
        url_parts = self.parse_url(source)
79
79
        if url_parts.scheme not in ('http', 'https', 'ftp', 'file'):
 
80
            # XXX: Why is this returning a boolean and a string? It's
 
81
            # doomed to fail since "bool(can_handle('foo://'))"  will be True.
80
82
            return "Wrong source type"
81
83
        if get_archive_handler(self.base_url(source)):
82
84
            return True
155
157
            else:
156
158
                algorithms = hashlib.algorithms_available
157
159
            if key in algorithms:
158
 
                check_hash(dld_file, value, key)
 
160
                if len(value) != 1:
 
161
                    raise TypeError(
 
162
                        "Expected 1 hash value, not %d" % len(value))
 
163
                expected = value[0]
 
164
                check_hash(dld_file, expected, key)
159
165
        if checksum:
160
166
            check_hash(dld_file, checksum, hash_type)
161
167
        return extract(dld_file, dest)