Commits

Ernesto Menéndez committed 4d2169e

pycurl

Comments (0)

Files changed (1)

nxweb/data/dkvs/__init__.py

 import StringIO
 import requests
 import json
+import pycurl
 from nxweb.data.dkvs.exception import InvalidId
 
 
     port = _server.get('port')
 
 
-    r = requests.get("http://%s:%s/riak/%s?keys=true&props=false" % (host,port,bucket_name))
-    keys = r.json.get('keys')
-
-
-    length = len(keys)
-    i = 0
-    print "Deleting %s Items" % length
-    for key in keys:
-        print "Deleting from bucket %s; %s Done" % (bucket_name, (i * 100) / length)
-        i = i + 1
-        if i % num_pause == 0:
-            time.sleep(sleeptime)
-        bucket.get(key).delete()
+    uri = "http://%s:%s/riak/%s?keys=true&props=false" % (host,port,bucket_name)
+    
+    
+    def on_receive(data):
+        keys = json.loads(data).get('keys')
+        length = len(keys)
+        i = 0
+        print "Deleting %s Items" % length
+        for key in keys:
+            print "Deleting from bucket %s; %s Done" % (bucket_name, (i * 100) / length)
+            i = i + 1
+            if i % num_pause == 0:
+                time.sleep(sleeptime)
+            bucket.get(key).delete()
+            
+    conn = pycurl.Curl()
+    conn.setopt(pycurl.URL, uri)
+    conn.setopt(pycurl.WRITEFUNCTION, on_receive)
+    conn.perform()
 
 
 def get_all_keys(bucket_name):