# HG changeset patch # User Teemu Piippo # Date 1598383215 -10800 # Node ID 62759e5c455427cf956b90cac865257cb40c60e7 # Parent 01941a811b5ad373eeb0dc95886dd7b5a5f02ecf add some basic versioning diff -r 01941a811b5a -r 62759e5c4554 ldcheck.py --- a/ldcheck.py Tue Aug 25 22:10:04 2020 +0300 +++ b/ldcheck.py Tue Aug 25 22:20:15 2020 +0300 @@ -3,6 +3,10 @@ if version_info < (3, 4): raise RuntimeError('Python 3.4 or newer required') +appname = 'ldcheck' +version = (0, 0, 9999) +version_string = str.join('.', map(str, version)) + from colours import load_colours from geometry import * from pathlib import Path @@ -130,6 +134,13 @@ action = 'store_true', help = 'use colors' ) + parser.add_argument('-v', '--version', + action = 'version', + version = str.format('{appname} {version}', + appname = appname, + version = version_string, + ), + ) args = parser.parse_args() config = load_config('ldcheck.cfg') for ldconfig_ldr_path in find_ldconfig_ldr_paths(config): diff -r 01941a811b5a -r 62759e5c4554 templates/webfront.html --- a/templates/webfront.html Tue Aug 25 22:10:04 2020 +0300 +++ b/templates/webfront.html Tue Aug 25 22:20:15 2020 +0300 @@ -7,7 +7,7 @@
-

Check your part here

+

{{appname}} {{version}} - Check your part here

@@ -15,6 +15,10 @@
+{% if is_debug %} +

Note: this is an unreleased version, everything may not work as intended.

+{% endif %} + {% if report %}

{{name}}

{% if report['problems'] %} diff -r 01941a811b5a -r 62759e5c4554 webfront.py --- a/webfront.py Tue Aug 25 22:10:04 2020 +0300 +++ b/webfront.py Tue Aug 25 22:20:15 2020 +0300 @@ -1,10 +1,11 @@ #!/usr/bin/env python3 from flask import Flask, render_template, redirect, request +from ldcheck import appname, version, version_string from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths from parse import read_ldraw from testsuite import load_tests, check_model, problem_text, all_problem_types -app = Flask('LDCheck') +app = Flask(appname) def format_report_html(report, model, test_suite): messages = [] @@ -25,6 +26,11 @@ @app.route('/', methods = ['GET', 'POST']) def web_front(): test_suite = load_tests() + common_args = { + 'appname': appname, + 'version': version_string, + 'is_debug': max(version) == 9999, + } if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files or not request.files['file'].filename: @@ -39,6 +45,7 @@ file.stream, name = filename, ldraw_directories = config['libraries'], + **common_args, ) report = check_model(model, test_suite) @@ -50,14 +57,16 @@ return render_template('webfront.html', report = report, name = filename, - problem_types = all_problem_types(test_suite) + problem_types = all_problem_types(test_suite), + **common_args, ) else: test_suite = load_tests() return render_template('webfront.html', report = None, name = None, - problem_types = all_problem_types(test_suite) + problem_types = all_problem_types(test_suite), + **common_args, ) @app.route('/static/')