|
terom@73
|
1 |
""" |
|
terom@73
|
2 |
Configureable defaults |
|
terom@73
|
3 |
""" |
|
terom@73
|
4 |
|
|
terom@73
|
5 |
import os.path, pytz |
|
terom@73
|
6 |
from log_parser import IrssiParser |
|
terom@73
|
7 |
from log_channel import LogChannel |
|
terom@82
|
8 |
from log_source import LogSourceDecoder, LogDirectory |
|
terom@86
|
9 |
from log_formatter import IrssiFormatter, DebugFormatter |
|
terom@73
|
10 |
from channels import ChannelList |
|
terom@73
|
11 |
import log_formatter |
|
terom@73
|
12 |
|
|
terom@128
|
13 |
# build relative paths to the dir containing this file |
|
terom@73
|
14 |
relpath = lambda path : os.path.join(os.path.dirname(__file__), path) |
|
terom@73
|
15 |
|
|
terom@79
|
16 |
### ### |
|
terom@79
|
17 |
### Configuration ### |
|
terom@79
|
18 |
### ### |
|
terom@79
|
19 |
|
|
terom@73
|
20 |
# timezone to use for logs |
|
terom@79
|
21 |
LOG_TIMEZONE = pytz.timezone('Europe/Helsinki') |
|
terom@73
|
22 |
|
|
terom@73
|
23 |
# timestamp format for logfiles |
|
terom@79
|
24 |
LOG_TIMESTAMP_FMT = '%H:%M:%S' |
|
terom@73
|
25 |
|
|
terom@82
|
26 |
# the decoder used for logfiles |
|
terom@82
|
27 |
LOG_DECODER = LogSourceDecoder(( |
|
terom@82
|
28 |
('utf-8', 'strict'), |
|
terom@82
|
29 |
('latin-1', 'replace'), |
|
terom@82
|
30 |
)) |
|
terom@73
|
31 |
|
|
terom@73
|
32 |
# log filename format |
|
terom@79
|
33 |
LOG_FILENAME_FMT = '%Y-%m-%d' |
|
terom@73
|
34 |
|
|
terom@73
|
35 |
# the log parser that we use |
|
terom@79
|
36 |
LOG_PARSER = IrssiParser(LOG_TIMEZONE, LOG_TIMESTAMP_FMT) |
|
terom@121
|
37 |
#LOG_PARSER_FULLTS = IrssiParser(LOG_TIMEZONE, '%Y%m%d%H%M%S') |
|
terom@73
|
38 |
|
|
terom@73
|
39 |
# the statically defined channel list |
|
terom@79
|
40 |
LOG_CHANNELS = ChannelList([ |
|
terom@73
|
41 |
LogChannel('tycoon', "OFTC", "#tycoon", |
|
terom@121
|
42 |
LogDirectory(relpath('/home/spbot/irclogs/tycoon'), LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT) |
|
terom@73
|
43 |
), |
|
terom@73
|
44 |
|
|
terom@73
|
45 |
LogChannel('openttd', "OFTC", "#openttd", |
|
terom@121
|
46 |
LogDirectory(relpath('/home/spbot/irclogs/openttd'), LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT) |
|
terom@73
|
47 |
), |
|
terom@81
|
48 |
|
|
terom@81
|
49 |
LogChannel('test', "TEST", "#test", |
|
terom@121
|
50 |
LogDirectory(relpath('/home/spbot/irclogs/test'), LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT) |
|
terom@81
|
51 |
) |
|
terom@73
|
52 |
]) |
|
terom@73
|
53 |
|
|
terom@131
|
54 |
# URL to the hgweb installation for this code |
|
terom@144
|
55 |
HGWEB_URL = "http://hg.qmsk.net/qmsk.irclogs" |
|
terom@119
|
56 |
|
|
terom@140
|
57 |
# path to the mercurial working copy |
|
terom@140
|
58 |
HG_WC_PATH = "." |
|
terom@119
|
59 |
|
|
terom@82
|
60 |
# how to handle decode() errors for logfile lines |
|
terom@82
|
61 |
LOG_SOURCE_DECODE_ERRORS = 'replace' |
|
terom@82
|
62 |
|
|
terom@73
|
63 |
# date format for URLs |
|
terom@79
|
64 |
URL_DATE_FMT = '%Y-%m-%d' |
|
terom@73
|
65 |
|
|
terom@73
|
66 |
# month name format |
|
terom@79
|
67 |
MONTH_FMT = '%B %Y' |
|
terom@73
|
68 |
|
|
terom@73
|
69 |
# timezone name format |
|
terom@79
|
70 |
TIMEZONE_FMT = '%Z %z' |
|
terom@79
|
71 |
|
|
terom@79
|
72 |
# TTF fonts to use for drawing images |
|
terom@79
|
73 |
FORMATTER_IMAGE_FONTS = { |
|
terom@124
|
74 |
# XXX: no unicode support |
|
terom@124
|
75 |
# 'default': (None, "Ugly default font" ), |
|
terom@79
|
76 |
'ttf-dejavu-mono': ("/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf", "DejaVu Sans Mono" ), |
|
terom@79
|
77 |
'ttf-liberation-mono': ("/usr/share/fonts/truetype/ttf-liberation/LiberationMono-Regular.ttf", "Liberation Mono Regular" ) |
|
terom@79
|
78 |
} |
|
terom@73
|
79 |
|
|
terom@73
|
80 |
# available formatters |
|
terom@79
|
81 |
LOG_FORMATTERS = { |
|
terom@79
|
82 |
'irssi': IrssiFormatter, |
|
terom@86
|
83 |
'debug': DebugFormatter, |
|
terom@79
|
84 |
} |
|
terom@73
|
85 |
|
|
terom@131
|
86 |
# Cookie settings |
|
terom@131
|
87 |
PREF_COOKIE_PATH = '/' |
|
terom@131
|
88 |
PREF_COOKIE_EXPIRE_SECONDS = 1 * 365 * 24 * 60 * 60 # one year |
|
terom@131
|
89 |
|
|
terom@73
|
90 |
# default preferences |
|
terom@79
|
91 |
PREF_TIME_FMT_DEFAULT = '%H:%M:%S' |
|
terom@79
|
92 |
PREF_DATE_FMT_DEFAULT = '%Y-%m-%d' |
|
terom@131
|
93 |
PREF_TIMEZONE_FALLBACK = pytz.utc |
|
terom@79
|
94 |
PREF_FORMATTER_DEFAULT = IrssiFormatter |
|
terom@79
|
95 |
PREF_COUNT_DEFAULT = 200 |
|
terom@79
|
96 |
PREF_COUNT_MAX = None |
|
terom@124
|
97 |
PREF_IMAGE_FONT_DEFAULT = 'ttf-dejavu-mono' |
|
terom@124
|
98 |
PREF_IMAGE_FONT_SIZE_DEFAULT = 12 |
|
terom@79
|
99 |
PREF_IMAGE_FONT_SIZE_MAX = 32 |
|
terom@73
|
100 |
|
|
terom@73
|
101 |
# search line count options |
|
terom@82
|
102 |
SEARCH_LINE_COUNT_OPTIONS = ( |
|
terom@73
|
103 |
(50, 50), |
|
terom@73
|
104 |
(100, 100), |
|
terom@73
|
105 |
(200, 200), |
|
terom@141
|
106 |
|
|
terom@141
|
107 |
# infinity, not supported |
|
terom@141
|
108 |
# (0, "∞"), |
|
terom@73
|
109 |
) |
|
terom@73
|
110 |
|
|
terom@82
|
111 |
# search index database path |
|
terom@121
|
112 |
SEARCH_INDEX_PATH = '/home/spbot/irclogs/search-index' |
|
terom@121
|
113 |
SEARCH_AUTOINDEX_PATH = '/home/spbot/irclogs/search-autoindex' |
|
terom@82
|
114 |
|