Commit c6d4f0ac authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Don't ask for compression on standalone mode + fix bug on windows

parent b946b9f3
...@@ -161,7 +161,7 @@ class Functions: ...@@ -161,7 +161,7 @@ class Functions:
@staticmethod @staticmethod
def sort_fasta(job_name, fasta_file, index_file, lock_file, compress=False, mailer=None): def sort_fasta(job_name, fasta_file, index_file, lock_file, compress=False, mailer=None, mode="webserver"):
index, sample_name = Functions.read_index(index_file) index, sample_name = Functions.read_index(index_file)
is_compressed = fasta_file.endswith(".gz") is_compressed = fasta_file.endswith(".gz")
if is_compressed: if is_compressed:
...@@ -185,7 +185,7 @@ class Functions: ...@@ -185,7 +185,7 @@ class Functions:
if compress: if compress:
Functions.compress(fasta_file_o) Functions.compress(fasta_file_o)
os.remove(lock_file) os.remove(lock_file)
if mailer is not None and not os.path.exists(lock_file + ".pending"): if mode == "webserver" and mailer is not None and not os.path.exists(lock_file + ".pending"):
Functions.send_fasta_ready(mailer, job_name, sample_name, compress) Functions.send_fasta_ready(mailer, job_name, sample_name, compress)
@staticmethod @staticmethod
......
...@@ -86,36 +86,41 @@ dgenies.result.export.export_fasta = function(compress=false) { ...@@ -86,36 +86,41 @@ dgenies.result.export.export_fasta = function(compress=false) {
}; };
dgenies.result.export.ask_export_fasta = function () { dgenies.result.export.ask_export_fasta = function () {
let dialog = $("<div>") if (dgenies.mode === "webserver") {
.attr("id", "dialog-confirm") let dialog = $("<div>")
.attr("title", "Gzip?"); .attr("id", "dialog-confirm")
let icon = $("<span>") .attr("title", "Gzip?");
.attr("class", "ui-icon ui-icon-help") let icon = $("<span>")
.css("float", "left") .attr("class", "ui-icon ui-icon-help")
.css("margin", "12px 12px 20px 0"); .css("float", "left")
let body = $("<p>"); .css("margin", "12px 12px 20px 0");
body.append(icon); let body = $("<p>");
body.append("Compression is recommanded on slow connections. Download Gzip file?"); body.append(icon);
dialog.append(body); body.append("Compression is recommanded on slow connections. Download Gzip file?");
dialog.dialog({ dialog.append(body);
resizable: false, dialog.dialog({
height: "auto", resizable: false,
width: 500, height: "auto",
modal: true, width: 500,
buttons: { modal: true,
"Use default": function() { buttons: {
$( this ).dialog( "close" ); "Use default": function () {
dgenies.result.export.export_fasta(false); $(this).dialog("close");
}, dgenies.result.export.export_fasta(false);
"Use Gzip": function () { },
$( this ).dialog( "close" ); "Use Gzip": function () {
dgenies.result.export.export_fasta(true); $(this).dialog("close");
}, dgenies.result.export.export_fasta(true);
Cancel: function () { },
$( this ).dialog( "close" ); Cancel: function () {
$(this).dialog("close");
}
} }
} });
}); }
else {
dgenies.result.export.export_fasta(false);
}
}; };
dgenies.result.export.export_association_table = function () { dgenies.result.export.export_association_table = function () {
......
This diff is collapsed.
...@@ -391,21 +391,33 @@ def build_fasta(id_res): ...@@ -391,21 +391,33 @@ def build_fasta(id_res):
Path(lock_query).touch() Path(lock_query).touch()
if not compressed or MODE == "standalone": # If compressed, it will took a long time, so not wait if not compressed or MODE == "standalone": # If compressed, it will took a long time, so not wait
Path(lock_query + ".pending").touch() Path(lock_query + ".pending").touch()
thread = threading.Timer(1, Functions.sort_fasta, kwargs={ index_file = os.path.join(res_dir, "query.idx.sorted")
"job_name": id_res, if MODE == "webserver":
"fasta_file": query_fasta, thread = threading.Timer(1, Functions.sort_fasta, kwargs={
"index_file": os.path.join(res_dir, "query.idx.sorted"), "job_name": id_res,
"lock_file": lock_query, "fasta_file": query_fasta,
"compress": compressed, "index_file": index_file,
"mailer": mailer "lock_file": lock_query,
}) "compress": compressed,
thread.start() "mailer": mailer,
"mode": MODE
})
thread.start()
else:
Functions.sort_fasta(job_name=id_res,
fasta_file=query_fasta,
index_file=index_file,
lock_file=lock_query,
compress=compressed,
mailer=None,
mode=MODE)
if not compressed or MODE == "standalone": if not compressed or MODE == "standalone":
i = 0 if MODE == "webserver":
time.sleep(5) i = 0
while os.path.exists(lock_query) and (i < 2 or MODE == "standalone"):
i += 1
time.sleep(5) time.sleep(5)
while os.path.exists(lock_query) and (i < 2 or MODE == "standalone"):
i += 1
time.sleep(5)
os.remove(lock_query + ".pending") os.remove(lock_query + ".pending")
if os.path.exists(lock_query): if os.path.exists(lock_query):
return jsonify({"success": True, "status": 1, "status_message": "In progress"}) return jsonify({"success": True, "status": 1, "status_message": "In progress"})
......
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