summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@xso>2011-08-22 15:28:34 +0200
committertv <tv@xso>2011-08-22 15:28:34 +0200
commit4186e40734ae9cf8ab20437b70d09eeae23399c4 (patch)
tree4ac764979979ab28a76d61737f3f66d2090f7824
parenta002b665583bad738e47bef6f93f87d6ab74bfda (diff)
ovh soapi *List: unify [JSON-] output
-rwxr-xr-xovh/soapi/domainList20
-rwxr-xr-xovh/soapi/zoneEntryList6
2 files changed, 11 insertions, 15 deletions
diff --git a/ovh/soapi/domainList b/ovh/soapi/domainList
index 3f829ebe..b089f6a4 100755
--- a/ovh/soapi/domainList
+++ b/ovh/soapi/domainList
@@ -1,24 +1,26 @@
#!/usr/bin/python
from os import environ
-import pprint
from SOAPpy import WSDL
+from json import dumps, JSONEncoder
+
+def default(o):
+ try:
+ iterable = iter(o)
+ except TypeError:
+ pass
+ else:
+ return list(iterable)
+ return JSONEncoder.default(o)
soap = WSDL.Proxy('https://www.ovh.com/soapi/soapi-re-1.24.wsdl')
username = environ['KREBS_OVH_USER']
password = environ['KREBS_OVH_PASS']
-#login
session = soap.login(username, password, 'de', 0)
-print "login successfull"
-#domainHostList
result = soap.domainList(session)
-print "domainList successfull"
-pp = pprint.PrettyPrinter(indent=4)
-pp.pprint(result) # your code here ...
+print dumps(result, sort_keys=True, indent=2, default=default)
-#logout
soap.logout(session)
-print "logout successfull"
diff --git a/ovh/soapi/zoneEntryList b/ovh/soapi/zoneEntryList
index eb9c9c09..00f56958 100755
--- a/ovh/soapi/zoneEntryList
+++ b/ovh/soapi/zoneEntryList
@@ -18,15 +18,9 @@ soap = WSDL.Proxy('https://www.ovh.com/soapi/soapi-re-1.24.wsdl')
username = environ['KREBS_OVH_USER']
password = environ['KREBS_OVH_PASS']
-#login
session = soap.login(username, password, 'de', 0)
-print "login successfull"
-#zoneEntryList
result = soap.zoneEntryList(session, 'krebsco.de')
-print "zoneEntryList successfull"
print dumps(result, sort_keys=True, indent=2, default=default)
-#logout
soap.logout(session)
-print "logout successfull"