mirror of
git://git.yoctoproject.org/yocto-autobuilder-helper.git
synced 2025-07-19 20:59:02 +02:00
scripts/layer-parser.py: remove EOL layers
Remove caching and optimize to run on the autobuilder from scripts/run-dashboard-index Signed-off-by: Michael Halstead <mhalstead@linuxfoundation.org>
This commit is contained in:
parent
6a7b1e8dc3
commit
a1582ba785
|
@ -2,44 +2,32 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import requests
|
|
||||||
import json
|
import json
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
LAYER_API_URL = "https://layers.openembedded.org/layerindex/api/layers/?filter=yp_compatible_version__isnull:false&format=json"
|
LAYER_API_URL = "https://layers.openembedded.org/layerindex/api/layers/?filter=yp_compatible_version__isnull:false&format=json"
|
||||||
LAYERDATA = "layerdata.json"
|
LAYERDATA = "layerdata.json"
|
||||||
RELEASE_URL = "https://docs.yoctoproject.org/releases.json"
|
# RELEASE_URL = "https://docs.yoctoproject.org/releases.json"
|
||||||
RELEASEDATA = "releasedata.json"
|
RELEASEDATA = "releases.json"
|
||||||
|
|
||||||
|
with open(RELEASEDATA, "r") as file:
|
||||||
|
releases = json.load(file)
|
||||||
|
|
||||||
def fetch_data(url, file_path, cache):
|
with urllib.request.urlopen(LAYER_API_URL) as response:
|
||||||
if os.path.isfile(file_path):
|
if response.getcode() == 200:
|
||||||
modification_time = os.path.getmtime(file_path)
|
data = response.read().decode("utf-8")
|
||||||
time_difference = time.time() - modification_time
|
layers = json.loads(data)
|
||||||
else:
|
|
||||||
time_difference = 1000000
|
|
||||||
|
|
||||||
# Re-download if the time difference is greater than cache value
|
|
||||||
if time_difference > cache:
|
|
||||||
response = requests.get(url)
|
|
||||||
if response.status_code == 200:
|
|
||||||
with open(file_path, "w") as file:
|
|
||||||
file.write(response.text)
|
|
||||||
return json.loads(response.text)
|
|
||||||
else:
|
|
||||||
with open(file_path, "r") as file:
|
|
||||||
return json.load(file)
|
|
||||||
|
|
||||||
|
|
||||||
layers = fetch_data(LAYER_API_URL, LAYERDATA, 600)
|
|
||||||
releases = fetch_data(RELEASE_URL, RELEASEDATA, 600)
|
|
||||||
|
|
||||||
# grab the recent release branches and add master, so we can ignore old branches
|
# grab the recent release branches and add master, so we can ignore old branches
|
||||||
active_releases = [
|
active_releases = [
|
||||||
e["release_codename"].lower() for e in releases if e["series"] != "full"
|
e["release_codename"].lower() for e in releases if e["series"] == "current"
|
||||||
]
|
]
|
||||||
active_releases.append("master")
|
active_releases.append("master")
|
||||||
active_releases.append("main")
|
active_releases.append("main")
|
||||||
|
|
||||||
|
print(active_releases)
|
||||||
|
|
||||||
header = dict()
|
header = dict()
|
||||||
header["layer"] = "Layer"
|
header["layer"] = "Layer"
|
||||||
header["branches"] = "Branches"
|
header["branches"] = "Branches"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user