示例#1
0
    def test_linux_input_invalid_path_slack(self):
        with self.assertRaises(IOError) as ex:
            capturedOutput = StringIO.StringIO()
            sys.stdout = capturedOutput
            reader.linux_input_slack("some non existent path/",
                                     self.starting_date, self.starting_date)
            capturedOutput.close()
            sys.stdout = sys.__stdout__

        self.assertEqual(str(ex.exception),
                         "Path some non existent path/2013/ doesn't exist")
示例#2
0
 def test_dataset(self):
     log_data = reader.linux_input_slack(self.log_data_dir, self.start_date,
                                         self.end_date)
     nicks, nick_same_list = nickTracker.nick_tracker(log_data)
     message_number_graph = network.message_number_graph(
         log_data, nicks, nick_same_list, False)
     expected_output = len(message_number_graph), int(
         message_number_graph.size('weight'))
     self.assertEqual(expected_output, self.expected_result)
示例#3
0
    def test_linux_input_slack(self):
        expected_captured_output = util.load_from_disk(
            self.current_directory + "/data/stdout_captured_linux_input_slack")

        capturedOutput = StringIO.StringIO()
        sys.stdout = capturedOutput
        log_data = reader.linux_input_slack(
            self.current_directory + "/data/slackware/", self.starting_date,
            self.ending_date)
        output = capturedOutput.getvalue()
        capturedOutput.close()
        sys.stdout = sys.__stdout__

        #See https://docs.python.org/2/library/re.html for more details.
        # string 'Working on: /any_valid_path/IRCLogParser/test/unit-test/test_lib/test_in_out/data/log/2013/01/04/#kubuntu-devel.txt\n' is replaced by
        # 'Working on: IRCLogParser/test/unit-test/test_lib/test_in_out/data/log/2013/01/04/#kubuntu-devel.txt\n'
        output = re.sub(r'(?P<begin>.+ )/.+/(?P<constant>IRCLogParser/.+\n)',
                        r'\g<begin>\g<constant>', output)
        self.assertEqual(log_data, self.log_data)
        self.assertEqual(expected_captured_output, output)
示例#4
0
    def test_linux_input_non_existent_file_slack(self):
        expected_captured_output = util.load_from_disk(
            self.current_directory +
            "/data/stdout_captured_linux_input_slack_non_existent_file")
        expected_log_data = util.load_from_disk(
            self.current_directory +
            "/data/log_data_for_test_linux_input_non_existent_file_slack")

        capturedOutput = StringIO.StringIO()
        sys.stdout = capturedOutput
        log_data = reader.linux_input_slack(
            self.current_directory + "/data/slackware_with_missing_files/",
            "2013-1-1", "2013-1-6")
        output = capturedOutput.getvalue()
        capturedOutput.close()
        sys.stdout = sys.__stdout__

        #See https://docs.python.org/2/library/re.html for more details.
        output = re.sub(r'(?P<begin>.+ )/.+/(?P<constant>IRCLogParser/.+\n)',
                        r'\g<begin>\g<constant>', output)
        self.assertEqual(expected_log_data, log_data)
        self.assertEqual(expected_captured_output, output)
示例#5
0
log_directory = config.LOG_DIRECTORY
channel_name = config.CHANNEL_NAME
starting_date = config.STARTING_DATE
ending_date = config.ENDING_DATE
output_directory = config.OUTPUT_DIRECTORY

exec_times_file = open(output_directory + "execution_times.txt", 'w')

degree_type = ["out_degree", "in_degree", "total_degree"]

print("begin at: ", datetime.datetime.now(), file=exec_times_file)
exec_times_file.flush()

# ============== INPUT==================
log_data = reader.linux_input_slack(log_directory, starting_date, ending_date)
nicks, nick_same_list = nickTracker.nick_tracker(log_data)
print("reading log files completed at: ",
      datetime.datetime.now(),
      file=exec_times_file)
exec_times_file.flush()

# ============== MESSAGE BINS HEATMAP =============
bin_matrix, total_messages = network.message_number_bins_csv(
    log_data, nicks, nick_same_list)
data = [[i for i in range(len(bin_matrix[0]))]]
data.append([sum(i) for i in zip(*bin_matrix)])
saver.save_csv(bin_matrix, output_directory,
               "MessageNumber_binsize_" + str(config.BIN_LENGTH_MINS))
vis.plot_data(data, output_directory, "bins")