|
|
@ -1,3 +1,5 @@ |
|
|
|
"""Initialize an etherpump folder""" |
|
|
|
|
|
|
|
import json |
|
|
|
import os |
|
|
|
import sys |
|
|
@ -11,7 +13,6 @@ def get_api(url, cmd=None, data=None, verbose=False): |
|
|
|
useurl = url + cmd |
|
|
|
if data: |
|
|
|
useurl += "?" + urlencode(data) |
|
|
|
# data['apikey'] = "7c8faa070c97f83d8f705c935a32d5141f89cbaa2158042fa92e8ddad5dbc5e1" |
|
|
|
if verbose: |
|
|
|
print("trying", useurl, file=sys.stderr) |
|
|
|
resp = urlopen(useurl).read() |
|
|
@ -29,10 +30,6 @@ def get_api(url, cmd=None, data=None, verbose=False): |
|
|
|
if e.code == 401: |
|
|
|
# Unauthorized is how the API responds to an incorrect API key |
|
|
|
return {"code": 401, "message": e} |
|
|
|
# resp = json.load(e) |
|
|
|
# if "code" in resp and "message" in resp: |
|
|
|
# # print ("returning", resp, file=sys.stderr) |
|
|
|
# return resp |
|
|
|
|
|
|
|
|
|
|
|
def tryapiurl(url, verbose=False): |
|
|
@ -58,8 +55,6 @@ def tryapiurl(url, verbose=False): |
|
|
|
apiurl = urlunparse((scheme, netloc, path, params, query, fragment)) |
|
|
|
if get_api(apiurl, "listAllPads", verbose=verbose): |
|
|
|
return apiurl |
|
|
|
# except ValueError as e: |
|
|
|
# print ("ValueError", e, file=sys.stderr) |
|
|
|
except URLError as e: |
|
|
|
print("URLError", e, file=sys.stderr) |
|
|
|
|
|
|
|