From 4186e40734ae9cf8ab20437b70d09eeae23399c4 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 22 Aug 2011 15:28:34 +0200 Subject: ovh soapi *List: unify [JSON-] output --- ovh/soapi/domainList | 20 +++++++++++--------- ovh/soapi/zoneEntryList | 6 ------ 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'ovh/soapi') 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" -- cgit v1.2.3