Exemplo n.º 1
0
import kvmatch
import unittest

import datetime
import re
import os

# logging
import kvlogger
config = kvlogger.get_config('t_kvmatch.log')
kvlogger.dictConfig(config)
logger = kvlogger.getLogger(__name__)

rowdict = {
    'Company': 'Test',
    'Wine': 'Yummy',
    'Price': 10.00,
    'ProcessDate': datetime.datetime(2020, 1, 1, 0, 0)
}

record = ['Col1', 'Col2', 'Col3']
nonrecord = ['bad1', 'bad2', 'bad3']
xlat_dict = {'Col1': 'Ken1', 'Col2': 'Ken2', 'Col3': 'Ken3'}
xlat_dict_lower = {'Col1': 'Ken1', 'Col2': 'Ken2', 'col3': 'Ken3'}
kenlist = ['Ken1', 'Ken2', 'Ken3']
badoptiondict = {
    'no_case': 'nocase',
    'max_row': 'maxrows',
    'max_rows': 'maxrows',
    'uniquecolumn': 'unique_column',
    'uniquecolumns': 'unique_column',
Exemplo n.º 2
0
'''

import kvutil
import kvgmailsend

import time
import re
import datetime
import sys
from socket import gethostname


# logging - 
import kvlogger
config=kvlogger.get_config(kvutil.filename_create(__file__, filename_ext='log'))
kvlogger.dictConfig(config)
logger=kvlogger.getLogger(__name__)

# added logging feature to capture and log unhandled exceptions
def handle_exception(exc_type, exc_value, exc_traceback):
    if issubclass(exc_type, KeyboardInterrupt):
        sys.__excepthook__(exc_type, exc_value, exc_traceback)
        return

    logger.error("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback))

sys.excepthook = handle_exception


Exemplo n.º 3
0
            'formatter': 'default',
            'class': 'logging.StreamHandler',
            'stream': 'ext://sys.stdout'
        },
        'file': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'formatter': 'default',
            'filename': log_path,
            'maxBytes': 1024,
            'backupCount': 3
        }
    },
    'loggers': {
        '': {
            'handlers': ['console', 'file'],
            'level': 'DEBUG',
        },
    },
}

'''

config = kvlogger.get_config('t_kvlogger.log')
print('config:')
pprint.pprint(config)
logging.config.dictConfig(config)
# logger=kvlogger.get_logger(__name__, 't_kvutil.log')
logger.debug('send out a message')
logger.info('send out an info message')
Exemplo n.º 4
0
import kvutil
import kvargs

# may comment out in the future
import pprint

pp = pprint.PrettyPrinter(indent=4)

# logging
import sys
import kvlogger

# pick the log file structure from list below
# single file that is rotated
config = kvlogger.get_config(kvutil.filename_create(__file__, filename_ext='log', path_blank=True),
                             loggerlevel='NOTSET')  # single file
# one file per day of month
# config=kvlogger.get_config(kvutil.filename_log_day_of_month(__file__, ext_override='log'), 'logging.FileHandler') # one file per day of month
kvlogger.dictConfig(config)
logger = kvlogger.getLogger(__name__)


# added logging feature to capture and log unhandled exceptions
def handle_exception(exc_type, exc_value, exc_traceback):
    if issubclass(exc_type, KeyboardInterrupt):
        # if this is a keyboard interrupt - we dont' want to handle it here
        # reset and return
        sys.__excepthook__(exc_type, exc_value, exc_traceback)
        return

    # other wise catch/log this error
Exemplo n.º 5
0
import kvxls
import kvutil
import unittest
import datetime

import os

# logging
import kvlogger
config = kvlogger.get_config('t_kvxls.log', loggerlevel='DEBUG')
kvlogger.dictConfig(config)
logger = kvlogger.getLogger(__name__)

# set up filenames
filenamexls = kvutil.filename_unique({
    'base_filename': 't_kvxlstest',
    'file_ext': '.xls',
    'uniqtype': 'datecnt',
    'overwrite': True,
    'forceuniq': True
})
filenamexlsx = kvutil.filename_unique({
    'base_filename': 't_kvxlstest',
    'file_ext': '.xlsx',
    'uniqtype': 'datecnt',
    'overwrite': True,
    'forceuniq': True
})

filenamexls2 = kvutil.filename_unique({
    'base_filename': 't_kvxlstest2',
Exemplo n.º 6
0
import kvutil

# this test program is used to validate the command line parsing and reporting
#
# test1:  python t_kvutil2.py - it should terminate with error message
# test2:  python t_kvutil2.py workingdir=. alldir=1 - should run display but not terminate
# test2:  python t_kvutil2.py help=1 - should run display long list and terminate
#
#

# logging -
import sys
import kvlogger
config = kvlogger.get_config(
    kvutil.filename_create(__file__, filename_ext='log', path_blank=True))
kvlogger.dictConfig(config)
logger = kvlogger.getLogger(__name__)


# added logging feature to capture and log unhandled exceptions
def handle_exception(exc_type, exc_value, exc_traceback):
    if issubclass(exc_type, KeyboardInterrupt):
        sys.__excepthook__(exc_type, exc_value, exc_traceback)
        return

    logger.error("Uncaught exception",
                 exc_info=(exc_type, exc_value, exc_traceback))


sys.excepthook = handle_exception