Commit 5ad93361 authored by Alain Takoudjou's avatar Alain Takoudjou

Update md5sum of instance for slaprunner SR

parent 4c815ff9
......@@ -18,6 +18,9 @@ $(document).ready( function() {
//User have double click on file in to the fileTree
loadFileContent(file);
}
$("#update").click(function(){
alert($("#parameter").val());
});
function loadFileContent(file){
$.ajax({
......
......@@ -23,9 +23,9 @@
<li><a href="#tab4">Partitions Content</a></li>
</ul><!-- //Tab buttons -->
<div class="tabDetails">
<div id="tab1" class="tabContents">
<div id="tab1" class="tabContents">
<p>Add your instance parameters here and click on the update button</p>
<textarea class="parameter">&lt;?xml version='1.0' encoding='utf-8'?&gt;</textarea>
<textarea class="parameter" id="parameter">&lt;?xml version='1.0' encoding='utf-8'?&gt;</textarea>
<input type="submit" name="update" id ="update" value="Update" class="button"/>
</div><!-- end tab1 -->
<div id="tab2" class="tabContents">
......
......@@ -3,6 +3,7 @@ import time
import subprocess
import os
from xml_marshaller import xml_marshaller
from xml.dom import minidom
import re
import urllib
from flask import jsonify
......@@ -12,6 +13,7 @@ import hashlib
import signal
class Popen(subprocess.Popen):
def __init__(self, *args, **kwargs):
kwargs['stdin'] = subprocess.PIPE
......@@ -549,3 +551,21 @@ def realpath(config, path, check_exist=True):
else:
return path
return False
def readParameters(path):
if os.path.exists(path):
try:
xmldoc = minidom.parse(path)
object = {}
for elt in xmldoc.childNodes:
sub_object = {}
for subnode in elt.childNodes:
if subnode.nodeType != subnode.TEXT_NODE:
sub_object[str(subnode.getAttribute('id'))] = str(subnode.
childNodes[0].data)
object[str(elt.tagName)] = sub_object
return object
except Exception, e:
return str(e)
else:
return "No such file or directory: " + path
\ No newline at end of file
......@@ -357,4 +357,26 @@ def getPath():
if not realfile:
return jsonify(code=0, result="Can not access to this file: Permission Denied!")
else:
return jsonify(code=1, result=realfile)
\ No newline at end of file
return jsonify(code=1, result=realfile)
@app.route("/loadParameterXml", methods=['POST'])
def redParameterXml():
content = request.form['parameter']
param_path = os.path.join(app.config['runner_workdir'], ".parameter.xml")
f = open(param_path, 'w')
f.write(content)
f.close()
result = readParameters(param_path)
if type(result) == type(''):
return jsonify(code=0, result="XML Error: " + result)
else:
return jsonify(code=1, result="")
@app.route("/getParameterXml", methods=['GET'])
def getParameterXml():
param_path = os.path.join(app.config['runner_workdir'], ".parameter.xml")
if os.path.exists(param_path):
content = open(param_path, 'w').read()
return jsonify(code=1, result=content)
else:
return jsonify(code=0, result="Error: Can not load default instance parameters")
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment