def fetch_rpm_from_url(self, spec):
    (package_name, dummy) = os.path.splitext(str(spec.rsplit('/', 1)[1]))
    package_file = tempfile.NamedTemporaryFile(dir=self.module.tmpdir, prefix=package_name, suffix='.rpm', delete=False)
    self.module.add_cleanup_file(package_file.name)
    try:
        (rsp, info) = fetch_url(self.module, spec)
        if (not rsp):
            self.module.fail_json(msg=('Failure downloading %s, %s' % (spec, info['msg'])))
        data = rsp.read(BUFSIZE)
        while data:
            package_file.write(data)
            data = rsp.read(BUFSIZE)
        package_file.close()
    except Exception as e:
        self.module.fail_json(msg=('Failure downloading %s, %s' % (spec, to_native(e))))
    return package_file.name
def fetch_rpm_from_url(self, spec):
    (package_name, dummy) = os.path.splitext(str(spec.rsplit('/', 1)[1]))
    package_file = tempfile.NamedTemporaryFile(dir=self.module.tmpdir, prefix=package_name, suffix='.rpm', delete=False)
    self.module.add_cleanup_file(package_file.name)
    try:
        (rsp, info) = fetch_url(self.module, spec)
        if (not rsp):
            self.module.fail_json(msg=('Failure downloading %s, %s' % (spec, info['msg'])))
        data = rsp.read(BUFSIZE)
        while data:
            package_file.write(data)
            data = rsp.read(BUFSIZE)
        package_file.close()
    except Exception as e:
        self.module.fail_json(msg=('Failure downloading %s, %s' % (spec, to_native(e))))
    return package_file.name