DDEで遊んでみる。¶
Debian Data Export というのがあるようだ。 配布資料は無いし、スライドは小っちゃくて見えない ので、とりあえず勝手に遊んでみる。取り合えず、apt-fileの情報を取るというURIで、dashを引数で渡してみる。
$ curl http://dde.debian.net/dde/q/aptfile/byfile/sid-amd64/dash
<html><body>
<h1>Packages containing dash</h1>
<p>Value:</p>
<pre>
['dash', 'debian-edu-config', 'sauerbraten-data']
</pre>
<ol>
</ol>
<p><a href='http://dde.debian.net/dde/q/aptfile/byfile/sid-amd64'>Go up one level</a></p>
</body></html>
デフォルトではHTML形式のようだ。apt-file show dashやapt-file search dashで得られる情報とも違う。
出力形式はいくつかあるのでいろいろ試してみる。
JSON¶
$ curl http://dde.debian.net/dde/q/aptfile/byfile/sid-amd64/dash?t=json
{"r":["dash","debian-edu-config","sauerbraten-data"]}
YAML¶
$ curl http://dde.debian.net/dde/q/aptfile/byfile/sid-amd64/dash?t=yaml
---
- dash
- debian-edu-config
- sauerbraten-data
CSV¶
$ curl http://dde.debian.net/dde/q/aptfile/byfile/sid-amd64/dash?t=csv
dash
debian-edu-config
sauerbraten-data
text¶
$ curl http://dde.debian.net/dde/q/aptfile/byfile/sid-amd64/dash?t=text
['dash', 'debian-edu-config', 'sauerbraten-data']
debug¶
$ curl http://dde.debian.net/dde/q/aptfile/byfile/sid-amd64/dash?t=debug
<body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#6622aa">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><type 'exceptions.TypeError'></strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial">Python 2.5.2: /usr/bin/python<br>Sun Jul 26 11:53:12 2009</font></td></tr></table>
<p>A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.</p>
<table width="100%" cellspacing=0 cellpadding=0 border=0>
<tr><td bgcolor="#d8bbff"><big> </big><a href="file:///var/lib/python-support/python2.5/flup/server/fcgi_base.py">/var/lib/python-support/python2.5/flup/server/fcgi_base.py</a> in <strong>run</strong>(self=<flup.server.fcgi_base.Request object at 0x6000000000b2c390>)</td></tr>
<tr><td><font color="#909090"><tt><small> 556</small> """Runs the handler, flushes the streams, and ends the request."""<br>
</tt></font></td></tr>
<tr><td><font color="#909090"><tt><small> 557</small> try:<br>
</tt></font></td></tr>
<tr><td bgcolor="#ffccee"><tt><small> 558</small> protocolStatus, appStatus = self.server.handler(self)<br>
</tt></td></tr>
<tr><td><font color="#909090"><tt><small> 559</small> except:<br>
</tt></font></td></tr>
<tr><td><font color="#909090"><tt><small> 560</small> traceback.print_exc(file=self.stderr)<br>
</tt></font></td></tr>
<tr><td><small><font color="#909090">protocolStatus <em>undefined</em>, appStatus <em>undefined</em>, <strong>self</strong> = <flup.server.fcgi_base.Request object at 0x6000000000b2c390>, self.<strong>server</strong> = <flup.server.fcgi.WSGIServer object at 0x600000000086a6d0>, self.server.<strong>handler</strong> = <bound method WSGIServer.handler of <flup.server.fcgi.WSGIServer object at 0x600000000086a6d0>></font></small></td></tr></table>
<table width="100%" cellspacing=0 cellpadding=0 border=0>
<tr><td bgcolor="#d8bbff"><big> </big><a href="file:///var/lib/python-support/python2.5/flup/server/fcgi_base.py">/var/lib/python-support/python2.5/flup/server/fcgi_base.py</a> in <strong>handler</strong>(self=<flup.server.fcgi.WSGIServer object at 0x600000000086a6d0>, req=<flup.server.fcgi_base.Request object at 0x6000000000b2c390>)</td></tr>
<tr><td><font color="#909090"><tt><small> 1116</small> result = self.application(environ, start_response)<br>
</tt></font></td></tr>
<tr><td><font color="#909090"><tt><small> 1117</small> try:<br>
</tt></font></td></tr>
<tr><td bgcolor="#ffccee"><tt><small> 1118</small> for data in result:<br>
</tt></td></tr>
<tr><td><font color="#909090"><tt><small> 1119</small> if data:<br>
</tt></font></td></tr>
<tr><td><font color="#909090"><tt><small> 1120</small> write(data)<br>
</tt></font></td></tr>
<tr><td><small><font color="#909090">data <em>undefined</em>, <strong>result</strong> = <generator object at 0x600000000086bb00></font></small></td></tr></table>
<table width="100%" cellspacing=0 cellpadding=0 border=0>
<tr><td bgcolor="#d8bbff"><big> </big><a href="file:///org/dde.debian.net/home/dde/dde/wsgi.py">/org/dde.debian.net/home/dde/dde/wsgi.py</a> in <strong>handle_debug</strong>(self=<dde.wsgi.DDE object at 0x6000000000536310>, res=<dde.wsgi.Result instance at 0x6000000000993b48>, args=('aptfile', 'byfile', 'sid-amd64', 'dash'), kw={'t': 'debug'})</td></tr>
<tr><td><font color="#909090"><tt><small> 405</small> def handle_debug(self, res, args, kw):<br>
</tt></font></td></tr>
<tr><td><font color="#909090"><tt><small> 406</small> body = "Args: " + repr(args) + " kw: " + repr(kw)<br>
</tt></font></td></tr>
<tr><td bgcolor="#ffccee"><tt><small> 407</small> res.start_response(type = "text/plain", len = len(body))<br>
</tt></td></tr>
<tr><td><font color="#909090"><tt><small> 408</small> yield res<br>
</tt></font></td></tr>
<tr><td><font color="#909090"><tt><small> 409</small> <br>
</tt></font></td></tr>
<tr><td><small><font color="#909090"><strong>res</strong> = <dde.wsgi.Result instance at 0x6000000000993b48>, res.<strong>start_response</strong> = <bound method Result.start_response of <dde.wsgi.Result instance at 0x6000000000993b48>>, <em>builtin</em> <strong>type</strong> = <type 'type'>, <em>builtin</em> <strong>len</strong> = <built-in function len>, <strong>body</strong> = "Args: ('aptfile', 'byfile', 'sid-amd64', 'dash') kw: {'t': 'debug'}"</font></small></td></tr></table><p><strong><type 'exceptions.TypeError'></strong>: start_response() got an unexpected keyword argument 'len'
<br><tt><small> </small> </tt>args =
("start_response() got an unexpected keyword argument 'len'",)
<br><tt><small> </small> </tt>message =
"start_response() got an unexpected keyword argument 'len'"
pickleとかいうのもあるらしいが、文字化けしたので省略。何の情報をとっているのかよく分からんな。もうちょい遊んで調べてみるか。