Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MB-6928: import ctypes with fallback

Fallback steps:
1. Try to import ctypes from our library
2. If import fails - remove couchbase library from system path and
try again.
3. Exit if it still fails; otherwise return library to system path
and keep working.

Change-Id: I2b556597bb070b1426ca6824af6e9f58bf363953
Reviewed-on: http://review.couchbase.org/21750
Reviewed-by: Bin Cui <bin.cui@gmail.com>
Tested-by: Pavel Paulau <pavel.paulau@gmail.com>
  • Loading branch information...
commit d0e70d0dece8e4f4d0a782f4ac5452509fb3919b 1 parent 772f66a
@pavel-paulau pavel-paulau authored Farshid Ghods committed
Showing with 14 additions and 1 deletion.
  1. +14 −1 python/couchstore.py
View
15 python/couchstore.py
@@ -1,7 +1,20 @@
# couchstore.py
# Python interface to CouchStore library
-from ctypes import * # <http://docs.python.org/library/ctypes.html>
+try:
+ from ctypes import *
+except ImportError:
+ import sys
+ cb_path = '/opt/couchbase/lib/python'
+ while cb_path in sys.path:
+ sys.path.remove(cb_path)
+ try:
+ from ctypes import *
+ except ImportError:
+ sys.exit('error: could not import ctypes module')
+ else:
+ sys.path.insert(0, cb_path)
+
import errno
import traceback
Please sign in to comment.
Something went wrong with that request. Please try again.