Commit 2426bbcc authored by Jérome Perrin's avatar Jérome Perrin

component/theia: update generate_download_plugins_cfg.py

Sometimes this script is slow, add some logging to display progress
also use a Session to pool connections and apply a timeout to fail more
faster in case of network/server problems
parent a2e5a55d
import configparser import configparser
import logging
import requests import requests
import hashlib import hashlib
urls = [] urls = []
session = requests.Session()
timeout = 30
logger = logging.getLogger()
logging.basicConfig(level=logging.DEBUG)
for plugin_and_version in '''\ for plugin_and_version in '''\
vscode/bat/latest vscode/bat/latest
...@@ -96,8 +101,9 @@ for plugin_and_version in '''\ ...@@ -96,8 +101,9 @@ for plugin_and_version in '''\
publisher, extension_name, version = plugin_and_version.split('/') publisher, extension_name, version = plugin_and_version.split('/')
api_url = f'https://open-vsx.org/api/{publisher}/{extension_name}/{version}' api_url = f'https://open-vsx.org/api/{publisher}/{extension_name}/{version}'
download_url = requests.get(api_url).json()['files']['download'] logger.info(plugin_and_version)
md5sum = hashlib.md5(requests.get(download_url).content).hexdigest() download_url = session.get(api_url, timeout=timeout).json()['files']['download']
md5sum = hashlib.md5(session.get(download_url, timeout=timeout).content).hexdigest()
urls.append(f'{publisher}-{extension_name} {download_url} {md5sum}') urls.append(f'{publisher}-{extension_name} {download_url} {md5sum}')
cfg = configparser.ConfigParser() cfg = configparser.ConfigParser()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment