@call_interval(0.25)
    def request(self, url, token=None, verb='GET', filename=None, **args):
        """`url` may be relative with regard to Netflix. Verb is a
        HTTP verb.

        """
        if isinstance(url, NetflixObject) and not isinstance(url, basestring):
            url = url.id
        if not url.startswith('http://'):
            url = self.protocol + self.host + url
        if 'output' not in args:
            args['output'] = 'json'
        args['method'] = verb.upper()

        # we don't want unicode in the parameters
        for k,v in args.iteritems():
            try:
                args[k] = v.encode('utf-8')
            except __HOLE__:
                pass

        oa_req = OAuthRequest.from_consumer_and_token(self.consumer,
                                                      http_url=url,
                                                      parameters=args,
                                                      token=token)
        oa_req.sign_request(self.signature_method,
                            self.consumer,
                            token)
        if filename is None:
            def do_request():
                req = self.http.urlopen('GET', oa_req.to_url())
                if not str(req.status).startswith('2'):
                    self.analyze_error(req)
                return req
        else:
            def do_request():
                try:
                    subprocess.check_call(["curl", oa_req.to_url(),
                                           "--location",
                                           "--compressed",
                                           "--output", filename])
                    sys.stderr.write('\nSaved to: %s\n' % filename)
                except OSError:
                    raise RuntimeError, "You need to have curl installed to use this command"
        try:
            req = do_request()
        except TooManyRequestsPerSecondError:
            time.sleep(1)
            req = do_request()
        if filename:
            return
        o = json.loads(req.data, object_hook=self.object_hook)
        return o
dataset/ETHPy150Open ryszard/python-netflix/netflix/__init__.py/Netflix.request