Exemple #1
0
def configure_logger_web():
    'Configure log file and indicate succes or failure'
    print('Configuring log file')
    config_pytomo.LOG = logging.getLogger('pytomo_webpage')
    timestamp = time.strftime("%Y-%m-%d.%H_%M_%S")
    if config_pytomo.LOG_FILE == '-':
        handler = logging.StreamHandler(sys.stdout)
        print('Logs are on standard output')
        log_file = True
    else:
        try:
            log_file = check_out_files(config_pytomo.LOG_FILE,
                                       config_pytomo.LOG_DIR, timestamp)
        except IOError:
            print('Problem opening file with timestamp: %s' % timestamp)
            return None
        print('Graphical web interface logs are there: %s' % log_file)
        # for lib_youtube_download
        handler = logging.FileHandler(filename=log_file)
    log_formatter = logging.Formatter(
        '%(asctime)s - %(filename)s:%(lineno)d - '
        '%(levelname)s - %(message)s')
    handler.setFormatter(log_formatter)
    config_pytomo.LOG.addHandler(handler)
    config_pytomo.LOG.setLevel(config_pytomo.LOG_LEVEL)
    config_pytomo.LOG.critical(
        'Log level set to %s',
        config_pytomo.LEVEL_TO_NAME[config_pytomo.LOG_LEVEL])
    # to not have console output
    config_pytomo.LOG.propagate = False
    # log all config file values except built in values
    for value in filter(lambda x: not x.startswith('__'),
                        config_pytomo.__dict__):
        config_pytomo.LOG.critical('%s: %s' %
                                   (value, getattr(config_pytomo, value)))
Exemple #2
0
def rrd_filename(timestamp):
    ''' Return the file name of the rrd (try to create it if it does not
    exist). Will have the pattern:
                <RRD_DIR>/<hostname>.<timestamp>.<RRD_FILE>
    '''
    return check_out_files(config_pytomo.RRD_FILE, config_pytomo.RRD_DIR,
                           str(timestamp))
Exemple #3
0
def configure_logger_web():
    'Configure log file and indicate succes or failure'
    print('Configuring log file')
    config_pytomo.LOG = logging.getLogger('pytomo_webpage')
    timestamp = time.strftime("%Y-%m-%d.%H_%M_%S")
    if config_pytomo.LOG_FILE == '-':
        handler = logging.StreamHandler(sys.stdout)
        print('Logs are on standard output')
        log_file = True
    else:
        try:
            log_file = check_out_files(config_pytomo.LOG_FILE,
                                       config_pytomo.LOG_DIR, timestamp)
        except IOError:
            print('Problem opening file with timestamp: %s' % timestamp)
            return None
        print('Graphical web interface logs are there: %s' % log_file)
        # for lib_youtube_download
        handler = logging.FileHandler(filename=log_file)
    log_formatter = logging.Formatter('%(asctime)s - %(filename)s:%(lineno)d - '
                                      '%(levelname)s - %(message)s')
    handler.setFormatter(log_formatter)
    config_pytomo.LOG.addHandler(handler)
    config_pytomo.LOG.setLevel(config_pytomo.LOG_LEVEL)
    config_pytomo.LOG.critical('Log level set to %s',
                           config_pytomo.LEVEL_TO_NAME[config_pytomo.LOG_LEVEL])
    # to not have console output
    config_pytomo.LOG.propagate = False
    # log all config file values except built in values
    for value in filter(lambda x: not x.startswith('__'),
                        config_pytomo.__dict__):
        config_pytomo.LOG.critical('%s: %s'
                                   % (value, getattr(config_pytomo, value)))
Exemple #4
0
def index_filename(param, timestamp):
    ''' Return the file name of the index (try to create it if it does not
    exist). Will have the pattern:
                <TEMPLATES_DIR>/<hostname>.<timestamp>.<param_TEMPLATE_FILE>
    '''
    return check_out_files(NAME_CONNECTOR.join((param,
                                    config_pytomo.TEMPLATE_FILE)),
                                    config_pytomo.TEMPLATES_DIR, str(timestamp))
Exemple #5
0
def plot_filename(param, timestamp):
    ''' Return the file name of the plot (try to create it if it does not
    exist).  Will have the pattern:
                <RRD_PLOT_DIR>/<hostname>.<timestamp>.<param_IMAGE_FILE>
    '''
    return check_out_files(NAME_CONNECTOR.join((param,
                                    config_pytomo.IMAGE_FILE)),
                                    config_pytomo.RRD_PLOT_DIR, str(timestamp))