예제 #1
0
def get_cid():
    # pylint: disable=import-outside-toplevel
    from platformio.clients.http import fetch_remote_content

    cid = get_state_item("cid")
    if cid:
        return cid
    uid = None
    if os.getenv("C9_UID"):
        uid = os.getenv("C9_UID")
    elif os.getenv("GITPOD_GIT_USER_NAME"):
        uid = os.getenv("GITPOD_GIT_USER_NAME")
    elif os.getenv("CHE_API", os.getenv("CHE_API_ENDPOINT")):
        try:
            uid = json.loads(
                fetch_remote_content("{api}/user?token={token}".format(
                    api=os.getenv("CHE_API", os.getenv("CHE_API_ENDPOINT")),
                    token=os.getenv("USER_TOKEN"),
                ))).get("id")
        except:  # pylint: disable=bare-except
            pass
    if not uid:
        uid = uuid.getnode()
    cid = uuid.UUID(bytes=hashlib.md5(hashlib_encode_data(uid)).digest())
    cid = str(cid)
    if WINDOWS or os.getuid() > 0:  # pylint: disable=no-member
        set_state_item("cid", cid)
    return cid
예제 #2
0
 def new_from_url(remote_url):
     content = fetch_remote_content(remote_url)
     return ManifestParserFactory.new(
         content,
         ManifestFileType.from_uri(remote_url)
         or ManifestFileType.LIBRARY_JSON,
         remote_url,
     )
예제 #3
0
def get_develop_latest_version():
    version = None
    content = fetch_remote_content(
        "https://raw.githubusercontent.com/platformio/platformio"
        "/develop/platformio/__init__.py")
    for line in content.split("\n"):
        line = line.strip()
        if not line.startswith("VERSION"):
            continue
        match = re.match(r"VERSION\s*=\s*\(([^\)]+)\)", line)
        if not match:
            continue
        version = match.group(1)
        for c in (" ", "'", '"'):
            version = version.replace(c, "")
        version = ".".join(version.split(","))
    assert version
    return version
예제 #4
0
 def load_spdx_licenses():
     spdx_data_url = "https://dl.bintray.com/platformio/dl-misc/spdx-licenses-3.json"
     return json.loads(fetch_remote_content(spdx_data_url))
예제 #5
0
 def load_spdx_licenses():
     version = "3.10"
     spdx_data_url = (
         "https://raw.githubusercontent.com/spdx/license-list-data"
         "/v%s/json/licenses.json" % version)
     return json.loads(fetch_remote_content(spdx_data_url))
예제 #6
0
def get_pypi_latest_version():
    content = fetch_remote_content("https://pypi.org/pypi/platformio/json")
    return json.loads(content)["info"]["version"]