qmsk/irclogs/config.py
author Tero Marttila <terom@fixme.fi>
Sun, 13 Sep 2009 01:15:56 +0300
changeset 140 6db2527b67cf
parent 131 config.py@67f5d2fdca1d
child 141 65c98c9e1716
permissions -rw-r--r--
restructure into package format - the qmsk.* stuff doesn't work so well though, requires a symlink for qmsk.web to work...
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
"""
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
    Configureable defaults
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
"""
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
import os.path, pytz
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
from log_parser import IrssiParser
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
from log_channel import LogChannel
82
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
     8
from log_source import LogSourceDecoder, LogDirectory
86
645cf9c4441e implement full parser+formatter for irssi
Tero Marttila <terom@fixme.fi>
parents: 82
diff changeset
     9
from log_formatter import IrssiFormatter, DebugFormatter
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
from channels import ChannelList
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
import log_formatter
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
128
2a8a190f8aee fix config.VERSION_LINK to use relpath('.')
Tero Marttila <terom@fixme.fi>
parents: 124
diff changeset
    13
# build relative paths to the dir containing this file
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
relpath = lambda path : os.path.join(os.path.dirname(__file__), path)
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    16
###                     ###
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    17
###    Configuration    ###
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    18
###                     ###
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    19
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
# timezone to use for logs
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    21
LOG_TIMEZONE                    = pytz.timezone('Europe/Helsinki')
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
# timestamp format for logfiles
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    24
LOG_TIMESTAMP_FMT               = '%H:%M:%S'
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
82
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
    26
# the decoder used for logfiles
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
    27
LOG_DECODER                     = LogSourceDecoder((
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
    28
    ('utf-8',       'strict'),
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
    29
    ('latin-1',     'replace'),
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
    30
))
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
# log filename format
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    33
LOG_FILENAME_FMT                = '%Y-%m-%d'
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
# the log parser that we use
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    36
LOG_PARSER                      = IrssiParser(LOG_TIMEZONE, LOG_TIMESTAMP_FMT)
121
86aebc9cb60b some quickfixes to fix deployment errors
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
    37
#LOG_PARSER_FULLTS               = IrssiParser(LOG_TIMEZONE, '%Y%m%d%H%M%S')
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
# the statically defined channel list
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    40
LOG_CHANNELS                    = ChannelList([
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
    LogChannel('tycoon',    "OFTC",     "#tycoon", 
121
86aebc9cb60b some quickfixes to fix deployment errors
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
    42
        LogDirectory(relpath('/home/spbot/irclogs/tycoon'),    LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT)
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
    ),
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
    LogChannel('openttd',   "OFTC",     "#openttd", 
121
86aebc9cb60b some quickfixes to fix deployment errors
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
    46
        LogDirectory(relpath('/home/spbot/irclogs/openttd'),   LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT)
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
    ),
81
745032a57803 add #test logfile, improve handling of low-logfile situations
Tero Marttila <terom@fixme.fi>
parents: 79
diff changeset
    48
745032a57803 add #test logfile, improve handling of low-logfile situations
Tero Marttila <terom@fixme.fi>
parents: 79
diff changeset
    49
    LogChannel('test',      "TEST",     "#test",
121
86aebc9cb60b some quickfixes to fix deployment errors
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
    50
        LogDirectory(relpath('/home/spbot/irclogs/test'),  LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT)
81
745032a57803 add #test logfile, improve handling of low-logfile situations
Tero Marttila <terom@fixme.fi>
parents: 79
diff changeset
    51
    )
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
])
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    53
131
67f5d2fdca1d rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
Tero Marttila <terom@fixme.fi>
parents: 128
diff changeset
    54
# URL to the hgweb installation for this code
119
df859bfdd3be add version string
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    55
HGWEB_URL                       = "http://hg.qmsk.net/irclogs2"
df859bfdd3be add version string
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    56
140
6db2527b67cf restructure into package format - the qmsk.* stuff doesn't work so well though, requires a symlink for qmsk.web to work...
Tero Marttila <terom@fixme.fi>
parents: 131
diff changeset
    57
# path to the mercurial working copy
6db2527b67cf restructure into package format - the qmsk.* stuff doesn't work so well though, requires a symlink for qmsk.web to work...
Tero Marttila <terom@fixme.fi>
parents: 131
diff changeset
    58
HG_WC_PATH                      = "."
119
df859bfdd3be add version string
Tero Marttila <terom@fixme.fi>
parents: 86
diff changeset
    59
82
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
    60
# how to handle decode() errors for logfile lines
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
    61
