I'm new to Python and am trying my first applications. Why am I getting the Attribute message:
Traceback (most recent call last): File "C:\Users\myname\documents\visual studio 2010\Projects\PythonApplication 1\PythonApplication1\RunSikuliOnVM.py", line 97, in logging.config.dictConfig(LOG_DICT_CONFIG_OnVM) AttributeError: 'module' object has no attribute 'config' Press any key to continue . . .
Here is a portion of my code so far:
import os
import sys
import subprocess
import fnmatch
import datetime
import logging
import logging.handlers
import logging.config
"""===Global Variables==="""
LOGFILE = r"V:/RunTests.log"
LOGDETAILS= r"V:/SikuliScriptDetails.log"
FAILEDTESTS = r"V:/FailedTests.txt"
"""Logging configuration"""
# Dictionary configuration for logging within RunSikuliOnVM.py
LOG_DICT_CONFIG_OnVM = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)-8s %(asctime)s %(module)s %(process)d %(thread)d %(message)s',
'datefmt': '%a, %d %b %Y %H:%M:%S'
},
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s',
'datefmt': '%a, %d %b %Y %H:%M:%S'
},
'simple': {
'format': '%(asctime)s %(levelname)-8s %(message)s',
'datefmt': '%a, %d %b %Y %H:%M:%S'
}
},
'handlers': {
'console': {
'level':'DEBUG',
'class':'logging.StreamHandler',
'formatter': 'simple'
},
'RunTests_Handler': {
'class': 'logging.handlers.TimedRotatingFileHandler',
'level': 'DEBUG',
'formatter': 'simple',
'filename': LOGFILE,
'when':'D',
'interval': 7,
'backupCount':1,
'encoding': None,
'delay': False,
'utc': False,
},
'SikuliScriptDetails_Handler': {
'class': 'logging.handlers.TimedRotatingFileHandler',
'level': 'DEBUG',
'formatter': 'verbose',
'filename':LOGDETAILS,
'when':'D',
'interval': 7,
'backupCount':2,
'encoding': None,
'delay': False,
'utc': False,
},
'FailedTests_Handler': {
'class': 'logging.handlers.TimedRotatingFileHandler',
'level': 'DEBUG',
'formatter': 'standard',
'filename':FAILEDTESTS,
'when':'D',
'interval': 7,
'backupCount':2,
'encoding': None,
'delay': False,
'utc': False,
}
},
'loggers': {
'RunTests_Logger': {
'handlers': ['RunTests_Handler'],
'level': 'DEBUG',
'propagate': False
},
'SikuliScriptDetails_Logger': {
'handlers': ['SikuliScriptDetails_Handler'],
'level': 'DEBUG',
'propagate': False
},
'FailedTests_Logger': {
'handlers': ['FailedTests_Handler'],
'level': 'DEBUG',
'propagate': False
}
}
}
logging.config.dictConfig(LOG_DICT_CONFIG_OnVM)
logfilelogger = logging.getLogger('RunTests_Logger')
logdetailslogger = logging.getLogger('SikuliScriptDetails_Logger')
failedtestslogger = logging.getLogger('FailedTests_Logger')
PS: Some of the indentation is off...
import logging.config
is not included in the file. Is this included in the code that you are running?import logging import logging.handlers import logging.config
import logging
? I can run it without and i'm not sure that the top level module is being called.import logging
in it. Do you think I should delete the one in the child process?