Explorar el Código

Fix error handling in get_token().

tags/v0.2
Ben Kurtovic hace 12 años
padre
commit
1bfe5c2ee7
Se han modificado 1 ficheros con 6 adiciones y 6 borrados
  1. +6
    -6
      earwigbot/wiki/site.py

+ 6
- 6
earwigbot/wiki/site.py Ver fichero

@@ -778,16 +778,16 @@ class Site(object):
API issue. API issue.
""" """
if lock: if lock:
result = self.api_query(action="tokens", type=action)
res = self.api_query(action="tokens", type=action)
else: else:
params = {"action": "tokens", "type": action} params = {"action": "tokens", "type": action}
result = self._api_query(params, ae_retry=False)
res = self._api_query(params, ae_retry=False)


if "warnings" in result and "token" in result["warnings"]:
raise exceptions.PermissionsError(result["warnings"]["token"]["*"])
if "warnings" in res and "tokens" in res["warnings"]:
raise exceptions.PermissionsError(res["warnings"]["tokens"]["*"])
if "|" in action: if "|" in action:
return result["tokens"]
return result["tokens"].values()[0]
return res["tokens"]
return res["tokens"].values()[0]


def namespace_id_to_name(self, ns_id, all=False): def namespace_id_to_name(self, ns_id, all=False):
"""Given a namespace ID, returns associated namespace names. """Given a namespace ID, returns associated namespace names.


Cargando…
Cancelar
Guardar