Example #1
0
    def do_collect(self, stream, request):
        self._speedtest_complete(request)

        s = request.body.read()
        m = marshal.unmarshal_object(s, "text/xml", compat.SpeedtestCollect)

        if privacy.collect_allowed(m):
            table_speedtest.insertxxx(DATABASE.connection(), m)

        response = Message()
        response.compose(code="200", reason="Ok")
        stream.send_response(request, response)
Example #2
0
    def connection_ready(self, stream):
        m1 = compat.SpeedtestCollect()
        m1.client = self.conf.get("uuid", "")
        m1.timestamp = utils.timestamp()
        m1.internalAddress = stream.myname[0]
        m1.realAddress = self.conf.get("speedtest.client.public_address", "")
        m1.remoteAddress = stream.peername[0]

        m1.latency = self.conf.get("speedtest.client.latency", 0.0)
        m1.downloadSpeed = self.conf.get("speedtest.client.download", 0.0)
        m1.uploadSpeed = self.conf.get("speedtest.client.upload", 0.0)

        m1.privacy_informed = self.conf.get("privacy.informed", 0)
        m1.privacy_can_collect = self.conf.get("privacy.can_collect", 0)
        m1.privacy_can_share = self.conf.get("privacy.can_share", 0)

        m1.neubot_version = LibVersion.to_numeric("0.4.2")
        m1.platform = sys.platform

        if self.measurer:
            m1.connectTime = self.measurer.measure_rtt()[0]

#           import pprint
#           if hasattr(self.measurer, "recv_hist"):
#               download = self.measurer.recv_hist.get("download", [])
#               pprint.pprint(download)
#           if hasattr(self.measurer, "send_hist"):
#               upload = self.measurer.send_hist.get("upload", [])
#               pprint.pprint(upload)

        s = marshal.marshal_object(m1, "text/xml")
        stringio = StringIO.StringIO(s)

        if privacy.collect_allowed(m1):
            table_speedtest.insertxxx(DATABASE.connection(), m1)

        request = Message()
        request.compose(method="POST", pathquery="/speedtest/collect",
                        body=stringio, mimetype="application/xml",
                        host=self.host_header)
        request["authorization"] = self.conf.get(
          "speedtest.client.authorization", "")

        stream.send_request(request)