chg: make 3rd party dl a python script

pull/96/head
Raphaël Vinot 2020-09-28 13:57:21 +02:00
parent d33698357c
commit 26cb2f1d53
3 changed files with 32 additions and 18 deletions

View File

@ -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')

30
tools/3rdparty.py Executable file
View File

@ -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.')

View File

@ -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'