+ add delete after download
This commit is contained in:
@@ -2,22 +2,31 @@ from flask.helpers import send_file
|
|||||||
from flask import render_template, abort, flash, Blueprint
|
from flask import render_template, abort, flash, Blueprint
|
||||||
from Web.main.forms import UploadJavaForm
|
from Web.main.forms import UploadJavaForm
|
||||||
from random import randint
|
from random import randint
|
||||||
import shutil as zip
|
import shutil
|
||||||
import secrets
|
import secrets
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
UPLOAD_FOLDER = '/path/to/'
|
|
||||||
ALLOWED_EXTENSIONS = {'java','txt'}
|
|
||||||
|
|
||||||
from gui.utils import nassi
|
from gui.utils import nassi
|
||||||
from interpreter.NassiShneidermann import NassiShneidermanDiagram, OB
|
from interpreter.NassiShneidermann import NassiShneidermanDiagram, OB
|
||||||
|
|
||||||
main = Blueprint('main', __name__)
|
main = Blueprint('main', __name__)
|
||||||
|
|
||||||
def allowed_file(filename):
|
def deleteFile(path):
|
||||||
return '.' in filename and \
|
file_list = os.listdir(path)
|
||||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
for f in file_list:
|
||||||
|
try:
|
||||||
|
os.remove(path + '/' +f)
|
||||||
|
print("remove " + f)
|
||||||
|
except:
|
||||||
|
print("fail to remove " + f)
|
||||||
|
|
||||||
|
def deleteFolder(path):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(path)
|
||||||
|
print("remove " + path)
|
||||||
|
except:
|
||||||
|
print("fail to remove " + path)
|
||||||
|
|
||||||
def javaDatei(form_file):
|
def javaDatei(form_file):
|
||||||
try:
|
try:
|
||||||
@@ -50,8 +59,6 @@ def generator():
|
|||||||
NSD = NassiShneidermanDiagram(True)
|
NSD = NassiShneidermanDiagram(True)
|
||||||
output_directory = output_path + '/' + outputname
|
output_directory = output_path + '/' + outputname
|
||||||
|
|
||||||
# if font_filepath != None:
|
|
||||||
# NSD.set_font(font_filepath)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(output_directory):
|
if not os.path.exists(output_directory):
|
||||||
@@ -66,7 +73,9 @@ def generator():
|
|||||||
NSD.convert_to_image(output_directory, on_conflict=behaviour)
|
NSD.convert_to_image(output_directory, on_conflict=behaviour)
|
||||||
|
|
||||||
zip_path = os.path.join(os.path.abspath(os.path.join('Web', os.pardir)), f'../tmp/output/{outputname}')
|
zip_path = os.path.join(os.path.abspath(os.path.join('Web', os.pardir)), f'../tmp/output/{outputname}')
|
||||||
zip.make_archive(zip_path, 'zip', output_directory)
|
shutil.make_archive(zip_path, 'zip', output_directory)
|
||||||
|
|
||||||
|
deleteFolder(output_path)
|
||||||
|
|
||||||
return send_file(zip_path + '.zip', as_attachment=True)
|
return send_file(zip_path + '.zip', as_attachment=True)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,11 @@
|
|||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<p></p>
|
<p>WARNING Because the Interpreter is still WIP, some Java language features are not supported. These include:
|
||||||
|
*foreach loops (will throw JavaSyntaxError)
|
||||||
|
*constructors (will be ignored)
|
||||||
|
*switch statements
|
||||||
|
Please remove these features from the source code as they will result in incorrect behaviour</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form method='Post' action='' enctype="multipart/form-data">
|
<form method='Post' action='' enctype="multipart/form-data">
|
||||||
|
|||||||
Reference in New Issue
Block a user