Skip to content
Snippets Groups Projects
Commit 8374ed65 authored by carignani's avatar carignani
Browse files

custom version of YAML files for doc2tosca enabled

parent b1226384
No related branches found
Tags v0.0.3
No related merge requests found
VERSION = "0.0.2"
VERSION = "0.0.3"
......@@ -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']
......@@ -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)
)
sol_001 = docx.Document(filename)
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(
......
<!doctype html>
<!DOCTYPE HTML>
<html>
......@@ -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" />
......
#!/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)
......@@ -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")
......@@ -183,7 +184,16 @@ def mk_doc2tosca():
sol001_file = ufiles[0]
doc2tosca.generate_templates(sol001_file, doc_version)
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment