| 1 |
#!/usr/bin/env python
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
|
| 4 |
# Copyright © 2007-2008 Stefano Zacchiroli <zack@debian.org>
|
| 5 |
#
|
| 6 |
# This program is free software: you can redistribute it and/or modify
|
| 7 |
# it under the terms of the GNU General Public License as published by
|
| 8 |
# the Free Software Foundation, either version 3 of the License, or
|
| 9 |
# (at your option) any later version.
|
| 10 |
|
| 11 |
import sys
|
| 12 |
|
| 13 |
default_url = 'http://packages.qa.debian.org/cgi-bin/soap-alpha.cgi'
|
| 14 |
|
| 15 |
def zsi_query(soap_url, method, **kwargs):
|
| 16 |
from ZSI.client import NamedParamBinding as NPBinding
|
| 17 |
|
| 18 |
ws = NPBinding(url=soap_url) # tracefile=sys.stdout)
|
| 19 |
return getattr(ws, method)(**kwargs)
|
| 20 |
|
| 21 |
def soappy_query(soap_url, method, **kwargs):
|
| 22 |
import SOAPpy
|
| 23 |
|
| 24 |
ws = SOAPpy.SOAPProxy(url)
|
| 25 |
# ws.config.dumpSOAPOut = True
|
| 26 |
# ws.config.dumpSOAPIn = True
|
| 27 |
return getattr(ws, method)(**kwargs)
|
| 28 |
|
| 29 |
if __name__ == '__main__':
|
| 30 |
url = default_url
|
| 31 |
try:
|
| 32 |
if sys.argv[1] in ['-u', '--url']:
|
| 33 |
url = sys.argv[2]
|
| 34 |
del(sys.argv[:2])
|
| 35 |
method = sys.argv[1]
|
| 36 |
args = dict(map(lambda s:s.split('='), sys.argv[2:]))
|
| 37 |
except IndexError:
|
| 38 |
print "Usage: soap_query.py [(-u|--url) URL] METHOD [PARAM_NAME=PARAM_VALUE ...]"
|
| 39 |
print " URL: URL of the target CGI queries should be submitted to"
|
| 40 |
print " Default:", default_url
|
| 41 |
print " METHOD: method to be invoked"
|
| 42 |
print " PARAMS: keyword argument / argument value pairs; =-separated"
|
| 43 |
print "E.g.: ./soap_query.py latest_version source=ocaml"
|
| 44 |
sys.exit(1)
|
| 45 |
|
| 46 |
# print zsi_query(url, method, **args)
|
| 47 |
print soappy_query(url, method, **args)
|
| 48 |
|