view fetch_latest_pangolearn.py @ 1:f557122d379e draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/pangolin commit 1522bdb834ffab157d1ca25e6e74db21f62e3aae"
author iuc
date Sun, 25 Apr 2021 20:17:07 +0000
parents
children 437e28791761
line wrap: on
line source

#!/usr/bin/env python

import json
import os
import tarfile

# rely on the fact that pangolin itself uses the requests module
import requests

response = requests.get(
    "https://api.github.com/repos/cov-lineages/pangoLEARN/releases/latest"
)
if response.status_code == 200:
    details = json.loads(response.text)
    response = requests.get(details["tarball_url"])
    if response.status_code == 200:
        with open("pangolearn.tgz", "wb") as handle:
            handle.write(response.content)
        tf = tarfile.open("pangolearn.tgz")
        pl_path = tf.next().name
        tf.extractall()
        tf.close()
        os.rename(os.path.join(pl_path, "pangoLEARN"), "datadir")
    else:
        response.raise_for_status()
else:
    response.raise_for_status()