def handleResponse(self,
                       method,
                       response,
                       opts={ 'success_msg':'',
                              'error_msg':'' }):
        """ parse response in standard way.
            """
        if response.status in [200, 201, 202, 204, 302]:
            if method == 'GET':
                return response.read()

            return "SUCCESS: %s" % opts['success_msg']

        if response.status == 401:
            print 'ERROR: unable to access the REST API - please check your username (-u) and password (-p)'
            sys.exit(2)

        print 'ERROR: %s (%d) %s' % (opts['error_msg'],
                                     response.status, response.reason)

        output_json = json.loads(response.read())
        print output_json
        if "errors" in output_json:
            for error_code,error_message in output_json["errors"].iteritems():
                print "ERROR: %s" % error_message

        sys.exit(2)
dataset/ETHPy150Open membase/membase-cli/restclient.py/RestClient.handleResponse/original