From 261456514d5b86f685de7a782ec656da68ae6ac5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 7 Sep 2022 09:45:34 +0200 Subject: [PATCH] add external mirror for download the workbench isos --- .../templates/workbench/settings.html | 12 ++++---- ereuse_devicehub/workbench/__init__.py | 11 +++++++ ereuse_devicehub/workbench/views.py | 29 ++----------------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/ereuse_devicehub/templates/workbench/settings.html b/ereuse_devicehub/templates/workbench/settings.html index 8a830251..b1411100 100644 --- a/ereuse_devicehub/templates/workbench/settings.html +++ b/ereuse_devicehub/templates/workbench/settings.html @@ -44,19 +44,17 @@
Workbench 2022
- {% if iso %}

- Download Checksum: SHA512SUMS | + Download Checksum: SHA512SUMS | Help

- {% endif %}
@@ -115,14 +113,14 @@

- {{ v }} + {{ v.iso }}

- Download Checksum: SHA512SUMS | + Download Checksum: SHA512SUMS | Help

diff --git a/ereuse_devicehub/workbench/__init__.py b/ereuse_devicehub/workbench/__init__.py index e69de29b..9c52b02b 100644 --- a/ereuse_devicehub/workbench/__init__.py +++ b/ereuse_devicehub/workbench/__init__.py @@ -0,0 +1,11 @@ +isos = { + "demo": { + 'iso': "USODY_2022.5.2-beta.iso", + 'url': 'http://releases.usody.com/demo/', + }, + "2022": { + 'iso': "USODY_2022.5.2-beta.iso", + 'url': 'http://releases.usody.com//2022/', + }, + "v14": {'iso': "USODY_14.0.0.iso", 'url': 'http://releases.usody.com/v14/'}, +} diff --git a/ereuse_devicehub/workbench/views.py b/ereuse_devicehub/workbench/views.py index bce2f5a8..3640ab5b 100644 --- a/ereuse_devicehub/workbench/views.py +++ b/ereuse_devicehub/workbench/views.py @@ -1,6 +1,4 @@ -import os import time -from pathlib import Path import flask from flask import Blueprint @@ -13,6 +11,7 @@ from ereuse_devicehub.db import db from ereuse_devicehub.resources.enums import SessionType from ereuse_devicehub.resources.user.models import Session from ereuse_devicehub.views import GenericMixin +from ereuse_devicehub.workbench import isos workbench = Blueprint('workbench', __name__, url_prefix='/workbench') @@ -28,9 +27,9 @@ class SettingsView(GenericMixin): { 'page_title': self.page_title, 'demo': g.user.email == app.config['EMAIL_DEMO'], + 'iso': isos, } ) - self.get_iso() self.opt = request.values.get('opt') if self.opt in ['register', 'erease_basic', 'erease_sectors']: @@ -38,30 +37,6 @@ class SettingsView(GenericMixin): return flask.render_template(self.template_name, **self.context) - def get_iso(self): - path = Path(__file__).parent.parent - uri = f'{path}/static/iso/' - if self.context.get('demo'): - uri = f'{path}/static/iso/demo/' - - self.context['iso'] = {} - - if not os.path.exists(uri): - return - - versions = os.listdir(f'{path}/static/iso/') - versions.sort() - - for d in versions: - dir_iso = f'{uri}/{d}' - if not os.path.isdir(dir_iso): - continue - - files = [f for f in os.listdir(dir_iso) if f[-3:].lower() == 'iso'] - - if files: - self.context['iso'][f'{d}'] = files[0] - def download(self): url = "https://{}/api/inventory/".format(app.config['HOST']) self.wbContext = {