Example #1
0
 def test_basic_log(self, mock_get_now):
     mock_get_now = mock.Mock.return_value = datetime.datetime(1960, 1, 1, 8, 10, 10)
     wlogger.setup_loggers(os.path.join(self.test_data_dir, 'Temp'), test_mode_on=True, name='test_basic_log')
     wlogger.log_info('First Info Message',  name='test_basic_log')
     wlogger.log_info('Second Info Message',  name='test_basic_log')
     wlogger.log_info('Third Info Message',  name='test_basic_log')
     wlogger.tear_down_loggers(name='test_basic_log')
     self.log_test_compare()
Example #2
0
    def test_dir_does_not_exist(self, mock_get_now):
        mock_get_now = mock.Mock.return_value = datetime.datetime(1960, 1, 1, 8, 10, 10)

        # Extend filepath required to check that sub directories are created.
        file_path = os.path.join(self.test_data_dir, 'Temp', 'SubDirectory', 'SubSubDirectory')
        wlogger.setup_loggers(file_path,
                              test_mode_on=True,
                              name='test_dir_does_not_exist')

        wlogger.log_info('First Info Message', name='test_dir_does_not_exist')
        wlogger.log_info('Second Info Message', name='test_dir_does_not_exist')
        wlogger.log_info('Third Info Message', name='test_dir_does_not_exist')
        wlogger.tear_down_loggers(name='test_dir_does_not_exist')

        self.log_test_compare()
Example #3
0
    def test_file_rotation(self, mock_get_now):
        mock_get_now = mock.Mock.return_value = datetime.datetime(1960, 1, 1, 8, 10, 10)
        wlogger.setup_loggers(os.path.join(self.test_data_dir, 'Temp'),
                              debug_on=True,
                              test_mode_on=True,
                              name='test_file_rotation',
                              maxBytes=1000)

        for i in range(0, 1000):
            wlogger.log_info('Info Message ' + str(i),        name='test_file_rotation')
            wlogger.log_debug('Debug Message ' + str(i),      name='test_file_rotation')
            wlogger.log_error('Error Message ' + str(i),      name='test_file_rotation')

        wlogger.tear_down_loggers(name='test_file_rotation')
        self.log_test_compare()
Example #4
0
    def test_message_levels_debug_off(self, mock_get_now):
        mock_get_now = mock.Mock.return_value = datetime.datetime(1960, 1, 1, 8, 10, 10)
        wlogger.setup_loggers(os.path.join(self.test_data_dir, 'Temp'),
                              debug_on=False,
                              test_mode_on=True,
                              name='test_message_levels_debug_off')

        wlogger.log_info('Info Message',        name='test_message_levels_debug_off')
        wlogger.log_debug('Debug Message',      name='test_message_levels_debug_off')
        wlogger.log_error('Error Message',      name='test_message_levels_debug_off')
        wlogger.log_info('Info Message',        name='test_message_levels_debug_off')
        wlogger.log_debug('Debug Message',      name='test_message_levels_debug_off')
        wlogger.log_warning('Warning Message',  name='test_message_levels_debug_off')
        wlogger.tear_down_loggers(name='test_message_levels_debug_off')

        self.log_test_compare()
Example #5
0
    def test_dir_and_log_already_exist(self, mock_get_now):
        mock_get_now = mock.Mock.return_value = datetime.datetime(1960, 1, 1, 8, 10, 10)

        # Set up a logger and write out some messages.
        wlogger.setup_loggers(os.path.join(self.test_data_dir, 'Temp'),
                              test_mode_on=True,
                              name='test_dir_and_log_already_exist')

        wlogger.log_info('First Info Message - Logger 1', name='test_dir_and_log_already_exist')
        wlogger.log_info('Second Info Message - Logger 1', name='test_dir_and_log_already_exist')
        wlogger.log_info('Third Info Message - Logger 1', name='test_dir_and_log_already_exist')
        wlogger.tear_down_loggers(name='test_dir_and_log_already_exist')

        wlogger.setup_loggers(os.path.join(self.test_data_dir, 'Temp'),
                              test_mode_on=True,
                              name='test_dir_and_log_already_exist_2')
        wlogger.log_info('First Info Message - Logger 2', name='test_dir_and_log_already_exist_2')
        wlogger.log_info('Second Info Message - Logger 2', name='test_dir_and_log_already_exist_2')
        wlogger.log_info('Third Info Message - Logger 2', name='test_dir_and_log_already_exist_2')
        wlogger.tear_down_loggers(name='test_dir_and_log_already_exist_2')

        self.log_test_compare()
# Set the logger up.
wlogger.setup_loggers(config.log_directory)
wlogger.log_info("Run Block Light Pattern")

NUM_LED = 12 * 144
print("Num LEDS")
print(NUM_LED)

keep_running = True
while keep_running:

    try:
        # Cycle of light pattern
        print('Run Block Light Patterns')
        MY_CYCLE = blocklightpatterns.ChangingBlockLightPattern(
            num_led=NUM_LED,
            pause_value=0.0,
            num_steps_per_cycle=120000,
            num_cycles=1)
        MY_CYCLE.start()

    except KeyboardInterrupt:  # Ctrl-C can halt the light program
        keep_running = False
        wlogger.tear_down_loggers()
        GPIO.cleanup()
        raise KeyboardInterrupt

GPIO.cleanup()
print('Finished the test')
exit()