Selaa lähdekoodia

ZOOKEEPER-821. Add ZooKeeper version information to zkpython (Rich Schumacher via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@979461 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 15 vuotta sitten
vanhempi
commit
957b54a6a0

+ 3 - 0
CHANGES.txt

@@ -88,6 +88,9 @@ IMPROVEMENTS:
 
   ZOOKEEPER-790. Last processed zxid set prematurely while establishing leadership (fpj via breed)
 
+  ZOOKEEPER-821. Add ZooKeeper version information to zkpython (Rich
+  Schumacher via mahadev)
+
 NEW FEATURES:
   ZOOKEEPER-729. Java client API to recursively delete a subtree.
   (Kay Kay via henry)

+ 6 - 0
src/contrib/zkpython/src/c/zookeeper.c

@@ -1510,6 +1510,12 @@ PyMODINIT_FUNC initzookeeper(void) {
   PyModule_AddObject(module, "ZooKeeperException", ZooKeeperException);
   Py_INCREF(ZooKeeperException);
 
+  int size = 10;
+  char version_str[size];
+  snprintf(version_str, size, "%i.%i.%i", ZOO_MAJOR_VERSION, ZOO_MINOR_VERSION, ZOO_PATCH_VERSION);
+
+  PyModule_AddStringConstant(module, "__version__", version_str);
+
   ADD_INTCONSTANT(PERM_READ);
   ADD_INTCONSTANT(PERM_WRITE);
   ADD_INTCONSTANT(PERM_CREATE);

+ 4 - 1
src/contrib/zkpython/src/test/connection_test.py

@@ -16,7 +16,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import unittest, threading
+import unittest, threading, re
 
 import zookeeper, zktestbase
 ZOO_OPEN_ACL_UNSAFE = {"perms":0x1f, "scheme":"world", "id" :"anyone"}
@@ -117,6 +117,9 @@ class ConnectionTest(zktestbase.TestBase):
 
         self.assertEqual(True, all( zookeeper.close(h) == zookeeper.OK for h in handles ))
 
+    def testversionstringexists(self):
+        self.assertTrue(hasattr(zookeeper, '__version__'))
+        self.assertTrue(re.match("\d.\d.\d", zookeeper.__version__))
 
 
     def tearDown(self):