Esempio n. 1
0
    def __init__(self,
                 appkey,
                 threads=1,
                 apiurl="http://localhost:8000",
                 apiversion="",
                 qsize=0,
                 timeout=5):
        """Constructor of Client object.

        """
        self.appkey = appkey
        self.threads = threads
        self.apiurl = apiurl
        self.apiversion = apiversion
        self.qsize = qsize
        self.timeout = timeout

        # check connection type
        https_pattern = r'^https://(.*)'
        http_pattern = r'^http://(.*)'
        m = re.match(https_pattern, apiurl)
        self.https = True
        if m is None:  # not matching https
            m = re.match(http_pattern, apiurl)
            self.https = False
            if m is None:  # not matching http either
                raise InvalidArgumentError("apiurl is not valid: %s" % apiurl)
        self.host = m.group(1)

        self._uid = None  # identified uid
        self._connection = Connection(host=self.host,
                                      threads=self.threads,
                                      qsize=self.qsize,
                                      https=self.https,
                                      timeout=self.timeout)