How to use the ai2thor.downloader.download function in ai2thor

To help you get started, we’ve selected a few ai2thor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github allenai / ai2thor / ai2thor / controller.py View on Github external
def download_binary(self):
        if platform.architecture()[0] != '64bit':
            raise Exception("Only 64bit currently supported")

        url, sha256_build = self.build_url()
        tmp_dir = os.path.join(self.base_dir(), 'tmp')
        makedirs(self.releases_dir())
        makedirs(tmp_dir)

        if not os.path.isfile(self.executable_path()):
            zip_data = ai2thor.downloader.download(
                url,
                self.build_name(),
                sha256_build)

            z = zipfile.ZipFile(io.BytesIO(zip_data))
            # use tmpdir instead or a random number
            extract_dir = os.path.join(tmp_dir, self.build_name())
            logger.debug("Extracting zipfile %s" % os.path.basename(url))
            z.extractall(extract_dir)
            os.rename(extract_dir, os.path.join(self.releases_dir(), self.build_name()))
            # we can lose the executable permission when unzipping a build
            os.chmod(self.executable_path(), 0o755)
        else:
            logger.debug("%s exists - skipping download" % self.executable_path())
github allenai / ai2thor / tasks.py View on Github external
def fetch_source_textures(context):
    import ai2thor.downloader
    import io

    zip_data = ai2thor.downloader.download(
        "http://s3-us-west-2.amazonaws.com/ai2-thor/assets/source-textures.zip",
        "source-textures",
        "75476d60a05747873f1173ba2e1dbe3686500f63bcde3fc3b010eea45fa58de7",
    )

    z = zipfile.ZipFile(io.BytesIO(zip_data))
    z.extractall(os.getcwd())