summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-08-08 19:12:06 -0500
committerDan McGee <dan@archlinux.org>2012-08-08 19:12:06 -0500
commit064a1b7699ef8f65ee1c123f93cd8da02e843dea (patch)
treea4709362e94e29d2bf12b10274cc479598d25cf8 /packages
parentb7a03d89d126989bf53005404759482e17163991 (diff)
Fix alpm ctypes interface on systems not having alpm
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages')
-rw-r--r--packages/alpm.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/packages/alpm.py b/packages/alpm.py
index a7f4c3b5..3762ea68 100644
--- a/packages/alpm.py
+++ b/packages/alpm.py
@@ -5,16 +5,23 @@ import operator
def load_alpm(name=None):
# Load the alpm library and set up some of the functions we might use
- if name == None:
+ if name is None:
name = find_library('alpm')
+ if name is None:
+ # couldn't locate the correct library
+ return None
try:
alpm = ctypes.cdll.LoadLibrary(name)
except OSError:
return None
- alpm.alpm_version.argtypes = ()
- alpm.alpm_version.restype = ctypes.c_char_p
- alpm.alpm_pkg_vercmp.argtypes = (ctypes.c_char_p, ctypes.c_char_p)
- alpm.alpm_pkg_vercmp.restype = ctypes.c_int
+ try:
+ alpm.alpm_version.argtypes = ()
+ alpm.alpm_version.restype = ctypes.c_char_p
+ alpm.alpm_pkg_vercmp.argtypes = (ctypes.c_char_p, ctypes.c_char_p)
+ alpm.alpm_pkg_vercmp.restype = ctypes.c_int
+ except AttributeError:
+ return None
+
return alpm