Check if projects exists before trying to read from them
This commit is contained in:
parent
9ebbee33fc
commit
df1019dd4b
1 changed files with 21 additions and 1 deletions
|
@ -1,16 +1,22 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-FileCopyrightText: 2021 Luca Beltrame <lbeltrame@kde.org>
|
||||||
|
# SPDX-License-Identifier: BSD-3-clause
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import csv
|
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import pickle
|
import pickle
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
import git
|
import git
|
||||||
|
import requests
|
||||||
import sarge
|
import sarge
|
||||||
|
|
||||||
|
|
||||||
|
API_URL = "https://invent.kde.org/api/v4/projects/"
|
||||||
|
|
||||||
|
|
||||||
class GitHashCache:
|
class GitHashCache:
|
||||||
|
|
||||||
def __init__(self, cache_file):
|
def __init__(self, cache_file):
|
||||||
|
@ -51,6 +57,16 @@ class GitHashCache:
|
||||||
json.dump(self._data, handle, indent=4)
|
json.dump(self._data, handle, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
def project_exists(project):
|
||||||
|
project_name = urlencode(project)
|
||||||
|
request = requests.get(API_URL + project_name)
|
||||||
|
|
||||||
|
if request.status_code == requests.status_codes.codes.ok:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def lsremote(url):
|
def lsremote(url):
|
||||||
|
|
||||||
remote_refs = {}
|
remote_refs = {}
|
||||||
|
@ -91,6 +107,10 @@ def update_package(hash_data, package_name, remote_name, obs_repository,
|
||||||
|
|
||||||
repo_name = "https://invent.kde.org/{}".format(remote_name)
|
repo_name = "https://invent.kde.org/{}".format(remote_name)
|
||||||
|
|
||||||
|
if not project_exists(remote_name):
|
||||||
|
logging.warn("Repository {} not found, skipping".format(remote_name))
|
||||||
|
return
|
||||||
|
|
||||||
remote_hash = get_remote_hash(repo_name, branch)
|
remote_hash = get_remote_hash(repo_name, branch)
|
||||||
repo_hashes = hash_data.get(obs_repository)
|
repo_hashes = hash_data.get(obs_repository)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue