From 261456514d5b86f685de7a782ec656da68ae6ac5 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 7 Sep 2022 09:45:34 +0200 Subject: [PATCH 1/2] 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 = { From 04f8b630ac4be8adf359ebb0878ec8df0ad79eb7 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 7 Sep 2022 10:26:00 +0200 Subject: [PATCH 2/2] fix url in test_print_labels --- tests/test_render_2_0.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 3395cda5..ba6c1f03 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -1,4 +1,3 @@ -import csv import datetime import json from io import BytesIO @@ -419,7 +418,7 @@ def test_print_labels(user3: UserClientFlask): body, status = user3.post(uri, data=data) assert status == '200 OK' - path = "/inventory/device/{}/".format(dev.devicehub_id) + path = "/devices/{}".format(dev.devicehub_id) assert path in body assert "tag1" in body