annotate couchdb_client.xml @ 0:907b95ba9cf7 draft

Uploaded
author kellrott
date Tue, 24 Jul 2012 17:40:26 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
1 <tool id="couchdb_client" name="CouchDB Client" version="1.0.0">
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
2 <description>CouchDB Client</description>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
3 <command interpreter="python">$scriptfile</command>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
4 <inputs>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
5 <param name="url" type="text" size="128" label="Server URL"/>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
6 <param name="db" type="text" size="32" label="Database"/>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
7 <param name="query" type="text" area="True" size="5x25" label="Query">
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
8 <sanitizer>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
9 <valid initial="string.printable"/>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
10 <mapping initial="none">
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
11 <add source="&#10;" target="__cn__"/>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
12 <add source="&quot;" target="__dq__"/>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
13 </mapping>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
14 </sanitizer>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
15 </param>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
16 </inputs>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
17 <outputs>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
18 <data name="output" format="txt"/>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
19 </outputs>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
20 <configfiles>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
21
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
22 <configfile name="scriptfile"><![CDATA[#!/usr/bin/env python
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
23 import couchdb.client
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
24 import json
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
25 import galaxy.eggs
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
26 import galaxy.util
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
27
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
28 server = couchdb.client.Server(galaxy.util.restore_text("$url"))
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
29 db = server['$db']
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
30
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
31 query=galaxy.util.restore_text("""$query""")
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
32 print query
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
33 result = db.query(query)
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
34 print result
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
35 handle = open(galaxy.util.restore_text("$output"), "w")
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
36 for row in result:
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
37 handle.write("{\"key\":%s, \"value\":%s}\n" % (json.dumps(row.key), json.dumps(row.value)))
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
38 handle.close()
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
39
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
40 ]]></configfile>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
41 </configfiles>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
42 <help>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
43
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
44
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
45 </help>
907b95ba9cf7 Uploaded
kellrott
parents:
diff changeset
46 </tool>