Ejemplo n.º 1
0
def set_all_loggers():
    try:
        # Register Fores-cron callings (calling, validation, errors and execution):
        cron_logger = _Utilities.setup_logger('cron')  # Default
        # Temporal log table of all the process executed:
        cron_processes_logger = _Utilities.setup_logger(
            'cron_processes',
            file_name=GENERAL_LOGGING_CONFIG['processes_file_name'],
            format=GENERAL_LOGGING_CONFIG['processes_file_format'])
        # Process logs (every process has its logs). Also every process has subprocesses (threads) and each one of this subprocesses has its logs (this logs are created on each subprocess respectively):
        sl1_logger = _Utilities.setup_logger(
            SL1_LOGGING_CONFIG['process_file_name'],
            path=SL1_LOGGING_CONFIG['process_path'],
            file_name=SL1_LOGGING_CONFIG['process_file_name'],
            file_extension=SL1_LOGGING_CONFIG['file_extension'],
            format=SL1_LOGGING_CONFIG['format'],
            level=SL1_LOGGING_CONFIG['level'])
        equalization_logger = _Utilities.setup_logger(
            EQUALIZATION_LOGGING_CONFIG['process_file_name'],
            path=EQUALIZATION_LOGGING_CONFIG['process_path'],
            file_name=EQUALIZATION_LOGGING_CONFIG['process_file_name'],
            file_extension=EQUALIZATION_LOGGING_CONFIG['file_extension'],
            format=EQUALIZATION_LOGGING_CONFIG['format'],
            level=EQUALIZATION_LOGGING_CONFIG['level'])
        initialization_logger = _Utilities.setup_logger(
            INITIALIZATION_LOGGING_CONFIG['process_file_name'],
            path=INITIALIZATION_LOGGING_CONFIG['process_path'],
            file_name=INITIALIZATION_LOGGING_CONFIG['process_file_name'],
            file_extension=INITIALIZATION_LOGGING_CONFIG['file_extension'],
            format=INITIALIZATION_LOGGING_CONFIG['format'],
            level=INITIALIZATION_LOGGING_CONFIG['level'])
    except Exception as e:
        print 'Error settion up all logs'
        print e
        raise e
Ejemplo n.º 2
0
def set_all_loggers():
	try:
		# Register Fores-cron callings (calling, validation, errors and execution):
		cron_logger = _Utilities.setup_logger('cron')# Default 
		# Temporal log table of all the process executed:
		cron_processes_logger = _Utilities.setup_logger('cron_processes',file_name=GENERAL_LOGGING_CONFIG['processes_file_name'],format=GENERAL_LOGGING_CONFIG['processes_file_format'])
		# Process logs (every process has its logs). Also every process has subprocesses (threads) and each one of this subprocesses has its logs (this logs are created on each subprocess respectively):
		sl1_logger = _Utilities.setup_logger(SL1_LOGGING_CONFIG['process_file_name'],path=SL1_LOGGING_CONFIG['process_path'],file_name=SL1_LOGGING_CONFIG['process_file_name'] ,file_extension=SL1_LOGGING_CONFIG['file_extension'],format=SL1_LOGGING_CONFIG['format'],level=SL1_LOGGING_CONFIG['level'])
		equalization_logger = _Utilities.setup_logger(EQUALIZATION_LOGGING_CONFIG['process_file_name'],path=EQUALIZATION_LOGGING_CONFIG['process_path'],file_name=EQUALIZATION_LOGGING_CONFIG['process_file_name'] ,file_extension=EQUALIZATION_LOGGING_CONFIG['file_extension'],format=EQUALIZATION_LOGGING_CONFIG['format'],level=EQUALIZATION_LOGGING_CONFIG['level'])
		initialization_logger = _Utilities.setup_logger(INITIALIZATION_LOGGING_CONFIG['process_file_name'],path=INITIALIZATION_LOGGING_CONFIG['process_path'],file_name=INITIALIZATION_LOGGING_CONFIG['process_file_name'] ,file_extension=INITIALIZATION_LOGGING_CONFIG['file_extension'],format=INITIALIZATION_LOGGING_CONFIG['format'],level=INITIALIZATION_LOGGING_CONFIG['level'])
	except Exception as e:
		print 'Error settion up all logs'
		print e
		raise e
