blockdiagとかを試してみた
対象
以下の条件に阻まれている人
- Wiki External Filter Plugin を導入してみた - miauの避難所 を導入してみたひと
- 次のようなエラーに悩まされている方
PILライブラリが見当たらないエラー。
Error executing the <strong>nwdiag</strong> macro (Error applying external filter: stdout is (略), stderr is Traceback (most recent call last): File "/usr/bin/nwdiag", line 7, in ? sys.exit( File "/usr/lib/python2.4/site-packages/nwdiag-0.2.4-py2.4.egg/nwdiag/command.py", line 122, in main draw.draw() File "/usr/lib/python2.4/site-packages/nwdiag-0.2.4-py2.4.egg/nwdiag/DiagramDraw.py", line 53, in draw super(DiagramDraw, self).draw() File "/usr/lib/python2.4/site-packages/blockdiag-0.8.1-py2.4.egg/blockdiag/DiagramDraw.py", line 122, in draw self.node(node, **kwargs) File "/usr/lib/python2.4/site-packages/nwdiag-0.2.4-py2.4.egg/nwdiag/DiagramDraw.py", line 82, in node fontsize=self.metrix.fontSize) File "/usr/lib/python2.4/site-packages/blockdiag-0.8.1-py2.4.egg/blockdiag/ImageDrawEx.py", line 263, in textarea lines = TextFolder(box, string, scale=self.scale_ratio, **kwargs) File "/usr/lib/python2.4/site-packages/blockdiag-0.8.1-py2.4.egg/blockdiag/utils/PILTextFolder.py", line 27, in __init__ self.ttfont = ImageFont.truetype(font, fontsize) File "/usr/lib/python2.4/site-packages/PIL-1.1.7-py2.4-linux-i686.egg/ImageFont.py", line 218, in truetype return FreeTypeFont(filename, size, index, encoding) File "/usr/lib/python2.4/site-packages/PIL-1.1.7-py2.4-linux-i686.egg/ImageFont.py", line 134, in __init__ self.font = core.getfont(file, size, index, encoding) File "/usr/lib/python2.4/site-packages/PIL-1.1.7-py2.4-linux-i686.egg/ImageFont.py", line 34, in __getattr__ raise ImportError("The _imagingft C module is not installed") ImportError: The _imagingft C module is not installed )
なので、以下を実行して再度(CentOS5.6)
sudo yum install python-imaging #本当はsudo suはよくない(出来ないことが多いので、rootでのログインを推奨、proxyを使う場合) sudo su export HTTP_PROXY=http://proxyserver:portno/ export HTTPS_PROXY=http://proxyserver:portno/ easy_install PIL
としても、型が合わないと怒られる(なんで?)
Error executing the <strong>nwdiag</strong> macro (Error applying external filter: stdout is (略), stderr is Traceback (most recent call last): File "/usr/bin/nwdiag", line 7, in ? sys.exit( File "/usr/lib/python2.4/site-packages/nwdiag-0.2.4-py2.4.egg/nwdiag/command.py", line 122, in main draw.draw() File "/usr/lib/python2.4/site-packages/nwdiag-0.2.4-py2.4.egg/nwdiag/DiagramDraw.py", line 53, in draw super(DiagramDraw, self).draw() File "/usr/lib/python2.4/site-packages/blockdiag-0.8.1-py2.4.egg/blockdiag/DiagramDraw.py", line 122, in draw self.node(node, **kwargs) File "/usr/lib/python2.4/site-packages/nwdiag-0.2.4-py2.4.egg/nwdiag/DiagramDraw.py", line 82, in node fontsize=self.metrix.fontSize) File "/usr/lib/python2.4/site-packages/blockdiag-0.8.1-py2.4.egg/blockdiag/ImageDrawEx.py", line 263, in textarea lines = TextFolder(box, string, scale=self.scale_ratio, **kwargs) File "/usr/lib/python2.4/site-packages/blockdiag-0.8.1-py2.4.egg/blockdiag/utils/PILTextFolder.py", line 36, in __init__ TextFolder.__init__(self, box, string, **kwargs) File "/usr/lib/python2.4/site-packages/blockdiag-0.8.1-py2.4.egg/blockdiag/utils/TextFolder.py", line 102, in __init__ self._result = self._lines() File "/usr/lib/python2.4/site-packages/blockdiag-0.8.1-py2.4.egg/blockdiag/utils/TextFolder.py", line 255, in _lines if metrics[0] <= size[0]: TypeError: unsubscriptable object )
上記現象は、フォントを指定に関連して発生している模様(環境による部分が大きい)。
自分の力の限界を感じたのでチケットを発行しました。
対策
ことから、
という手順を思いついた。
まずは下準備。http://web.fpso.jp/article.php/20080101013132688 を参考にしました。
sudo yum install librsvg2
blockdiagを仕込む部分を変更する
blockdiag: description: "Constructs block-diagram image from its textual description in blockdiag language, see http://tk0miya.bitbucket.org/blockdiag/build/html/index.html" template: svg outputs: - command: "/usr/bin/blockdiag -T svg -o /dev/stdout /dev/stdin" content_type: "image/svg+xml" - command: "/usr/bin/blockdiag -T png -f /usr/share/fonts/japanese/TrueType/sazanami-gothic.ttf -a -o /dev/stdout /dev/stdin" content_type: "image/png"
を以下のように記述する。
blockdiag: description: "Constructs block-diagram image from its textual description in blockdiag language, see http://tk0miya.bitbucket.org/blockdiag/build/html/index.html" template: svg outputs: - command: "/usr/bin/blockdiag -T svg -o /dev/stdout /dev/stdin" content_type: "image/svg+xml" - command: "/usr/bin/blockdiag -T svg -o /dev/stdout /dev/stdin | rsvg-convert -f png /dev/stdin" content_type: "image/png"
出来ました。
ついでに
ダイアグ! を見ると、blockdiagシリーズが結構あるので、同じ要領で、(ついでに)redmineに組み込んでしまう。
※インストールや組み込みは一気にやっても問題はないです。
インストール
#本当はsudo suはよくない(出来ないことが多いので、rootでのログインを推奨、proxyを使う場合) sudo su export HTTP_PROXY=http://proxyserver:portno/ export HTTPS_PROXY=http://proxyserver:portno/ #easy_install blockdiag easy_install seqdiag easy_install actdiag easy_install nwdiag
seqdiag
適当な場所へ追加。
seqdiag: description: "Constructs sequence-diagram image from its textual description in seqdiag language, see http://tk0miya.bitbucket.org/seqdiag/build/html/index.html" template: svg outputs: - command: "/usr/bin/seqdiag -T svg -o /dev/stdout /dev/stdin" content_type: "image/svg+xml" - command: "/usr/bin/seqdiag -T svg -o /dev/stdout /dev/stdin | rsvg-convert -f png /dev/stdin" content_type: "image/png"
actdiag
適当な場所へ追加。
actdiag: description: "Constructs action-diagram image from its textual description in actdiag language, see http://tk0miya.bitbucket.org/actdiag/build/html/index.html" template: svg outputs: - command: "/usr/bin/actdiag -T svg -o /dev/stdout /dev/stdin" content_type: "image/svg+xml" - command: "/usr/bin/actdiag -T svg -o /dev/stdout /dev/stdin | rsvg-convert -f png /dev/stdin" content_type: "image/png"
nwdiag
適当な場所へ追加。
nwdiag: description: "Constructs network-diagram image from its textual description in nwdiag language, see http://tk0miya.bitbucket.org/nwdiag/build/html/index.html" template: svg outputs: - command: "/usr/bin/nwdiag -T svg -o /dev/stdout /dev/stdin" content_type: "image/svg+xml" - command: "/usr/bin/nwdiag -T svg -o /dev/stdout /dev/stdin | rsvg-convert -f png /dev/stdin" content_type: "image/png"
multiple svgエラー ... 対策を考え中。
↑、解決しました。「rsvg-convert -f png /dev/stdin」と入力すべき箇所が「rsvg-convert -f png /dev/std」となっていました。コピペするときは正しく貼り付けているかを確認すべきでした。
その他
便利なものを提供していただいて大変ありがとうございます!