Beispiel #1
0
    def handle(self, *args, **kwargs):
        if len(args) != 2:
            raise CommandError(self.error)

        try:
            starttime = datetime.strptime(args[0], "%Y-%m-%dT%H:%M:%S")
            endtime = datetime.strptime(args[1], "%Y-%m-%dT%H:%M:%S")
        except ValueError:
            raise CommandError(self.error)

        files = load_correct_access_log_files(starttime, endtime)
        merged_lines = load_and_merge_files(files)
        parsed_file = parse_access_log(merged_lines)

        (unique_listeners, listeners_in_interval) = get_listeners_in_interval(parsed_file, starttime, endtime)
        self.stdout.write("Total time spent listening between %s and %s: %d" % (str(starttime), str(endtime), get_total_listening_time(listeners_in_interval),))
Beispiel #2
0
    def handle(self, *args, **kwargs):
        if len(args) != 2:
            raise CommandError(self.error)

        try:
            starttime = datetime.strptime(args[0], "%Y-%m-%dT%H:%M:%S")
            endtime = datetime.strptime(args[1], "%Y-%m-%dT%H:%M:%S")
        except ValueError:
            raise CommandError(self.error)

        files = load_correct_access_log_files(starttime, endtime)
        merged_lines = load_and_merge_files(files)
        parsed_file = parse_access_log(merged_lines)

        (unique_listeners, listeners_in_interval) = get_listeners_in_interval(parsed_file, starttime, endtime)
        avg_time = get_average_listening_time(listeners_in_interval)
        self.stdout.write("Average time per IP spent listening between %s and %s: %d minutes, %d seconds" % (str(starttime), str(endtime), floor(avg_time/60.0), avg_time % 60,))