Commit b069b161 authored by Mikael Salson's avatar Mikael Salson Committed by Vidjil Team

fuse.py: Don't hardcode temporary files in which we store data.

The current directory is not necessarily writable by the web user.
Use temporary directory instead.
Fix 6cd61c5b
parent 8a2f0470
...@@ -36,6 +36,7 @@ import copy ...@@ -36,6 +36,7 @@ import copy
import os.path import os.path
import datetime import datetime
import subprocess import subprocess
import tempfile
from operator import itemgetter from operator import itemgetter
from utils import * from utils import *
...@@ -728,15 +729,16 @@ def main(): ...@@ -728,15 +729,16 @@ def main():
for i in range(len(jlist_fused.d["clones"])) : for i in range(len(jlist_fused.d["clones"])) :
fasta += ">>" + str(i) + "\n" fasta += ">>" + str(i) + "\n"
fasta += jlist_fused.d["clones"][i].d["id"] + "\n" fasta += jlist_fused.d["clones"][i].d["id"] + "\n"
fasta_file = open("tmp", 'w') fasta_file = tempfile.NamedTemporaryFile()
fasta_file.write(fasta) fasta_file.write(fasta)
try: try:
out = subprocess.check_output([TOOL_SIMILARITY, "-j", "tmp"]) out = subprocess.check_output([TOOL_SIMILARITY, "-j", fasta_file.name])
jlist_fused.d["similarity"] = json.loads(out) jlist_fused.d["similarity"] = json.loads(out)
except OSError: except OSError:
print("! failed: %s" % TOOL_SIMILARITY) print("! failed: %s" % TOOL_SIMILARITY)
print("### Save merged file") print("### Save merged file")
jlist_fused.save_json(args.output) jlist_fused.save_json(args.output)
unlink(fasta_file.name)
......
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