diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2006-10-08 13:57:23 +0400 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2006-10-08 13:57:23 +0400 |
commit | 5c615f53b5ad0359aa6c591e7ce621f7492a4386 (patch) | |
tree | cc78a51eefce8366158124af13cf880f038422d4 | |
parent | 182963242b57e91e40fe635847cf430a4b55bef9 (diff) |
clean logs table so that show field contains only 0, 1, 2, 3, 4, 5 values
-rw-r--r-- | src/common/config.py | 2 | ||||
-rw-r--r-- | src/common/optparser.py | 35 |
2 files changed, 29 insertions, 8 deletions
diff --git a/src/common/config.py b/src/common/config.py index 2b0da3e85..fd575affa 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -141,7 +141,7 @@ class Config: 'send_on_ctrl_enter': [opt_bool, False, _('Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour).')], 'show_roster_on_startup': [opt_bool, True], 'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')], - 'version': [ opt_str, '0.10.1.4' ], # which version created the config + 'version': [ opt_str, '0.10.1.5' ], # which version created the config 'search_engine': [opt_str, 'http://www.google.com/search?&q=%s&sourceid=gajim'], 'dictionary_url': [opt_str, 'WIKTIONARY', _("Either custom url with %s in it where %s is the word/phrase or 'WIKTIONARY' which means use wiktionary.")], 'always_english_wikipedia': [opt_bool, False], diff --git a/src/common/optparser.py b/src/common/optparser.py index 7d381afe9..e181f516e 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -147,6 +147,8 @@ class OptionsParser: self.update_config_to_01013() if old < [0, 10, 1, 4] and new >= [0, 10, 1, 4]: self.update_config_to_01014() + if old < [0, 10, 1, 5] and new >= [0, 10, 1, 5]: + self.update_config_to_01015() gajim.logger.init_vars() gajim.config.set('version', new_version) @@ -315,13 +317,32 @@ class OptionsParser: con = sqlite.connect(logger.LOG_DB_PATH) cur = con.cursor() # apply indeces - cur.executescript( - ''' - CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind); - CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id); - ''' - ) + try: + cur.executescript( + ''' + CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind); + CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id); + ''' + ) - con.commit() + con.commit() + except: + pass con.close() gajim.config.set('version', '0.10.1.4') + + def update_config_to_01015(self): + '''clean show values in logs database''' + from pysqlite2 import dbapi2 as sqlite + import logger + con = sqlite.connect(logger.LOG_DB_PATH) + cur = con.cursor() + status = dict((i[5:].lower(), logger.constants.__dict__[i]) for i in \ + logger.constants.__dict__.keys() if i.startswith('SHOW_')) + for show in status: + cur.execute('update logs set show = ? where show = ?;', (status[show], + show)) + cur.executescript('update logs set show = NULL where show not in (0, 1, 2, 3, 4, 5);') + con.commit() + con.close() + gajim.config.set('version', '0.10.1.5') |