Loading src/config.py +1 −1 Original line number Diff line number Diff line VERSION = "0.0.2" VERSION = "0.0.3" src/doc2tosca.py +8 −4 Original line number Diff line number Diff line Loading @@ -14,9 +14,9 @@ from docx.text.paragraph import Paragraph BASE_FILENAME = "generated_etsi_nfv_sol001_{}_types.yaml" TOSCA_VERSION = "tosca_simple_yaml_1_2" SPEC_VERSION = "2.6.1" SPEC_VERSION = "v2.6.1" allowed_versions = ["2.6.1","2.7.1"] allowed_versions = ["v2.6.1","v2.6.3", "v2.7.1"] MODEL_NAMES = ['vnfd', 'nsd', 'pnfd', 'common'] Loading Loading @@ -165,10 +165,14 @@ def generate_templates(filename, spec_version=SPEC_VERSION): for mn in MODEL_NAMES: MODELS[mn] = tosca_model_info( mn, '- https://forge.etsi.org/rep/nfv/SOL001/raw/v{}/etsi_nfv_sol001_common_types.yaml'.format(spec_version) '- https://forge.etsi.org/rep/nfv/SOL001/raw/{}/etsi_nfv_sol001_common_types.yaml'.format(spec_version) ) try: sol_001 = docx.Document(filename) except: print("Error opening the submitted Docx file") raise ValueError("Cannot open the submitted Docx file") for m in MODELS: dump_header( Loading src/templates/home.html +4 −1 Original line number Diff line number Diff line <!doctype html> <!DOCTYPE HTML> <html> Loading Loading @@ -83,6 +83,9 @@ For any other inquiry, contact <a href="mailto:cti_support@etsi.org">ETSI CTI</a <option value="{{version}}">{{version}}</option> {% endfor %} </select> <br /> Custom version (overrides the selector): <input type="text" name="custom-doc-version"> <br /><br /> <center> <input type="submit" class="btn btn-primary" value="Upload" /> Loading src/test_after_request.py 0 → 100644 +33 −0 Original line number Diff line number Diff line #!/bin/python3 ''' just a test ''' import os from flask import Flask, flash, request, send_file, g app = Flask(__name__) @app.after_request def after_request(response): if request.path != '/ciao': return response os.remove(g.fname) print("Deleted {}\n\n".format(g.fname)) return response @app.route("/") def hello(): ''' noting ''' return 'Hello world' @app.route("/ciao") def ciao(): fname='/tmp/MIOMIOMIO.txt' myfile=open(fname, 'w') myfile.write('PROVA\n'* 100) myfile.close() g.fname = fname return send_file(fname, as_attachment=True) src/web_app.py +11 −1 Original line number Diff line number Diff line Loading @@ -173,6 +173,7 @@ def mk_doc2tosca(): try: print(request.form) doc_version = request.form.get('doc-version') custom_doc_version = request.form.get('custom-doc-version') except: flash("Something went wrong :/") return redirect("/tosca-ie") Loading @@ -183,7 +184,16 @@ def mk_doc2tosca(): sol001_file = ufiles[0] if custom_doc_version != "": doc_version = custom_doc_version try: doc2tosca.generate_templates(sol001_file, doc_version) except ValueError as e: flash(str(e)) return redirect("/tosca-ie") except: flash("Unknown error in the generation of the files. Please contact the support.") return redirect("/tosca-ie") tmp_dir = tempfile.mkdtemp() print("TMP DIR: " + tmp_dir) Loading Loading
src/config.py +1 −1 Original line number Diff line number Diff line VERSION = "0.0.2" VERSION = "0.0.3"
src/doc2tosca.py +8 −4 Original line number Diff line number Diff line Loading @@ -14,9 +14,9 @@ from docx.text.paragraph import Paragraph BASE_FILENAME = "generated_etsi_nfv_sol001_{}_types.yaml" TOSCA_VERSION = "tosca_simple_yaml_1_2" SPEC_VERSION = "2.6.1" SPEC_VERSION = "v2.6.1" allowed_versions = ["2.6.1","2.7.1"] allowed_versions = ["v2.6.1","v2.6.3", "v2.7.1"] MODEL_NAMES = ['vnfd', 'nsd', 'pnfd', 'common'] Loading Loading @@ -165,10 +165,14 @@ def generate_templates(filename, spec_version=SPEC_VERSION): for mn in MODEL_NAMES: MODELS[mn] = tosca_model_info( mn, '- https://forge.etsi.org/rep/nfv/SOL001/raw/v{}/etsi_nfv_sol001_common_types.yaml'.format(spec_version) '- https://forge.etsi.org/rep/nfv/SOL001/raw/{}/etsi_nfv_sol001_common_types.yaml'.format(spec_version) ) try: sol_001 = docx.Document(filename) except: print("Error opening the submitted Docx file") raise ValueError("Cannot open the submitted Docx file") for m in MODELS: dump_header( Loading
src/templates/home.html +4 −1 Original line number Diff line number Diff line <!doctype html> <!DOCTYPE HTML> <html> Loading Loading @@ -83,6 +83,9 @@ For any other inquiry, contact <a href="mailto:cti_support@etsi.org">ETSI CTI</a <option value="{{version}}">{{version}}</option> {% endfor %} </select> <br /> Custom version (overrides the selector): <input type="text" name="custom-doc-version"> <br /><br /> <center> <input type="submit" class="btn btn-primary" value="Upload" /> Loading
src/test_after_request.py 0 → 100644 +33 −0 Original line number Diff line number Diff line #!/bin/python3 ''' just a test ''' import os from flask import Flask, flash, request, send_file, g app = Flask(__name__) @app.after_request def after_request(response): if request.path != '/ciao': return response os.remove(g.fname) print("Deleted {}\n\n".format(g.fname)) return response @app.route("/") def hello(): ''' noting ''' return 'Hello world' @app.route("/ciao") def ciao(): fname='/tmp/MIOMIOMIO.txt' myfile=open(fname, 'w') myfile.write('PROVA\n'* 100) myfile.close() g.fname = fname return send_file(fname, as_attachment=True)
src/web_app.py +11 −1 Original line number Diff line number Diff line Loading @@ -173,6 +173,7 @@ def mk_doc2tosca(): try: print(request.form) doc_version = request.form.get('doc-version') custom_doc_version = request.form.get('custom-doc-version') except: flash("Something went wrong :/") return redirect("/tosca-ie") Loading @@ -183,7 +184,16 @@ def mk_doc2tosca(): sol001_file = ufiles[0] if custom_doc_version != "": doc_version = custom_doc_version try: doc2tosca.generate_templates(sol001_file, doc_version) except ValueError as e: flash(str(e)) return redirect("/tosca-ie") except: flash("Unknown error in the generation of the files. Please contact the support.") return redirect("/tosca-ie") tmp_dir = tempfile.mkdtemp() print("TMP DIR: " + tmp_dir) Loading