support partial url
This commit is contained in:
parent
823de61ea8
commit
b61fede263
@ -56,6 +56,8 @@ def getjson (url, max_retry=3, retry_sleep_time=0.5):
|
|||||||
if rurl != url:
|
if rurl != url:
|
||||||
ret["_url"] = rurl
|
ret["_url"] = rurl
|
||||||
return ret
|
return ret
|
||||||
|
except ValueError as e:
|
||||||
|
url = "http://localhost" + url
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
print ("HTTPError {0}".format(e), file=sys.stderr)
|
print ("HTTPError {0}".format(e), file=sys.stderr)
|
||||||
ret["_code"] = e.code
|
ret["_code"] = e.code
|
||||||
|
@ -4,6 +4,7 @@ from argparse import ArgumentParser
|
|||||||
import json
|
import json
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
from urllib2 import urlopen, HTTPError, URLError
|
from urllib2 import urlopen, HTTPError, URLError
|
||||||
|
from common import getjson
|
||||||
|
|
||||||
def main (args):
|
def main (args):
|
||||||
p = ArgumentParser("call listAllPads and print the results")
|
p = ArgumentParser("call listAllPads and print the results")
|
||||||
@ -22,7 +23,7 @@ def main (args):
|
|||||||
if args.showurl:
|
if args.showurl:
|
||||||
print requesturl
|
print requesturl
|
||||||
else:
|
else:
|
||||||
results = json.load(urlopen(requesturl))['data']['padIDs']
|
results = getjson(urlopen(requesturl))['data']['padIDs']
|
||||||
if args.format == "json":
|
if args.format == "json":
|
||||||
print json.dumps(results)
|
print json.dumps(results)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user