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