| @@ -2,12 +2,23 @@ import sys | |||||
| import os | import os | ||||
| import glob | import glob | ||||
| import json | import json | ||||
| import re | |||||
| import requests | |||||
| import common | import common | ||||
| PACKAGES_DIR = "../packages" | |||||
| # Get the timestamp of the earliest commit touching the manifest file | |||||
| def get_plugin_build(plugin): | |||||
| slug = plugin['slug'] | |||||
| version = plugin['version'] | |||||
| arch = 'lin' | |||||
| package_filename = f"{slug}-{version}-{arch}.zip" | |||||
| package_path = PACKAGES_DIR + "/" + package_filename | |||||
| return os.path.getmtime(package_path) | |||||
| # Get the timestamp of the earliest commit touching the manifest file | # Get the timestamp of the earliest commit touching the manifest file | ||||
| def get_plugin_creation(manifest_filename): | def get_plugin_creation(manifest_filename): | ||||
| stdout = common.system(f"git log --format=%ct -- {manifest_filename} | tail -1") | stdout = common.system(f"git log --format=%ct -- {manifest_filename} | tail -1") | ||||
| @@ -26,8 +37,11 @@ def get_module_creation(manifest_filename, module_slug): | |||||
| def update(): | def update(): | ||||
| # Load existing dataset | # Load existing dataset | ||||
| cache_filename = "manifests-cache.json" | cache_filename = "manifests-cache.json" | ||||
| with open(cache_filename) as f: | |||||
| cache = json.load(f) | |||||
| try: | |||||
| with open(cache_filename) as f: | |||||
| cache = json.load(f) | |||||
| except: | |||||
| cache = {} | |||||
| # Iterate plugins | # Iterate plugins | ||||
| for manifest_filename in glob.glob('manifests/*.json'): | for manifest_filename in glob.glob('manifests/*.json'): | ||||
| @@ -37,6 +51,13 @@ def update(): | |||||
| plugin_slug = plugin['slug'] | plugin_slug = plugin['slug'] | ||||
| cache_plugin = cache.get(plugin_slug, {}) | cache_plugin = cache.get(plugin_slug, {}) | ||||
| # Get plugin build | |||||
| if 'buildTimestamp' not in cache_plugin: | |||||
| try: | |||||
| cache_plugin['buildTimestamp'] = get_plugin_build(plugin) | |||||
| except: | |||||
| pass | |||||
| # Get plugin creation | # Get plugin creation | ||||
| if 'creationTimestamp' not in cache_plugin: | if 'creationTimestamp' not in cache_plugin: | ||||
| cache_plugin['creationTimestamp'] = get_plugin_creation(manifest_filename) | cache_plugin['creationTimestamp'] = get_plugin_creation(manifest_filename) | ||||