Beispiel #1
0
    def try_download(self, json_spec: Dict) -> Optional[BotJsonMeta]:
        bot_spec = BotPlayer.parse_meta(json_spec)
        base_dir = f'{self.bot_dir}/{bot_spec.name}'
        try:
            os.makedirs(base_dir, exist_ok=False)

            # use http because local network on CTU has broken records
            # and it should work everywhere...
            download_extract_zip(bot_spec.botBinary.replace("https", "http"), f'{base_dir}/AI')
            download_file(bot_spec.bwapiDLL.replace("https", "http"), f'{base_dir}/BWAPI.dll')

            os.makedirs(f'{base_dir}/read', exist_ok=False)
            os.makedirs(f'{base_dir}/write', exist_ok=False)

            with open(f'{base_dir}/bot.json', 'w') as f:
                json.dump(json_spec, f)

            return bot_spec

        except Exception as e:
            logger.exception(f"Failed to process bot {bot_spec.name}")
            logger.exception(e)

            logger.info(f"Cleaning up dir {base_dir}")
            shutil.rmtree(base_dir)

            return None
Beispiel #2
0
def download_season_maps(map_dir: str) -> None:
    logger.info("downloading maps for 2019 season 1")
    download_extract_zip(
        "https://github.com/Bytekeeper/sc-docker/releases/download/Maps_2019Season1/2019Season1.zip", map_dir
    )
    logger.info("downloading maps for 2019 season 2")
    download_extract_zip(
        "https://github.com/Bytekeeper/sc-docker/releases/download/Maps_2019Season2/2019Season2.zip", map_dir
    )
Beispiel #3
0
def download_bwta_caches(bwta_dir: str, bwta2_dir: str) -> None:
    logger.info("downloading BWTA caches")
    tmp_dir = tempfile.mkdtemp()
    download_extract_zip(
        "https://github.com/adakitesystems/DropLauncher/releases/download/0.4.18a/BWTA_cache.zip",
        tmp_dir)

    for file in os.listdir(tmp_dir + "/bwapi-data/BWTA"):
        if not os.path.exists(f"{bwta_dir}/{file}"):
            shutil.move(tmp_dir + "/bwapi-data/BWTA/" + file, bwta_dir)
    for file in os.listdir(tmp_dir + "/bwapi-data/BWTA2"):
        if not os.path.exists(f"{bwta_dir}/{file}"):
            shutil.move(tmp_dir + "/bwapi-data/BWTA2/" + file, bwta2_dir)
Beispiel #4
0
    def try_download(self, name: str) -> Optional[Benchmark]:
        benchmark_dir = self.benchmark_dir(name)
        try:
            os.makedirs(benchmark_dir, exist_ok=False)
            download_extract_zip(f"{self.BASE_URL}/{name}.zip", benchmark_dir)
            return self.get_benchmark(benchmark_dir)

        except Exception as e:
            logger.exception(f"Failed to download benchmark {name}")
            logger.exception(e)

            logger.info(f"Cleaning up dir {benchmark_dir}")
            shutil.rmtree(self.benchmark_dir(name))

            return None
Beispiel #5
0
def download_sscait_maps(map_dir: str) -> None:
    logger.info("downloading maps from SSCAI")
    download_extract_zip(
        "http://sscaitournament.com/files/sscai_map_pack.zip", map_dir
    )