Changeset 10256 for mirror/edenwall

Show
Ignore:
Timestamp:
04/06/09 17:23:05 (16 months ago)
Author:
romain
svm:headrev:

c624a6cb-57d4-0310-9736-a25a8df6d016:18258
svk:copy_cache_prev:
10255
Message:

applied patch from Philippe Pujas.

This patch is for ulog_rotate.py in nulog package. When starting users_1
and ulog_1 SQL tables don't exist and the script crashes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mirror/edenwall/nulog2/branches/2.0/scripts/ulog_rotate.py

    r9332 r10256  
    109109 
    110110    def __table_exists(self, table): 
     111        try: 
     112            self.cursor.execute("""SHOW TABLES LIKE '%s'""" % table) 
     113            return self.cursor.fetchone()!=None 
     114        except _mysql_exceptions.ProgrammingError, e: 
     115            self.debug(e) 
     116            return False 
    111117 
     118    def __table_creates(self, table, pattern): 
    112119        try: 
    113             self.cursor.execute('select id from %s_1 limit 1' % self.ulog) 
     120            self.cursor.execute("CREATE TABLE IF NOT EXISTS `%s` LIKE `%s`" % (table, pattern)) 
    114121            return True 
    115122        except _mysql_exceptions.ProgrammingError, e: 
     
    119126    def daily_rotate(self, table, timestamp): 
    120127 
    121         if not self.__table_exists(table): 
     128        if not self.__table_exists(table+"_1") and not self.__table_creates(table+"_1",table): 
    122129            return 
    123130        self.cursor.execute("""INSERT INTO %s_1