Example #1
0
    def __init__(self, buckets, runpath,
                 url=None,
                 replicas=None,
                 vbuckets=None,
                 nodes=4):
        """
        Creates a new instance of the mock server. You must actually call
        'start()' for it to be invoked.
        :param list buckets: A list of BucketSpec items
        :param string runpath: a string pointing to the location of the mock
        :param string url: The URL to use to download the mock. This is only
          used if runpath does not exist
        :param int replicas: How many replicas should each bucket have
        :param int vbuckets: How many vbuckets should each bucket have
        :param int nodes: How many total nodes in the cluster

        Note that you must have ``java`` in your `PATH`
        """


        self.runpath = runpath
        self.buckets = buckets
        self.nodes = nodes
        self.vbuckets = vbuckets
        self.replicas = replicas

        if not os.path.exists(runpath):
            if not url:
                raise Exception(runpath + " Does not exist and no URL specified")
            fp = open(runpath, "wb")
            ulp = urlopen(url)
            jarblob = ulp.read()
            fp.write(jarblob)
            fp.close()
    def __init__(self, buckets, runpath,
                 url=None,
                 replicas=None,
                 vbuckets=None,
                 nodes=4):
        """
        Creates a new instance of the mock server. You must actually call
        'start()' for it to be invoked.
        :param list buckets: A list of BucketSpec items
        :param string runpath: a string pointing to the location of the mock
        :param string url: The URL to use to download the mock. This is only
          used if runpath does not exist
        :param int replicas: How many replicas should each bucket have
        :param int vbuckets: How many vbuckets should each bucket have
        :param int nodes: How many total nodes in the cluster

        Note that you must have ``java`` in your `PATH`
        """


        self.runpath = runpath
        self.buckets = buckets
        self.nodes = nodes
        self.vbuckets = vbuckets
        self.replicas = replicas

        if not os.path.exists(runpath):
            if not url:
                raise Exception(runpath + " Does not exist and no URL specified")
            fp = open(runpath, "w")
            ulp = urlopen(url)
            fp.write(ulp.read())
            fp.close()
Example #3
0
 def _get_common(self, command, params):
     qparams = {}
     for k, v in params.items():
         qparams[k] = json.dumps(v)
     qparams = ulp.urlencode(qparams)
     url = self.urlbase + "{0}?{1}".format(command, qparams)
     data = urlopen(url).read()
     if not isinstance(data, basestring):
         data = str(data, "utf-8")
     ret = json.loads(data)
     return ret
 def _get_common(self, command, params):
     qparams = {}
     for k, v in params.items():
         qparams[k] = json.dumps(v)
     qparams = ulp.urlencode(qparams)
     url = self.urlbase + "{0}?{1}".format(command, qparams)
     data = urlopen(url).read()
     if not isinstance(data, basestring):
         data = str(data, "utf-8")
     ret = json.loads(data)
     return ret