From 8747d80c894809036e8ce2cd8b6c02783eafe147 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sat, 12 Jul 2008 00:40:49 -0700 Subject: [PATCH 01/23] Initial checkin --- COPYING | 22 +++++++++++++++++++ hesiod.pyx | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 20 +++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 COPYING create mode 100644 hesiod.pyx create mode 100755 setup.py diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..787504c --- /dev/null +++ b/COPYING @@ -0,0 +1,22 @@ +Copyright (C) 2008 Evan Broder + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/hesiod.pyx b/hesiod.pyx new file mode 100644 index 0000000..1fc1d9e --- /dev/null +++ b/hesiod.pyx @@ -0,0 +1,63 @@ +cdef extern from "hesiod.h": + int hesiod_init(void **context) + void hesiod_end(void *context) + char *hesiod_to_bind(void *context, char *name, char *type) + char **hesiod_resolve(void *context, char *name, char *type) + void hesiod_free_string(void *context, char *str) + void hesiod_free_list(void *context, char **list) + +cdef extern from "errno.h": + int errno + +cdef void * __context + +cdef class __ContextManager: + def __init__(self): + if hesiod_init(&__context) == -1: + raise IOError, errno + + def __del__(self): + hesiod_end(__context) + +cdef object __cm +__cm = __ContextManager() + +def bind(hes_name, hes_type): + """ + Convert the provided arguments into a DNS name. + + The DNS name derived from the name and type provided is used to + actually execute the Hesiod lookup. + """ + cdef object py_result + cdef char * c_result + + c_result = hesiod_to_bind(__context, hes_name, hes_type) + if c_result is NULL: + raise IOError, errno + py_result = c_result + + hesiod_free_string(__context, c_result) + return py_result + +def resolve(hes_name, hes_type): + """ + Return a list of records matching the given name and type. + """ + cdef int i + cdef object py_result + py_result = list() + cdef char ** c_result + + c_result = hesiod_resolve(__context, hes_name, hes_type) + if c_result is NULL: + raise IOError, errno + i = 0 + while True: + if c_result[i] is NULL: + break + py_result.append(c_result[i]) + i += 1 + + hesiod_free_list(__context, c_result) + return py_result diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..cdb878f --- /dev/null +++ b/setup.py @@ -0,0 +1,20 @@ +#!/usr/bin/python + +from setuptools import setup +from distutils.extension import Extension +from Pyrex.Distutils import build_ext + +setup( + name="PyHesiod", + version="0.1.0", + description="PyHesiod - Python bindings for the Heisod naming library", + author="Evan Broder", + author_email="broder@mit.edu", + license="MIT", + ext_modules=[ + Extension("hesiod", + ["hesiod.pyx"], + libraries=["hesiod"]) + ], + cmdclass= {"build_ext": build_ext} +) From e6840130501e5d84c7e1776c3607b97660351c14 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sat, 12 Jul 2008 03:59:37 -0400 Subject: [PATCH 02/23] Apparently Debian/Ubuntu's libhesiod doesn't have hesiod_free_string --- hesiod.pyx | 10 +++++++--- setup.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hesiod.pyx b/hesiod.pyx index 1fc1d9e..54ee5cb 100644 --- a/hesiod.pyx +++ b/hesiod.pyx @@ -3,12 +3,16 @@ cdef extern from "hesiod.h": void hesiod_end(void *context) char *hesiod_to_bind(void *context, char *name, char *type) char **hesiod_resolve(void *context, char *name, char *type) - void hesiod_free_string(void *context, char *str) void hesiod_free_list(void *context, char **list) + # This function isn't defined in 3.0.2, which is what Debian/Ubuntu use + #void hesiod_free_string(void *context, char *str) cdef extern from "errno.h": int errno +cdef extern from "stdlib.h": + void free(void *) + cdef void * __context cdef class __ContextManager: @@ -37,7 +41,7 @@ def bind(hes_name, hes_type): raise IOError, errno py_result = c_result - hesiod_free_string(__context, c_result) + free(c_result) return py_result def resolve(hes_name, hes_type): @@ -57,7 +61,7 @@ def resolve(hes_name, hes_type): if c_result[i] is NULL: break py_result.append(c_result[i]) - i += 1 + i = i + 1 hesiod_free_list(__context, c_result) return py_result diff --git a/setup.py b/setup.py index cdb878f..35f6b56 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.1.0", + version="0.1.1", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From 3daccf289695255825e7fc254bc49c8838c6e427 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 29 Jul 2008 18:30:06 -0700 Subject: [PATCH 03/23] Make lookups threadsafe by locking around the hesiod_resolve call --- hesiod.pyx | 6 ++++++ setup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hesiod.pyx b/hesiod.pyx index 54ee5cb..92671da 100644 --- a/hesiod.pyx +++ b/hesiod.pyx @@ -26,6 +26,9 @@ cdef class __ContextManager: cdef object __cm __cm = __ContextManager() +import threading +__lookup_lock = threading.Lock() + def bind(hes_name, hes_type): """ Convert the provided arguments into a DNS name. @@ -53,7 +56,10 @@ def resolve(hes_name, hes_type): py_result = list() cdef char ** c_result + __lookup_lock.acquire() c_result = hesiod_resolve(__context, hes_name, hes_type) + __lookup_lock.release() + if c_result is NULL: raise IOError, errno i = 0 diff --git a/setup.py b/setup.py index 35f6b56..770b9fb 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.1.1", + version="0.1.2", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From 26863740faa4b286b2efb1e10aefaa9644ebd983 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 29 Jul 2008 22:32:43 -0700 Subject: [PATCH 04/23] Changee exposed hesiod module to be pure Python --- hesiod.pyx => _hesiod.pyx | 0 hesiod.py | 3 +++ setup.py | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) rename hesiod.pyx => _hesiod.pyx (100%) create mode 100755 hesiod.py diff --git a/hesiod.pyx b/_hesiod.pyx similarity index 100% rename from hesiod.pyx rename to _hesiod.pyx diff --git a/hesiod.py b/hesiod.py new file mode 100755 index 0000000..329d4df --- /dev/null +++ b/hesiod.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python + +from _hesiod import bind, resolve diff --git a/setup.py b/setup.py index 770b9fb..e2dae4a 100755 --- a/setup.py +++ b/setup.py @@ -11,9 +11,10 @@ author="Evan Broder", author_email="broder@mit.edu", license="MIT", + py_modules=['hesiod'], ext_modules=[ - Extension("hesiod", - ["hesiod.pyx"], + Extension("_hesiod", + ["_hesiod.pyx"], libraries=["hesiod"]) ], cmdclass= {"build_ext": build_ext} From fa0989051b6828f3af3e3c610532bb5531a2de34 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 29 Jul 2008 23:43:03 -0700 Subject: [PATCH 05/23] Convert arguments to strings in resolve and bind --- _hesiod.pyx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/_hesiod.pyx b/_hesiod.pyx index 92671da..31f580b 100644 --- a/_hesiod.pyx +++ b/_hesiod.pyx @@ -39,7 +39,9 @@ def bind(hes_name, hes_type): cdef object py_result cdef char * c_result - c_result = hesiod_to_bind(__context, hes_name, hes_type) + name_str, type_str = map(str, (hes_name, hes_type)) + + c_result = hesiod_to_bind(__context, name_str, type_str) if c_result is NULL: raise IOError, errno py_result = c_result @@ -56,8 +58,10 @@ def resolve(hes_name, hes_type): py_result = list() cdef char ** c_result + name_str, type_str = map(str, (hes_name, hes_type)) + __lookup_lock.acquire() - c_result = hesiod_resolve(__context, hes_name, hes_type) + c_result = hesiod_resolve(__context, name_str, type_str) __lookup_lock.release() if c_result is NULL: From 91c35078c7a8aad153d9aabe0b02fc3c48cfc76a Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 29 Jul 2008 23:44:49 -0700 Subject: [PATCH 06/23] Add object-oriented-style lookups for filsys, passwd, and uid lookups The filsys entry parsing code is taken from pyHesiodFS and was explicitly relicensed under the MIT license by Quentin Smith --- hesiod.py | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/hesiod.py b/hesiod.py index 329d4df..f708be5 100755 --- a/hesiod.py +++ b/hesiod.py @@ -1,3 +1,89 @@ #!/usr/bin/env python +""" +Present both functional and object-oriented interfaces for executing +lookups in Hesiod, Project Athena's service name resolution protocol. +""" + from _hesiod import bind, resolve + +from pwd import struct_passwd + +class HesiodParseError(Exception): + pass + +class Lookup(object): + """ + A Generic Hesiod lookup + """ + def __init__(self, hes_name, hes_type): + self.results = resolve(hes_name, hes_type) + self.parseRecords() + + def parseRecords(self): + pass + +class FilsysLookup(Lookup): + def __init__(self, name): + Lookup.__init__(self, name, 'filsys') + + def parseRecords(self): + Lookup.parseRecords(self) + + self.filsys = [] + self.multiRecords = (len(self.results) > 1) + + for result in self.results: + priority = 0 + if self.multiRecords: + result, priority = result.rsplit(" ", 1) + priority = int(priority) + + parts = result.split(" ") + type = parts[0] + if type == 'AFS': + self.filsys.append(dict(type=type, + location=parts[1], + mode=parts[2], + mountpoint=parts[3], + priority=priority)) + elif type == 'NFS': + self.filsys.append(dict(type=type, + remote_location=parts[1], + server=parts[2], + mode=parts[3], + mountpoint=parts[4], + priority=priority)) + elif type == 'ERR': + self.filsys.append(dict(type=type, + message=parts[1], + priority=priority)) + elif type == 'UFS': + self.filsys.append(dict(type=type, + device=parts[1], + mode=parts[2], + mountpoint=parts[3], + priority=priority)) + elif type == 'LOC': + self.filsys.append(dict(type=type, + location=parts[1], + mode=parts[2], + mountpoint=parts[3], + priority=priority)) + else: + raise HesiodParseError('Unknown filsys type: %s' % type) + +class PasswdLookup(Lookup): + def __init__(self, name): + Lookup.__init__(self, name, 'passwd') + + def parseRecords(self): + self.passwd = struct_passwd(self.results[0].split(':')) + +class UidLookup(PasswdLookup): + def __init__(self, uid): + Lookup.__init__(self, uid, 'uid') + +__all__ = ['bind', 'resolve', + 'Lookup', 'FilsysLookup', 'PasswdLookup', 'UidLookup', + 'HesiodParseError'] From caab8d196225f2018e3d6ab6e50dda382037351f Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 29 Jul 2008 23:52:50 -0700 Subject: [PATCH 07/23] Add support for group queries --- hesiod.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hesiod.py b/hesiod.py index f708be5..1da48a9 100755 --- a/hesiod.py +++ b/hesiod.py @@ -8,6 +8,7 @@ from _hesiod import bind, resolve from pwd import struct_passwd +from grp import struct_group class HesiodParseError(Exception): pass @@ -84,6 +85,21 @@ class UidLookup(PasswdLookup): def __init__(self, uid): Lookup.__init__(self, uid, 'uid') +class GroupLookup(Lookup): + def __init__(self, group): + Lookup.__init__(self, group, 'group') + + def parseRecords(self): + group_info = self.results[0].split(':') + group_info[3] = group_info[3].split(',') if group_info[3] != '' else [] + + self.group = struct_group(group_info) + +class GidLookup(GroupLookup): + def __init__(self, gid): + Lookup.__init__(self, gid, 'gid') + __all__ = ['bind', 'resolve', 'Lookup', 'FilsysLookup', 'PasswdLookup', 'UidLookup', + 'GroupLookup', 'GidLookup', 'HesiodParseError'] From 98c8c47a9154d06eb6c40e507d508a9624bbc608 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Wed, 30 Jul 2008 00:04:22 -0700 Subject: [PATCH 08/23] Bump version number to 0.2.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e2dae4a..d70d00a 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.1.2", + version="0.2.0", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From fbeb7b6d400f813c4ed9d293c5525a7c36b44d7d Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Wed, 30 Jul 2008 00:21:59 -0700 Subject: [PATCH 09/23] Add a quick note about a homepage --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d70d00a..0e4ce5b 100755 --- a/setup.py +++ b/setup.py @@ -6,10 +6,11 @@ setup( name="PyHesiod", - version="0.2.0", + version="0.2.1", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", + url="http://ebroder.net/code/PyHesiod", license="MIT", py_modules=['hesiod'], ext_modules=[ From 2eaec700bd987505deeec1986defd98d54e6bf8f Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Wed, 30 Jul 2008 11:32:43 -0700 Subject: [PATCH 10/23] Add a MANIFEST.in file to include COPYING in the source dist --- MANIFEST.in | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..eb762f3 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include COPYING diff --git a/setup.py b/setup.py index 0e4ce5b..22fdf54 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.1", + version="0.2.2", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From e3228e74a86436ab07482dd7c8a7300c42a0e735 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Wed, 30 Jul 2008 15:15:43 -0700 Subject: [PATCH 11/23] Fix dependency information --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 22fdf54..6715653 100755 --- a/setup.py +++ b/setup.py @@ -6,12 +6,13 @@ setup( name="PyHesiod", - version="0.2.2", + version="0.2.3", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", url="http://ebroder.net/code/PyHesiod", license="MIT", + requires=['Pyrex'], py_modules=['hesiod'], ext_modules=[ Extension("_hesiod", From 710b5864dde31a3b2d9c32eaa4361d51b2b360c0 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 31 Jul 2008 21:21:45 -0700 Subject: [PATCH 12/23] Fix invalid syntax in Python 2.4 --- hesiod.py | 7 ++++++- setup.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hesiod.py b/hesiod.py index 1da48a9..e08dd02 100755 --- a/hesiod.py +++ b/hesiod.py @@ -91,7 +91,12 @@ def __init__(self, group): def parseRecords(self): group_info = self.results[0].split(':') - group_info[3] = group_info[3].split(',') if group_info[3] != '' else [] + members = group_info[3] + if members != '': + members = members.split(',') + else: + members = [] + group_info[3] = members self.group = struct_group(group_info) diff --git a/setup.py b/setup.py index 6715653..3a00ebe 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.3", + version="0.2.4", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From 776e34d4d7d92b8c396a8bb88c67a61cce130d74 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 31 Jul 2008 21:53:08 -0700 Subject: [PATCH 13/23] I put shebangs at the top of modules out of habit, but Debian doesn't like them --- hesiod.py | 2 -- setup.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/hesiod.py b/hesiod.py index e08dd02..42c0f81 100755 --- a/hesiod.py +++ b/hesiod.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - """ Present both functional and object-oriented interfaces for executing lookups in Hesiod, Project Athena's service name resolution protocol. diff --git a/setup.py b/setup.py index 3a00ebe..4c08201 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.4", + version="0.2.5", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From b25635bb44309a438eed06e7554fa05c92fe07ce Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Sun, 10 Aug 2008 16:07:25 -0700 Subject: [PATCH 14/23] Raise IOError instances instead of tuples with a class --- _hesiod.pyx | 6 +++--- setup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_hesiod.pyx b/_hesiod.pyx index 31f580b..a4253e6 100644 --- a/_hesiod.pyx +++ b/_hesiod.pyx @@ -18,7 +18,7 @@ cdef void * __context cdef class __ContextManager: def __init__(self): if hesiod_init(&__context) == -1: - raise IOError, errno + raise IOError(errno) def __del__(self): hesiod_end(__context) @@ -43,7 +43,7 @@ def bind(hes_name, hes_type): c_result = hesiod_to_bind(__context, name_str, type_str) if c_result is NULL: - raise IOError, errno + raise IOError(errno) py_result = c_result free(c_result) @@ -65,7 +65,7 @@ def resolve(hes_name, hes_type): __lookup_lock.release() if c_result is NULL: - raise IOError, errno + raise IOError(errno) i = 0 while True: if c_result[i] is NULL: diff --git a/setup.py b/setup.py index 4c08201..8d5cad2 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.5", + version="0.2.6", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From 94ae59fbfec565bcd621e3c387ceff4e80dec652 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Mon, 11 Aug 2008 14:48:56 -0700 Subject: [PATCH 15/23] In passwd and group lookups, convert IDs to strings Reported by Anders Kaseorg --- hesiod.py | 6 +++++- setup.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hesiod.py b/hesiod.py index 42c0f81..604bebc 100755 --- a/hesiod.py +++ b/hesiod.py @@ -77,7 +77,10 @@ def __init__(self, name): Lookup.__init__(self, name, 'passwd') def parseRecords(self): - self.passwd = struct_passwd(self.results[0].split(':')) + passwd_info = self.results[0].split(':') + passwd_info[2] = int(passwd_info[2]) + passwd_info[3] = int(passwd_info[3]) + self.passwd = struct_passwd(passwd_info) class UidLookup(PasswdLookup): def __init__(self, uid): @@ -89,6 +92,7 @@ def __init__(self, group): def parseRecords(self): group_info = self.results[0].split(':') + group_info[2] = int(group_info[2]) members = group_info[3] if members != '': members = members.split(',') diff --git a/setup.py b/setup.py index 8d5cad2..95af3e8 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.6", + version="0.2.7", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From 934ad121560b56c9e9bd5f3674a160c439328931 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 12 Aug 2008 00:15:04 -0700 Subject: [PATCH 16/23] Actually set IOErrors correctly --- _hesiod.pyx | 9 ++++++--- setup.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/_hesiod.pyx b/_hesiod.pyx index a4253e6..6df6cf8 100644 --- a/_hesiod.pyx +++ b/_hesiod.pyx @@ -10,6 +10,9 @@ cdef extern from "hesiod.h": cdef extern from "errno.h": int errno +cdef extern from "string.h": + char * strerror(int errnum) + cdef extern from "stdlib.h": void free(void *) @@ -18,7 +21,7 @@ cdef void * __context cdef class __ContextManager: def __init__(self): if hesiod_init(&__context) == -1: - raise IOError(errno) + raise IOError(errno, strerror(errno)) def __del__(self): hesiod_end(__context) @@ -43,7 +46,7 @@ def bind(hes_name, hes_type): c_result = hesiod_to_bind(__context, name_str, type_str) if c_result is NULL: - raise IOError(errno) + raise IOError(errno, strerror(errno)) py_result = c_result free(c_result) @@ -65,7 +68,7 @@ def resolve(hes_name, hes_type): __lookup_lock.release() if c_result is NULL: - raise IOError(errno) + raise IOError(errno, strerror(errno)) i = 0 while True: if c_result[i] is NULL: diff --git a/setup.py b/setup.py index 95af3e8..8631beb 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.7", + version="0.2.8", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From ac653a047760b291e82809ca0b69f1b085ccf3d4 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 19 Aug 2008 21:31:34 -0500 Subject: [PATCH 17/23] Fix Linux bug where errno would get corrupted Reported by Anders Kaseorg --- _hesiod.pyx | 11 ++++++----- setup.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/_hesiod.pyx b/_hesiod.pyx index 6df6cf8..dee4fd2 100644 --- a/_hesiod.pyx +++ b/_hesiod.pyx @@ -1,4 +1,4 @@ -cdef extern from "hesiod.h": +cdef extern from : int hesiod_init(void **context) void hesiod_end(void *context) char *hesiod_to_bind(void *context, char *name, char *type) @@ -7,13 +7,13 @@ cdef extern from "hesiod.h": # This function isn't defined in 3.0.2, which is what Debian/Ubuntu use #void hesiod_free_string(void *context, char *str) -cdef extern from "errno.h": +cdef extern from : int errno -cdef extern from "string.h": +cdef extern from : char * strerror(int errnum) -cdef extern from "stdlib.h": +cdef extern from : void free(void *) cdef void * __context @@ -65,10 +65,11 @@ def resolve(hes_name, hes_type): __lookup_lock.acquire() c_result = hesiod_resolve(__context, name_str, type_str) + err = errno __lookup_lock.release() if c_result is NULL: - raise IOError(errno, strerror(errno)) + raise IOError(err, strerror(err)) i = 0 while True: if c_result[i] is NULL: diff --git a/setup.py b/setup.py index 8631beb..8ca0aba 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.8", + version="0.2.9", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From ffa42bfca0002801c7c6b89ca997cc9b07334592 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Tue, 19 Aug 2008 21:57:20 -0500 Subject: [PATCH 18/23] Undo a mistaken test commit --- _hesiod.pyx | 8 ++++---- setup.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/_hesiod.pyx b/_hesiod.pyx index dee4fd2..f0b41d9 100644 --- a/_hesiod.pyx +++ b/_hesiod.pyx @@ -1,4 +1,4 @@ -cdef extern from : +cdef extern from "hesiod.h": int hesiod_init(void **context) void hesiod_end(void *context) char *hesiod_to_bind(void *context, char *name, char *type) @@ -7,13 +7,13 @@ cdef extern from : # This function isn't defined in 3.0.2, which is what Debian/Ubuntu use #void hesiod_free_string(void *context, char *str) -cdef extern from : +cdef extern from "errno.h": int errno -cdef extern from : +cdef extern from "string.h": char * strerror(int errnum) -cdef extern from : +cdef extern from "stdlib.h": void free(void *) cdef void * __context diff --git a/setup.py b/setup.py index 8ca0aba..b308317 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.9", + version="0.2.9.1", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From 8fc04e6b3c08385384fd688aad789a0c3171a40c Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 20 Nov 2008 18:36:26 -0500 Subject: [PATCH 19/23] Version 0.2.10: Sort filsys entries based on priority --- hesiod.py | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hesiod.py b/hesiod.py index 604bebc..5cb3d1b 100755 --- a/hesiod.py +++ b/hesiod.py @@ -71,6 +71,8 @@ def parseRecords(self): priority=priority)) else: raise HesiodParseError('Unknown filsys type: %s' % type) + + self.filsys.sort(key=(lambda x: x['priority'])) class PasswdLookup(Lookup): def __init__(self, name): diff --git a/setup.py b/setup.py index b308317..8b499a4 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="PyHesiod", - version="0.2.9.1", + version="0.2.10", description="PyHesiod - Python bindings for the Heisod naming library", author="Evan Broder", author_email="broder@mit.edu", From 4244859e192890a5516ddcb86cfd6aa3b6b76771 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 23 Apr 2009 17:05:09 -0400 Subject: [PATCH 20/23] Add my stock README, adapted from PyMoira. --- README | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..5583b65 --- /dev/null +++ b/README @@ -0,0 +1,27 @@ +=================== +Installing PyHesiod +=================== + +To install PyHesiod, you will first need to install Pyrex_. It's +always a good idea to install Pyrex through your package manager, if +possible. Your system's Pyrex package may be named ``python-pyrex`` or +``pyrex-py25``. If your package manager doesn't have a package for +Pyrex, or if you wish to install Pyrex by hand anyway, you can do so +by running:: + + $ easy_install Pyrex + +Once you've done that, to install PyHesiod globally, run:: + + $ python setup.py install + +If you want to build PyHesiod without installing it globally, you may +want to run:: + + $ python setup.py build_ext --inplace + +which will build the C extensions in place next to their source, +allowing you to import the various modules, so long as your current +working directory is the root of the PyHesiod source tree. + +.. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ From ea3de19cac6da5bd468d12febb534a0853c53c43 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 23 Apr 2009 17:21:54 -0400 Subject: [PATCH 21/23] Add instructions to the README for building on Debian. --- README | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README b/README index 5583b65..bad6c02 100644 --- a/README +++ b/README @@ -24,4 +24,16 @@ which will build the C extensions in place next to their source, allowing you to import the various modules, so long as your current working directory is the root of the PyHesiod source tree. +Alternatively, PyHesiod has been packaged for Debian and Ubuntu. To +build the Debian package of the latest release, run:: + + $ git checkout debian + $ git buildpackage + $ sudo debi + +You will need the devscripts and git-buildpackage packages installed, +as well as this package's build dependencies (cdbs, debhelper, +python-all-dev, python-support, python-pyrex, python-setuptools, +libhesiod -dev). + .. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ From 2b11f727fe934efe8935ac3543fe538d14b8fafe Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 23 Apr 2009 17:27:31 -0400 Subject: [PATCH 22/23] Fix a typo in the README. --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index bad6c02..93deb59 100644 --- a/README +++ b/README @@ -34,6 +34,6 @@ build the Debian package of the latest release, run:: You will need the devscripts and git-buildpackage packages installed, as well as this package's build dependencies (cdbs, debhelper, python-all-dev, python-support, python-pyrex, python-setuptools, -libhesiod -dev). +libhesiod-dev). .. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ From bd2788081ce18e1b5a52525553a78a83594458d0 Mon Sep 17 00:00:00 2001 From: Alex Dehnert Date: Wed, 19 Jun 2013 03:25:45 -0400 Subject: [PATCH 23/23] Move python-hesiod into a subdirectory --- COPYING => python/COPYING | 0 MANIFEST.in => python/MANIFEST.in | 0 README => python/README | 0 _hesiod.pyx => python/_hesiod.pyx | 0 hesiod.py => python/hesiod.py | 0 setup.py => python/setup.py | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename COPYING => python/COPYING (100%) rename MANIFEST.in => python/MANIFEST.in (100%) rename README => python/README (100%) rename _hesiod.pyx => python/_hesiod.pyx (100%) rename hesiod.py => python/hesiod.py (100%) rename setup.py => python/setup.py (100%) diff --git a/COPYING b/python/COPYING similarity index 100% rename from COPYING rename to python/COPYING diff --git a/MANIFEST.in b/python/MANIFEST.in similarity index 100% rename from MANIFEST.in rename to python/MANIFEST.in diff --git a/README b/python/README similarity index 100% rename from README rename to python/README diff --git a/_hesiod.pyx b/python/_hesiod.pyx similarity index 100% rename from _hesiod.pyx rename to python/_hesiod.pyx diff --git a/hesiod.py b/python/hesiod.py similarity index 100% rename from hesiod.py rename to python/hesiod.py diff --git a/setup.py b/python/setup.py similarity index 100% rename from setup.py rename to python/setup.py