From 26cb2f1d53bcf6ad9b8f14347151db6046d70bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 28 Sep 2020 13:57:21 +0200 Subject: [PATCH] chg: make 3rd party dl a python script --- bin/update.py | 5 ++--- tools/3rdparty.py | 30 ++++++++++++++++++++++++++++++ website/3rdparty.sh | 15 --------------- 3 files changed, 32 insertions(+), 18 deletions(-) create mode 100755 tools/3rdparty.py delete mode 100755 website/3rdparty.sh diff --git a/bin/update.py b/bin/update.py index e3cecf47..8e611f5e 100755 --- a/bin/update.py +++ b/bin/update.py @@ -24,6 +24,7 @@ def keep_going(ignore=False): def run_command(command): args = shlex.split(command) + homedir = get_homedir() process = subprocess.run(args, cwd=homedir, capture_output=True) print(process.stdout.decode()) if process.returncode: @@ -36,8 +37,6 @@ if __name__ == '__main__': parser.add_argument('--yes', default=False, action='store_true', help='Run all commands without asking.') args = parser.parse_args() - homedir = get_homedir() - print('* Update repository.') keep_going(args.yes) run_command('git pull') @@ -56,4 +55,4 @@ if __name__ == '__main__': print('* Update third party dependencies for the website.') keep_going(args.yes) - run_command('website/3rdparty.sh') + run_command('tools/3rdparty.py') diff --git a/tools/3rdparty.py b/tools/3rdparty.py new file mode 100755 index 00000000..19a0561b --- /dev/null +++ b/tools/3rdparty.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import requests + +from lookyloo.helpers import get_homedir + +d3js_version = '5' +datatables_version = "1.10.22" + + +if __name__ == '__main__': + dest_dir = get_homedir() / 'website' / 'web' / 'static' + + d3 = requests.get(f'https://d3js.org/d3.v${d3js_version}.min.js') + with (dest_dir / 'd3.v${d3js_version}.min.js').open('wb') as f: + f.write(d3.content) + print(f'Downloaded d3js v{d3js_version}.') + + datatables_js = requests.get(f'https://cdn.datatables.net/v/bs4/dt-${datatables_version}/datatables.min.js') + with (dest_dir / 'datatables.min.js').open('wb') as f: + f.write(d3.content) + print(f'Downloaded datatables js v{datatables_version}.') + + datatables_css = requests.get(f'https://cdn.datatables.net/v/bs4/dt-${datatables_version}/datatables.min.css') + with (dest_dir / 'datatables.min.css').open('wb') as f: + f.write(d3.content) + print(f'Downloaded datatables_css v{datatables_version}.') + + print('All 3rd party modules for the website were downloaded.') diff --git a/website/3rdparty.sh b/website/3rdparty.sh deleted file mode 100755 index 31321f2d..00000000 --- a/website/3rdparty.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -e -set -x - -mkdir -p web/static/ - -wget -q https://d3js.org/d3.v5.min.js -O web/static/d3.v5.min.js - -datatables="1.10.22" - -wget -q https://cdn.datatables.net/v/bs4/dt-${datatables}/datatables.min.css -O web/static/datatables.min.css -wget -q https://cdn.datatables.net/v/bs4/dt-${datatables}/datatables.min.js -O web/static/datatables.min.js - -echo 'Done'