~hopem/charms/trusty/rabbitmq-server/lp1510902-stable-backport

« back to all changes in this revision

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

  • Committer: james.page at ubuntu
  • Date: 2015-08-10 16:38:33 UTC
  • Revision ID: james.page@ubuntu.com-20150810163833-lwvkk1s3iea5zd35
Tags: 15.07
[gnuoy] 15.07 Charm release

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)