예제 #1
0
파일: qtrender_lua.py 프로젝트: dwdm/splash
    @command()
    def reraise(self):
        if self.errors:
            ex = self.errors[-1]
            if isinstance(ex, ScriptError):
                info = ex.args[0]
                info['splash_method'] = None
                info['timer_method'] = 'reraise'
            raise ex

    def store_error(self, error):
        self.errors.append(error)


requires_request = requires_attr(
    "request",
    lambda self, meth, attr_name: self._on_request_required(meth, attr_name)
)
requires_response = requires_attr(
    "response",
    lambda self, meth, attr_name: self._on_response_required(meth, attr_name)
)


class _ExposedRequest(BaseExposedObject):
    """ QNetworkRequest wrapper for Lua """
    _attribute_whitelist = ['info']

    def __init__(self, lua, request, operation, outgoing_data):
        super(_ExposedRequest, self).__init__(lua)
        self.request = request
        self.info = self.lua.python2lua(
예제 #2
0
        self.timer.stop()

    @command()
    def is_pending(self):
        return self.timer.isActive()

    @command()
    def reraise(self):
        if self.errors:
            raise self.errors[-1]

    def store_error(self, error):
        self.errors.append(error)


requires_request = requires_attr("request",
                                 "request is used outside a callback")
requires_response = requires_attr("response",
                                  "response is used outside a callback")


class _ExposedRequest(BaseExposedObject):
    """ QNetworkRequest wrapper for Lua """
    _attribute_whitelist = ['info']

    def __init__(self, lua, request, operation, outgoing_data):
        super(_ExposedRequest, self).__init__(lua)
        self.request = request
        self.info = self.lua.python2lua(
            request2har(request, operation, outgoing_data)
        )