Ejemplo n.º 1
0
 def write_header(self):
     pretty_date = date.pretty_date()
     header = "# OONI Probe Report for Test %s\n" % self.testname
     header += "# %s\n\n" % pretty_date
     self._write_to_report(header)
     # XXX replace this with something proper
     address = net.getClientAddress()
     test_details = {'start_time': str(date.now()),
                     'asn': address['asn'],
                     'test_name': self.testname,
                     'addr': address['ip']}
     self(test_details)
Ejemplo n.º 2
0
    def startTest(self, args):
        """
        This method is invoked by the worker to start the test with one line of
        the asset file.

        @param args: the asset(s) lines that we are working on.
        """

        log.debug("OONITest.startTest")

        self.start_time = date.now()
        log.msg("OONITest: Starting test %s" % self.__class__)
        return self._do_experiment(args)
Ejemplo n.º 3
0
 def write_header(self):
     pretty_date = date.pretty_date()
     header = "# OONI Probe Report for Test %s\n" % self.testname
     header += "# %s\n\n" % pretty_date
     self._write_to_report(header)
     # XXX replace this with something proper
     address = net.getClientAddress()
     test_details = {
         "start_time": str(date.now()),
         "asn": address["asn"],
         "test_name": self.testname,
         "addr": address["ip"],
     }
     self(test_details)
Ejemplo n.º 4
0
 def finished(self, return_value):
     """
     The Test has finished running, we must now calculate the test runtime
     and add all time data to the report.
     """
     #self.ooninet.report(result)
     self.end_time = date.now()
     result = self.result
     result['start_time'] = str(self.start_time)
     result['end_time'] = str(self.end_time)
     result['run_time'] = str(self.end_time - self.start_time)
     result['return_value'] = return_value
     log.msg("FINISHED %s" % result)
     self.report(result)
     return result
Ejemplo n.º 5
0
    def startTest(self, args):
        """
        This method is invoked by the worker to start the test with one line of
        the asset file.

        @param args: the asset(s) lines that we are working on.
        """
        self.start_time = date.now()

        if self.shortName:
            log.msg("Starting test %s" % self.shortName)
        else:
            log.msg("Starting test %s" % self.__class__)

        return self._do_experiment(args)
Ejemplo n.º 6
0
    def disabled_startTest(self, args):
        """
        Local override of :meth:`OONITest.startTest` to bypass calling
        self.control.

        :param args:
            The current line of :class:`Asset`, not used but kept for
            compatibility reasons.
        :return:
            A fired deferred which callbacks :meth:`experiment` and
            :meth:`OONITest.finished`.
        """
        self.start_time = date.now()
        self.d = self.experiment(args)
        self.d.addErrback(log.err)
        self.d.addCallbacks(self.finished, log.err)
        return self.d
Ejemplo n.º 7
0
    def disabled_startTest(self, args):
        """
        Local override of :meth:`OONITest.startTest` to bypass calling
        self.control.

        :param args:
            The current line of :class:`Asset`, not used but kept for
            compatibility reasons.
        :return:
            A fired deferred which callbacks :meth:`experiment` and
            :meth:`OONITest.finished`.
        """
        self.start_time = date.now()
        self.d = self.experiment(args)
        self.d.addErrback(log.err)
        self.d.addCallbacks(self.finished, log.err)
        return self.d
Ejemplo n.º 8
0
    def writeHeader(self):
        self.firstrun = False
        (klass, options) = self.options
        self._writeln("###########################################")
        self._writeln("# OONI Probe Report for %s test" % klass.name)
        self._writeln("# %s" % date.pretty_date())
        self._writeln("###########################################")

        client_geodata = {}
        log.msg("Running geo IP lookup via check.torproject.org")

        client_ip = yield geodata.myIP()
        try:
            import txtorcon
            client_location = txtorcon.util.NetLocation(client_ip)
        except:
            log.err("txtorcon is not installed. Geolocation lookup is not"\
                    "supported")

        client_geodata['ip'] = client_ip
        client_geodata['asn'] = client_location.asn
        client_geodata['city'] = client_location.city
        client_geodata['countrycode'] = client_location.countrycode

        test_details = {'startTime': repr(date.now()),
                        'probeASN': client_geodata['asn'],
                        'probeCC': client_geodata['countrycode'],
                        'probeIP': client_geodata['ip'],
                        'probeLocation': {'city': client_geodata['city'],
                                          'countrycode':
                                          client_geodata['countrycode']},
                        'testName': klass.name,
                        'testVersion': klass.version,
                        }
        self.writeYamlLine(test_details)
        self._writeln('')