conan-recipes/utils/impl/remotes.py
2023-05-29 21:07:19 +03:00

26 lines
759 B
Python

import subprocess
import json
from impl.utils import get_conan
def list_remotes() -> list[str]:
remotes = subprocess.check_output([get_conan(), 'remote', 'list', '--format', 'json']).decode('utf-8')
return json.loads(remotes)
def add_remote(name:str, url:str) -> None:
remotes = list_remotes()
for remote in remotes:
if remote['name'] != name:
continue
if remote['url'] != url:
subprocess.check_call([get_conan(), 'remote', 'update', '--url', name])
return False
subprocess.check_call([get_conan(), 'remote', 'add', name, url])
return True
def remove_remote(name:str) -> None:
try:
subprocess.check_call([get_conan(), 'remote', 'remove', name])
finally:
pass