Skip to content
Permalink
Browse files

fix(flow): add warning to jpg downloader

  • Loading branch information...
hanxiao committed Oct 12, 2019
1 parent e3ab1aa commit 7d2c681ec42d1026b8a37c0a26e744e5ae8a7863
Showing with 4 additions and 2 deletions.
  1. +4 −2 gnes/flow/__init__.py
@@ -238,7 +238,7 @@ def to_url(self, **kwargs) -> str:
return 'https://mermaidjs.github.io/mermaid-live-editor/#/view/%s' % encoded_str

@_build_level(BuildLevel.GRAPH)
def to_jpg(self, path: str = 'flow.jpg', **kwargs):
def to_jpg(self, path: str = 'flow.jpg', **kwargs) -> None:
"""
Rendering the current flow as a jpg image, this will call :py:meth:`to_mermaid` and it needs internet connection
@@ -249,7 +249,9 @@ def to_jpg(self, path: str = 'flow.jpg', **kwargs):

from urllib.request import Request, urlopen
encoded_str = self.to_url().replace('https://mermaidjs.github.io/mermaid-live-editor/#/view/', '')
self.logger.info('saving jpg...')
self.logger.warning('jpg exporting relies on https://mermaid.ink/, but it is not very stable. '
'some syntax are not supported, please use with caution.')
self.logger.info('downloading as jpg...')
req = Request('https://mermaid.ink/img/%s' % encoded_str, headers={'User-Agent': 'Mozilla/5.0'})
with open(path, 'wb') as fp:
fp.write(urlopen(req).read())

0 comments on commit 7d2c681

Please sign in to comment.
You can’t perform that action at this time.