8
0
Fork 0
mirror of https://gitlab.federez.net/re2o/re2o synced 2024-06-02 07:52:23 +00:00

Fichier dot temporaire

This commit is contained in:
grisel-davy 2018-05-21 22:05:31 +02:00
parent 8cc1841f69
commit 93a9ce630f

View file

@ -48,7 +48,7 @@ from django.template import Context, Template, loader
from django.db.models.signals import post_save
from django.dispatch import receiver
import pprint
import tempfile
from users.views import form
from re2o.utils import re2o_paginator, SortTable
@ -1037,11 +1037,12 @@ def make_machine_graph():
dot_data=generate_dot(dico,'topologie/graph_switch.dot') # generate the dot file
fichier = open(MEDIA_ROOT + "/images/switchs.dot","w", encoding='utf-8')
fichier.write(dot_data)
fichier.close()
f = tempfile.NamedTemporaryFile(mode='w+', encoding='utf-8', delete=False) # Create a temporary file to store the dot data
with f:
f.write(dot_data)
unflatten = Popen( # unflatten the graph to make it look better
["unflatten","-l", "3", MEDIA_ROOT + "/images/switchs.dot"],
["unflatten","-l", "3", f.name],
stdout=PIPE
)
image = Popen( # pipe the result of the first command into the second