[ 備忘録 /python ] pyrad のサンプルファイルを使うとエラーになる
いつの間にか pyrad1.2 がリリースされていますが、sample フォルダの中の dictionary を使おうとすると↓のようなエラーが発生してしまうことがあります。
Python 2.6.4 (r264:75706, Nov 2 2009, 14:38:03)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyrad.dictionary import Dictionary
>>> radius_dictionary = Dictionary( "dictionary" )
pyrad.dictionary.Dictionary.ReadDictionary( dictionary )
/home/fmt/dev/pyrad-1.2/example/dictionary
/home/fmt/dev/pyrad-1.2/example/dictionary.compat
Traceback (most recent call last):
File "", line 1, in
File "/home/fmt/dev/pyrad-1.2/pyrad/dictionary.py", line 145, in __init__
self.ReadDictionary(dict)
File "/home/fmt/dev/pyrad-1.2/pyrad/dictionary.py", line 323, in ReadDictionary
for line in fil:
File "/home/fmt/dev/pyrad-1.2/pyrad/dictfile.py", line 108, in next
self.__ReadNode(inc)
File "/home/fmt/dev/pyrad-1.2/pyrad/dictfile.py", line 60, in __ReadNode
fd = open(fname, "rt")
IOError: [Errno 2] No such file or directory: '/home/fmt/dev/pyrad-1.2/example/dictionary.compat'
dictionary.compat なんて指定していないのに、読み込みエラーが発生しています。
原因は dictionary ファイルの先頭にある $INCLUDE で始まる部分。$INCLUDE の後に記述されているファイルをすべて読み込もうとしているため、ファイルがないとそこでエラーになってしまうのです。
ただ単に pyrad1.2 を試したいとか、余分な辞書ファイルはいらないという場合は以下の行をすべてコメントアウトしましょう。
$INCLUDE dictionary.compat # compability issues
$INCLUDE dictionary.acc
$INCLUDE dictionary.ascend
$INCLUDE dictionary.bay
$INCLUDE dictionary.cisco
$INCLUDE dictionary.livingston
$INCLUDE dictionary.microsoft
$INCLUDE dictionary.quintum
$INCLUDE dictionary.redback
$INCLUDE dictionary.shasta
$INCLUDE dictionary.shiva
$INCLUDE dictionary.tunnel
$INCLUDE dictionary.usr
$INCLUDE dictionary.versanet
$INCLUDE dictionary.erx
$INCLUDE dictionary.freeradius
$INCLUDE dictionary.alcatel
| 固定リンク
この記事へのコメントは終了しました。
コメント