Closed majbahUSC closed 4 years ago
I see.
I've not tested this on windows. Will fix now
Have you tried passing --export-path
?
Yes, but I got the same error using the path as well.
Can you paste the error in with the full command when you pass --export-path. Thanks!
You should really avoid creating paths by appending strings, the standard os.path
and pathlib
libraries are far more reliable and help avoid cross-platform issues. Next, don't assume that /tmp
is the temporary directory, Python has a tempfile
module to handle these issues.
I'd create a tempfile.TemporaryDirectory()
object, so that any files in it are automatically deleted when you are done rendering:
# in .render()
if path is None:
path = os.path.join('trees', datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + '.gv')
with tempfile.TemporaryDirectory() as self.tempdir:
# graphviz code, now ending in
g.render(path, view=view)
and
# in bar_chart
file = os.path.join(self.tempdir, format(time.time(), ".20f").replace('.', '') + '.png')
and remove all references to self.files
, including self.files.append(file)
and the remove_tmp_files
method. That moves responsibility to the standard Python library for generating paths that are compatible with Linux, Mac and Windows, and for cleaning up the temporary files you generate (they'll be gone when the with
block exits).
You should really avoid creating paths by appending strings, the standard
os.path
andpathlib
libraries are far more reliable and help avoid cross-platform issues. Next, don't assume that/tmp
is the temporary directory, Python has atempfile
module to handle these issues.I'd create a
tempfile.TemporaryDirectory()
object, so that any files in it are automatically deleted when you are done rendering:# in .render() if path is None: path = os.path.join('trees', datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + '.gv') with tempfile.TemporaryDirectory() as self.tempdir: # graphviz code, now ending in g.render(path, view=view)
and
# in bar_chart file = os.path.join(self.tempdir, format(time.time(), ".20f").replace('.', '') + '.png')
and remove all references to
self.files
, includingself.files.append(file)
and theremove_tmp_files
method. That moves responsibility to the standard Python library for generating paths that are compatible with Linux, Mac and Windows, and for cleaning up the temporary files you generate (they'll be gone when thewith
block exits).
Hi, I did that but still it is getting as PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\PS\AppData\Local\Temp\tmpus2ps0tk\tmp_eub1j8w.png'
I deleted temp files and restarted but still the same. Please help me to fix this. Thank you
Hi, while exporting the tree, I am getting the following error.![Capture](https://user-images.githubusercontent.com/16784935/69079273-9e978380-0a07-11ea-8906-3cf55828e8d2.PNG)