LOG_SOURCE_DECODE_ERRORS        = 'replace'
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
    62
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
# date format for URLs
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    64
URL_DATE_FMT                    = '%Y-%m-%d'
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
# month name format
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    67
MONTH_FMT                       = '%B %Y'
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    68
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    69
# timezone name format
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    70
TIMEZONE_FMT                    = '%Z %z'
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    71
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    72
# TTF fonts to use for drawing images
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    73
FORMATTER_IMAGE_FONTS =         {
124
4bc4de14f006 remove support for default font, as it doesn't support unicode, and implement a 1px line spacing for format_png
Tero Marttila <terom@fixme.fi>
parents: 121
diff changeset
    74
    # XXX: no unicode support
4bc4de14f006 remove support for default font, as it doesn't support unicode, and implement a 1px line spacing for format_png
Tero Marttila <terom@fixme.fi>
parents: 121
diff changeset
    75
    #    'default':              (None,                                                                  "Ugly default font"         ),
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    76
    'ttf-dejavu-mono':      ("/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf",             "DejaVu Sans Mono"          ),
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    77
    'ttf-liberation-mono':  ("/usr/share/fonts/truetype/ttf-liberation/LiberationMono-Regular.ttf", "Liberation Mono Regular"   )
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    78
}
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    79
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    80
# available formatters
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    81
LOG_FORMATTERS =                {
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    82
    'irssi':        IrssiFormatter,
86
645cf9c4441e implement full parser+formatter for irssi
Tero Marttila <terom@fixme.fi>
parents: 82
diff changeset
    83
    'debug':        DebugFormatter,
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    84
}
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    85
131
67f5d2fdca1d rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
Tero Marttila <terom@fixme.fi>
parents: 128
diff changeset
    86
# Cookie settings
67f5d2fdca1d rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
Tero Marttila <terom@fixme.fi>
parents: 128
diff changeset
    87
PREF_COOKIE_PATH                = '/'
67f5d2fdca1d rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
Tero Marttila <terom@fixme.fi>
parents: 128
diff changeset
    88
PREF_COOKIE_EXPIRE_SECONDS      = 1 * 365 * 24 * 60 * 60    # one year
67f5d2fdca1d rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
Tero Marttila <terom@fixme.fi>
parents: 128
diff changeset
    89
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    90
# default preferences
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    91
PREF_TIME_FMT_DEFAULT           = '%H:%M:%S'
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    92
PREF_DATE_FMT_DEFAULT           = '%Y-%m-%d'
131
67f5d2fdca1d rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
Tero Marttila <terom@fixme.fi>
parents: 128
diff changeset
    93
PREF_TIMEZONE_FALLBACK          = pytz.utc
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    94
PREF_FORMATTER_DEFAULT          = IrssiFormatter
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    95
PREF_COUNT_DEFAULT              = 200
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    96
PREF_COUNT_MAX                  = None
124
4bc4de14f006 remove support for default font, as it doesn't support unicode, and implement a 1px line spacing for format_png
Tero Marttila <terom@fixme.fi>
parents: 121
diff changeset
    97
PREF_IMAGE_FONT_DEFAULT         = 'ttf-dejavu-mono'
4bc4de14f006 remove support for default font, as it doesn't support unicode, and implement a 1px line spacing for format_png
Tero Marttila <terom@fixme.fi>
parents: 121
diff changeset
    98
PREF_IMAGE_FONT_SIZE_DEFAULT    = 12
79
43ac75054d5c image formatting \o/
Tero Marttila <terom@fixme.fi>
parents: 73
diff changeset
    99
PREF_IMAGE_FONT_SIZE_MAX        = 32
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   101
# search line count options
82
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
   102
SEARCH_LINE_COUNT_OPTIONS       = (
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
    (50,    50), 
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
    (100,   100), 
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   105
    (200,   200), 
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   106
    (None,  "&#8734;"),
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
)
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   108
82
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
   109
# search index database path
121
86aebc9cb60b some quickfixes to fix deployment errors
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
   110
SEARCH_INDEX_PATH               = '/home/spbot/irclogs/search-index'
86aebc9cb60b some quickfixes to fix deployment errors
Tero Marttila <terom@fixme.fi>
parents: 119
diff changeset
   111
SEARCH_AUTOINDEX_PATH           = '/home/spbot/irclogs/search-autoindex'
82
afd3120ec71e add a LogSourceDecoder to fallback from utf-8 to latin-1, and improve scripts/search-index.py
Tero Marttila <terom@fixme.fi>
parents: 81
diff changeset
   112