Example #1
0
                                            (minutes, minutes))

    for location in locations_for_delete:
        try:
            remove(location[0])
        except:
            pass

    cn.execute_query(delete_old_records_query % minutes)
    cn.disconnect()


# ОСНОВНОЙ КОД
if __name__ == '__main__':

    logger = logger_module.logger()
    try:
        # парсим аргументы командной строки
        my_parser = create_parser()
        namespace = my_parser.parse_args()

        if namespace.version:
            show_version()
            exit(0)

        if namespace.remove:
            delete_worker(minutes=namespace.minutes)
            info = 'Сведения старее %s минут удалены' % namespace.minutes
            print(info)
            logger.info(info)
            exit(0)
Example #2
0
                    # и найдем нужный звуковой файл
                    play_text = element[1][3]
                    if not play_text:
                        play_text = default_text
                    play_texts.append(play_text)

        # обновляем сведения об обработанных ошибках
        last_error_strings = error_strings
        # настало время воспроизвести то, что мы нашли
        # создаем строку для воспроизведения с полными путями
        play_texts = ' '.join(set(play_texts))
        if play_texts:
            play_texts = prefix_text + ' ' + play_texts
            notify_command = play_command % play_texts
            os.system(notify_command)
            logger.info('Exec "%s"' % notify_command)
        sleep(sleep_time)


if __name__ == '__main__':
    logger = logger()
    try:
        main()
    # если при исполнении будут исключения - кратко выводим на терминал, остальное - в лог
    except Exception as e:
        logger.fatal('Fatal error! Exit', exc_info=True)
        print('Critical error: %s' % e)
        print('More information in log file')
        exit(1)