parameters: (self, url, data = None, files = None, keepCookies = True)
docstring: Queries a URL, optionally with some data (dictionary).
  
          If no data is specified, a GET request will be used.
          If some data is specified, a POST request will be used.
  
          If files is specified, it must be a dictionary like data but
          the values are filenames.
  
          By default, cookies are kept in-between requests.
  
          A HTTPError exception is raised if the response's HTTP code is not 200.
docstring_summary: Queries a URL, optionally with some data (dictionary).
docstring_tokens: Queries a URL optionally with some data ( dictionary ) .
function: def query(self, url, data = None, files = None, keepCookies = True):
          '''Queries a URL, optionally with some data (dictionary).
  
          If no data is specified, a GET request will be used.
          If some data is specified, a POST request will be used.
  
          If files is specified, it must be a dictionary like data but
          the values are filenames.
  
          By default, cookies are kept in-between requests.
  
          A HTTPError exception is raised if the response's HTTP code is not 200.
          '''
  
          if not keepCookies:
              self.discardCookies()
  
          url = self.baseUrl + url
  
          # make sure the logs are safe ... at least somewhat :)
          data4log = copy.copy(data)
          if data4log:
              if 'password' in data4log.keys():
                  data4log['password'] = '*'
  
          retries = [0] + list(self.retries)
  
          while True:
              logging.debug('Querying %s with data %s and files %s (retries left: %s, current sleep: %s)...', url, data4log, files, len(retries), retries[0])
  
              time.sleep(retries.pop(0))
  
              try:
                  self.curl.setopt(self.curl.URL, url)
                  self.curl.setopt(self.curl.HTTPGET, 1)
  
                  # from now on we use the token we got from the login
                  self.curl.setopt(pycurl.USERPWD, '%s:""' % ( str(self.token), ) )
                  self.curl.setopt(pycurl.HTTPHEADER, ['Accept: application/json'])
  
                  if data is not None or files is not None:
                      # If there is data or files to send, use a POST request
  
                      finalData = {}
  
                      if data is not None:
                          finalData.update(data)
  
                      if files is not None:
                          for (key, fileName) in files.items():
                              finalData[key] = (self.curl.FORM_FILE, fileName)
                      self.curl.setopt( self.curl.HTTPPOST, finalData.items() )
  
                  self.curl.setopt(pycurl.VERBOSE, 0)
  
                  response = cStringIO.StringIO()
                  self.curl.setopt(self.curl.WRITEFUNCTION, response.write)
                  self.curl.perform()
  
                  code = self.curl.getinfo(self.curl.RESPONSE_CODE)
  
                  if code in self.retryCodes and len(retries) > 0:
                      logging.debug('Retrying since we got the %s error code...', code)
                      continue
  
                  if code != 200:
                      raise HTTPError(code, response.getvalue())
  
                  return response.getvalue()
  
              except pycurl.error as e:
                  if len(retries) == 0:
                      raise e
                  logging.debug('Retrying since we got the %s pycurl exception...', str(e))
function_tokens: def query ( self , url , data = None , files = None , keepCookies = True ) : if not keepCookies : self . discardCookies ( ) url = self . baseUrl + url # make sure the logs are safe ... at least somewhat :) data4log = copy . copy ( data ) if data4log : if 'password' in data4log . keys ( ) : data4log [ 'password' ] = '*' retries = [ 0 ] + list ( self . retries ) while True : logging . debug ( 'Querying %s with data %s and files %s (retries left: %s, current sleep: %s)...' , url , data4log , files , len ( retries ) , retries [ 0 ] ) time . sleep ( retries . pop ( 0 ) ) try : self . curl . setopt ( self . curl . URL , url ) self . curl . setopt ( self . curl . HTTPGET , 1 ) # from now on we use the token we got from the login self . curl . setopt ( pycurl . USERPWD , '%s:""' % ( str ( self . token ) , ) ) self . curl . setopt ( pycurl . HTTPHEADER , [ 'Accept: application/json' ] ) if data is not None or files is not None : # If there is data or files to send, use a POST request finalData = { } if data is not None : finalData . update ( data ) if files is not None : for ( key , fileName ) in files . items ( ) : finalData [ key ] = ( self . curl . FORM_FILE , fileName ) self . curl . setopt ( self . curl . HTTPPOST , finalData . items ( ) ) self . curl . setopt ( pycurl . VERBOSE , 0 ) response = cStringIO . StringIO ( ) self . curl . setopt ( self . curl . WRITEFUNCTION , response . write ) self . curl . perform ( ) code = self . curl . getinfo ( self . curl . RESPONSE_CODE ) if code in self . retryCodes and len ( retries ) > 0 : logging . debug ( 'Retrying since we got the %s error code...' , code ) continue if code != 200 : raise HTTPError ( code , response . getvalue ( ) ) return response . getvalue ( ) except pycurl . error as e : if len ( retries ) == 0 : raise e logging . debug ( 'Retrying since we got the %s pycurl exception...' , str ( e ) )