def convert():
	if not request.json or 'convert' not in request.json:
		abort(400)

	files = glob.glob('/home/ubuntu/msh/*.msh')
	file = '/home/ubuntu/msh/{}'.format(request.json['convert'])
	print file
	print request.json['convert']
	if request.json['convert'] == 'all':
		convert_group = group([convert_msh.s(msh) for msh in files])
		res = convert_group()

	elif file in files:
		convert_msh.delay(file)

	return redirect('/index')
def convert():
    if not request.json or "convert" not in request.json:
        abort(400)

    files = glob.glob("/home/ubuntu/msh/*.msh")
    file = "/home/ubuntu/msh/{}".format(request.json["convert"])
    print file
    print request.json["convert"]
    if request.json["convert"] == "all":
        convert_group = group([convert_msh.s(msh) for msh in files])
        res = convert_group()

    elif file in files:
        convert_msh.delay(file)

    return redirect("/index")
def gmsh():
	form = GMSHForm()
	if form.validate_on_submit():
		angle_start = str(form.angle_start.data)
		angle_stop = str(form.angle_stop.data)
		angles = str(form.angles.data)
		nodes = str(form.nodes.data)
		levels = str(form.levels.data)

		res = start_gmsh.delay(angle_start, angle_stop, angles, nodes, levels)
		res.get()

		files = glob.glob('/home/ubuntu/msh/*.msh')
		convert_group = group([convert_msh.s(msh) for msh in files])
		res = convert_group()

		return redirect('/index')

	return render_template('gmsh.html', form=form)
def gmsh():
    form = GMSHForm()
    if form.validate_on_submit():
        angle_start = str(form.angle_start.data)
        angle_stop = str(form.angle_stop.data)
        angles = str(form.angles.data)
        nodes = str(form.nodes.data)
        levels = str(form.levels.data)

        res = start_gmsh.delay(angle_start, angle_stop, angles, nodes, levels)
        res.get()

        files = glob.glob("/home/ubuntu/msh/*.msh")
        convert_group = group([convert_msh.s(msh) for msh in files])
        res = convert_group()

        return redirect("/index")

    return render_template("gmsh.html", form=form)