Beispiel #1
0
 def dbctl_download_data(self, handle, filename=None):
     """Download data and return (temp) filename."""
     url = "/".join([self.url, self.version, "dbctl/data", handle])
     with download_to_file(url,
                           self.token,
                           target_file=filename,
                           cleanup=False) as filename:
         return filename
Beispiel #2
0
    def download_file(self, url_path, target=None, untargz=False):
        """Download static file to target file/dir (if untargz is True).

        If target is None then a temporary file/dir is used.

        """
        url = "/".join([self.url, url_path])
        if untargz:
            with download_to_file(url, self.token) as tmp_filename:
                with untar_to_dir(
                    tmp_filename, target=target, cleanup=False
                ) as directory:
                    return directory
        else:
            with download_to_file(
                url, self.token, target=target, cleanup=False
            ) as filename:
                return filename
Beispiel #3
0
    def pip_install_from_plugin(self, namespace, wheelhouse="python/wheelhouse.tar.gz"):
        """Download and install Python packages published by given plugin/namespace.

        The output from `pip install` is sent to stdout/err.

        """
        url = "/".join([self.url, namespace, wheelhouse])
        with download_to_file(url, self.token) as tmp_filename:
            with untar_to_dir(tmp_filename) as tmp_dir:
                subprocess.check_call(
                    [
                        sys.executable,
                        "-m",
                        "pip",
                        "install",
                        "--force",
                        "--find-links",
                        tmp_dir,
                        "--requirement",
                        tmp_dir / "requirements.txt",
                    ]
                )