Ejemplo n.º 3
0
def main(argv):
	hey_execution = get_command_line_params(argv)
	cron_logger = _Utilities.setup_logger('cron')
	current_hour = Datetime.now().hour
	chat_id = None
	if hey_execution:
		hey = _Utilities.hey(logger=cron_logger,server_index=SERVER_INDEX)
		if hey is False:
			return
		chat_id = hey
	cron_logger.info('------------------------------------------------------------------------')
	cron_logger.info(LOG_INDENT + 'Performing Forest Supervision')
	processes = get_processes_in_this_mode()
	for process in processes:
		if process == _Constants.INITIALIZATION:
			taxpayers = _Utilities.get_taxpayers_for_a_specific_process(process)
			taxpayers_in_init = len(taxpayers)
			if taxpayers_in_init > 0:
				last_log_date = get_last_log_time_of_a_process(process)
			else:
				last_log_date = True
		else:
			last_log_date = get_last_log_time_of_a_process(process)		
		everything_ok = is_everything_ok(last_log_date)	
		cron_logger.info(LOG_INDENT + process.upper())
		current_date = Datetime.now()
		year = current_date.year
		month = current_date.month
		day = current_date.day
		begin_of_the_day = Datetime(year,month,day)		
		if last_log_date > begin_of_the_day:
			last_log_date_hour = str(last_log_date)[11:11+8]
		else:
			last_log_date_hour = str(last_log_date)
		if everything_ok:
			message = HAPPY_FACE + 'Todo chido con ' + process + ' en Forest_' + str(SERVER_INDEX) + '. Tengo el ultimo registro a las ' + str(last_log_date_hour)
			cron_logger.info(2*LOG_INDENT + 'Everyting ok. Last log was at: ' + str(last_log_date_hour))
			if chat_id is not None:
				_Utilities.send_message_to_forest_telegram_contacts(message,chat_ids=[chat_id])
			else:
				_Utilities.send_message_to_forest_telegram_contacts(message)
		else:
			message = 'Tengo un ' + 3*telegram.Emoji.PILE_OF_POO + 1*CHANGITO + ' en Forest_' + str(SERVER_INDEX) + '. El ultimo registro a las ' + str(last_log_date_hour)
			cron_logger.info(2*LOG_INDENT + 'There is a PROBLEM. Last log was at: ' + str(last_log_date_hour))
			if chat_id is not None:
				_Utilities.send_message_to_forest_telegram_contacts(message,chat_ids=[chat_id])
			else:
				_Utilities.send_message_to_forest_telegram_contacts(message)
Ejemplo n.º 4
0
def main(argv):
    hey_execution = get_command_line_params(argv)
    cron_logger = _Utilities.setup_logger('cron')
    current_hour = Datetime.now().hour
    chat_id = None
    if hey_execution:
        hey = _Utilities.hey(logger=cron_logger, server_index=SERVER_INDEX)
        if hey is False:
            return
        chat_id = hey
    cron_logger.info(
        '------------------------------------------------------------------------'
    )
    cron_logger.info(LOG_INDENT + 'Performing Forest Supervision')
    processes = get_processes_in_this_mode()
    for process in processes:
        if process == _Constants.INITIALIZATION:
            taxpayers = _Utilities.get_taxpayers_for_a_specific_process(
                process)
            taxpayers_in_init = len(taxpayers)
            if taxpayers_in_init > 0:
                last_log_date = get_last_log_time_of_a_process(process)
            else:
                last_log_date = True
        else:
            last_log_date = get_last_log_time_of_a_process(process)
        everything_ok = is_everything_ok(last_log_date)
        cron_logger.info(LOG_INDENT + process.upper())
        current_date = Datetime.now()
        year = current_date.year
        month = current_date.month
        day = current_date.day
        begin_of_the_day = Datetime(year, month, day)
        if last_log_date > begin_of_the_day:
            last_log_date_hour = str(last_log_date)[11:11 + 8]
        else:
            last_log_date_hour = str(last_log_date)
        if everything_ok:
            message = HAPPY_FACE + 'Todo chido con ' + process + ' en Forest_' + str(
                SERVER_INDEX) + '. Tengo el ultimo registro a las ' + str(
                    last_log_date_hour)
            cron_logger.info(2 * LOG_INDENT +
                             'Everyting ok. Last log was at: ' +
                             str(last_log_date_hour))
            if chat_id is not None:
                _Utilities.send_message_to_forest_telegram_contacts(
                    message, chat_ids=[chat_id])
            else:
                _Utilities.send_message_to_forest_telegram_contacts(message)
        else:
            message = 'Tengo un ' + 3 * telegram.Emoji.PILE_OF_POO + 1 * CHANGITO + ' en Forest_' + str(
                SERVER_INDEX) + '. El ultimo registro a las ' + str(
                    last_log_date_hour)
            cron_logger.info(2 * LOG_INDENT +
                             'There is a PROBLEM. Last log was at: ' +
                             str(last_log_date_hour))
            if chat_id is not None:
                _Utilities.send_message_to_forest_telegram_contacts(
                    message, chat_ids=[chat_id])
            else:
                _Utilities.send_message_to_forest_telegram_contacts(message)