示例#1
0
def showArchived(year, month):
	if month < 1 or month > 12:
		print '<br />Please enter a month between 1 and 12'
		return 0
	if month < 10:
		monthstr = '0' + str(month)
	else:
		monthstr = str(month)

	try:
		events = os.listdir(config.get('archive', 'date_dir') + '/' + str(year) + '/' + monthstr)
		for event in events:
			if event[0] != '.':
				archived = archive.getArchived(event)
				for field in archived:
					for value in archived[field]:
						print '<br />' + field + ': ' + value
				print '<hr />'
	except OSError:
		# Directory does not exist
		print '<br />There are no events archived for the given date'
		return 0
示例#2
0
def getconfigpriority():
    #LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE,
    #LOG_INFO, LOG_DEBUG.
    prioritymap = { 
#	"user":     syslog.LOG_USER,
	"emerg":	syslog.LOG_EMERG, 
	"emergency":	syslog.LOG_EMERG, 
	"alert":	syslog.LOG_ALERT, 
	"crit":         syslog.LOG_CRIT, 
	"critical":	syslog.LOG_CRIT, 
	"err":          syslog.LOG_ERR, 
	"error":	syslog.LOG_ERR, 
	"warn":         syslog.LOG_WARNING, 
	"warning":	syslog.LOG_WARNING, 
	"notice":	syslog.LOG_NOTICE, 
	"info":         syslog.LOG_INFO, 
	"debug":	syslog.LOG_DEBUG, 
        }
    try:
        priority = conf.get("logging", "priority")
    except:
        priority = "info"
    return prioritymap.get(priority, syslog.LOG_INFO)
示例#3
0
def getconfigfacility():
    facilitymap = { 
	"user":     syslog.LOG_USER,
	"mail":     syslog.LOG_MAIL,
	"daemon":   syslog.LOG_DAEMON,
	"auth":     syslog.LOG_AUTH,
	"lpr":      syslog.LOG_LPR,
	"news":     syslog.LOG_NEWS,
	"uucp":     syslog.LOG_UUCP,
	"cron":     syslog.LOG_CRON,
	"local0":   syslog.LOG_LOCAL0,
	"local1":   syslog.LOG_LOCAL1,
	"local2":   syslog.LOG_LOCAL2,
	"local3":   syslog.LOG_LOCAL3,
	"local4":   syslog.LOG_LOCAL4,
	"local5":   syslog.LOG_LOCAL5,
	"local6":   syslog.LOG_LOCAL6,
	"local7":   syslog.LOG_LOCAL7,
        }
    try:
        facility = conf.get("logging", "facility")
    except:
        facility = "user"
    return facilitymap.get(facility, syslog.LOG_USER)