def _download() -> None: debug('Downloading server from', url) target = sublime.active_window() label = 'Downloading PromQL language server' with ActivityIndicator(target, label): try: opener = FancyURLopener() tmp_file, _ = opener.retrieve(url) if not checksum_verified(checksum, tmp_file): debug('Checksum error.') sublime.status_message('Server binary', os.path.basename(tmp_file), 'checkusm error.') return # extract and copy the cache with tarfile.open(tmp_file) as tf: tf.extractall(self._cache_path) os.unlink(tmp_file) self._ready = True except Exception as ex: debug('Failed downloading server:', ex) finally: opener.close()
def resolve(self): urlopener = FancyURLopener() try: unresolved = [] for artifact in self.artifacts: if not self._download_artifact(urlopener, artifact): unresolved.append(artifact) self.logger.error("Could not resolve artifact %s." % artifact.name) if len(unresolved) > 0: raise ArtifactUnresolvedException(unresolved) except KeyboardInterrupt as e: raise TequilaException('Download interrupted by user.') from e finally: urlopener.close()