-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,591 additions
and
1,051 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Changes in version 0.3.1 (10 April 2015) | ||
|
||
* implemented asynchronous queries, bound to Context() | ||
objects, and introduced Context.run() method. See | ||
getdns.readthedocs.org | ||
|
||
* queries now return a Result() object, with attributes. | ||
See getdns.readthedocs.org | ||
|
||
* removed leading GETDNS_ in all constants | ||
(i.e. getdns.GETDNS_RRTYPE_AAAA is now getdns.RRTYPE_AAAA) | ||
|
||
* added getdns.get_errorstr_by_id() method, making it easier | ||
to provide user-friendly error messages | ||
|
||
* prettied up printing of canonical names in Result object | ||
|
||
* str and repr printing has been added to both Context and | ||
Result objects | ||
|
||
* dead code removed | ||
|
||
* replaced instances of getdns_strerror() with | ||
getdns_get_errorstr_by_id() | ||
|
||
* fixed incorrect error return from Result construction | ||
|
||
* moved __version__ attribute from Context to top-level | ||
getdns module | ||
|
||
* made exception handling within the module more consistent | ||
|
||
* added documentation describing getdns.error | ||
|
||
* broke out query types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <Python.h> | ||
#include <getdns/getdns.h> | ||
#include <arpa/inet.h> | ||
#include "pygetdns.h" | ||
|
||
|
||
/* | ||
* Get the address of the Python function object | ||
* being passed in by name to the context | ||
* query methods | ||
*/ | ||
|
||
PyObject * | ||
get_callback(char *py_main, char *callback) | ||
{ | ||
PyObject *main_module; | ||
PyObject *main_dict; | ||
PyObject *callback_func; | ||
|
||
if ((main_module = PyImport_AddModule(py_main)) == 0) { | ||
PyErr_SetString(getdns_error, "No 'main'"); | ||
return NULL; | ||
} | ||
main_dict = PyModule_GetDict(main_module); | ||
if ((callback_func = PyDict_GetItemString(main_dict, callback)) == 0) { | ||
PyErr_SetString(getdns_error, "callback not found\n"); | ||
return NULL; | ||
} | ||
if (!PyCallable_Check(callback_func)) { | ||
PyErr_SetString(getdns_error, "The callback function is not runnable"); | ||
return NULL; | ||
} | ||
return callback_func; | ||
} | ||
|
||
|
||
void | ||
callback_shim(struct getdns_context *context, | ||
getdns_callback_type_t type, | ||
struct getdns_dict *response, | ||
void *userarg, | ||
getdns_transaction_t tid) | ||
{ | ||
PyObject *py_callback_type; | ||
PyObject *py_result; | ||
PyObject *py_tid; | ||
PyObject *py_userarg; | ||
|
||
userarg_blob *u = (userarg_blob *)userarg; | ||
if ((py_callback_type = PyInt_FromLong((long)type)) == NULL) { | ||
PyObject *err_type, *err_value, *err_traceback; | ||
PyErr_Fetch(&err_type, &err_value, &err_traceback); | ||
PyErr_Restore(err_type, err_value, err_traceback); | ||
return; | ||
} | ||
if (type == GETDNS_CALLBACK_CANCEL) { | ||
py_result = Py_None; | ||
py_tid = Py_None; | ||
py_userarg = Py_None; | ||
} else { | ||
py_result = result_create(response); | ||
py_tid = PyInt_FromLong((long)tid); | ||
if (u->userarg) | ||
py_userarg = PyString_FromString(u->userarg); | ||
else | ||
py_userarg = Py_None; | ||
} | ||
PyObject_CallFunctionObjArgs(u->callback_func, py_callback_type, py_result, py_userarg, py_tid, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
:mod:`getdns` exceptions | ||
============================= | ||
|
||
.. module:: getdns | ||
:synopsis: getdns exception description and explanation | ||
.. sectionauthor:: Melinda Shore <[email protected]> | ||
|
||
|
||
getdns exceptions | ||
----------------- | ||
|
||
.. py:exception:: getdns.error | ||
getdns will throw an exception, ``getdns.error``, under | ||
certain conditions. Those conditions include: | ||
|
||
* a required parameter having a bad value | ||
* a badly-formed domain name in the query | ||
* a bad ``Context()`` object | ||
* a failed ``Context()`` update | ||
* an out-of-bounds error for a getdns data structure | ||
* requesting an extension that doesn't exist | ||
* requesting DNSSEC validation while using stub | ||
resolution | ||
|
||
Please note that a successful return from a getdns method | ||
does `not` indicate that the query returned the records | ||
being requested, but rather that the query is formed | ||
correctly and has been submitted to the DNS. A getdns | ||
exception is typically the result of a coding error. | ||
|
||
getdns will set the exception message to a diagnostic | ||
string, which may be examined for help in resolving the | ||
error. | ||
|
||
Example | ||
------- | ||
|
||
:: | ||
|
||
import getdns, sys | ||
c = getdns.Context() | ||
try: | ||
results = c.address('www.example.com', foo='bar') | ||
except getdns.error, e: | ||
print(str(e)) | ||
sys.exit(1) | ||
|
||
|
||
This will result in "A required parameter had an invalid | ||
value" being printed to the screen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.