Example #1
0
def upgrade():
    rlog(10, 'infoitem', 'upgrading')
    teller = 0
    dbdir = datadir + os.sep + 'db' + os.sep + 'infoitem.db'
    if os.path.exists(dbdir):
        try:
            from gozerbot.database.db import Db
            db = Db(dbtype='sqlite')
            db.connect('db/infoitem.db')
            result = db.execute(""" SELECT * FROM infoitems """)
            if result:
                for i in result:
                    info.add(*i[1:])
                    teller += 1
        except Exception, ex:
            handle_exception()
Example #2
0
def upgrade():
    teller = 0
    oldfile = datadir + os.sep + 'old'
    dbdir = datadir + os.sep + 'db' + os.sep + 'karma.db'
    if os.path.exists(dbdir):
        try:
            from gozerbot.database.db import Db
            db = Db(dbtype='sqlite')
            db.connect('db/karma.db')
            result = db.execute(""" SELECT * FROM karma """)
            if result:
                for i in result:
                    try:
                        karma.add(i[0], i[1])
                    except sa.exc.IntegrityError:
                        pass
                    teller += 1
            result = db.execute(""" SELECT * FROM whokarma """)
            if result:
                for i in result:
                    if i[2] == 'up':
                        karma.setwhoup(i[0], i[1])
                    else:
                        karma.setwhodown(i[0], i[1])
            result = db.execute(""" SELECT * FROM whykarma """)
            if result:
                for i in result:
                    karma.addwhy(*i)
        except Exception, ex:
            handle_exception()
        return teller
Example #3
0
def upgrade():
    rlog(10, 'quote', 'upgrading')
    teller = 0
    oldfile = datadir + os.sep + 'old' + os.sep + 'todo'
    dbdir = datadir + os.sep + 'db' + os.sep + 'todo.db' 
    if os.path.exists(dbdir):
        try:
            from gozerbot.database.db import Db
            db = Db(dbtype='sqlite')
            db.connect('db/todo.db')
            result = db.execute(""" SELECT * FROM todo """)
            if result:
                for i in result:
                    todo.add(i[1], i[5],*i[2:4])
                    teller += 1
        except Exception, ex:  
            handle_exception() 
        return teller
Example #4
0
def upgrade():
    rlog(10, 'quote', 'upgrading')
    teller = 0
    oldfile = datadir + os.sep + 'old' + os.sep + 'todo'
    dbdir = datadir + os.sep + 'db' + os.sep + 'todo.db'
    if os.path.exists(dbdir):
        try:
            from gozerbot.database.db import Db
            db = Db(dbtype='sqlite')
            db.connect('db/todo.db')
            result = db.execute(""" SELECT * FROM todo """)
            if result:
                for i in result:
                    todo.add(i[1], i[5], *i[2:4])
                    teller += 1
        except Exception, ex:
            handle_exception()
        return teller
Example #5
0
def upgrade():
    teller = 0
    oldfile = datadir + os.sep + 'old'
    dbdir = datadir + os.sep + 'db' + os.sep + 'karma.db'
    if os.path.exists(dbdir):
        try:
            from gozerbot.database.db import Db
            db = Db(dbtype='sqlite')
            db.connect('db/karma.db')
            result = db.execute(""" SELECT * FROM karma """)
            if result:
                for i in result:
                    try:
                        karma.add(i[0], i[1])
                    except sa.exc.IntegrityError:
                        pass
                    teller += 1
            result = db.execute(""" SELECT * FROM whokarma """)
            if result:
                for i in result:
                    if i[2] == 'up':
                        karma.setwhoup(i[0], i[1])
                    else:
                        karma.setwhodown(i[0], i[1])
            result = db.execute(""" SELECT * FROM whykarma """)
            if result:
                for i in result:
                    karma.addwhy(*i)
        except Exception, ex:
            handle_exception()
        return teller
Example #6
0
        if name in upgraded:
            continue
        try:
            if not byname(name):
                newuser = User(name=name)
                session.add(newuser)
            upgraded.append(name)
        except sqlalchemy.exc.IntegrityError, ex:
            pass
        except:
            handle_exception()

    session.commit()
    print "upgraded: %s" % ' .. '.join(upgraded) 
    print 'upgrading email table'
    from gozerbot.database.db import Db

    # upgrade email table
    try:
        db = Db(config=mainconfig)
        if db.dbtype == 'mysql':
            db.execute("ALTER TABLE email ADD COLUMN email.order INT")
        else:
            db.execute("ALTER TABLE email ADD COLUMN 'order' INT")
    except Exception, ex:
        if 'already exists' in str(ex) or 'duplicate column name' in \
str(ex).lower():
            pass
        else:
            handle_exception()
Example #7
0
        if name in upgraded:
            continue
        try:
            if not byname(name):
                newuser = User(name=name)
                session.add(newuser)
            upgraded.append(name)
        except sqlalchemy.exc.IntegrityError, ex:
            pass
        except:
            handle_exception()

    session.commit()
    print "upgraded: %s" % ' .. '.join(upgraded)
    print 'upgrading email table'
    from gozerbot.database.db import Db

    # upgrade email table
    try:
        db = Db(config=mainconfig)
        if db.dbtype == 'mysql':
            db.execute("ALTER TABLE email ADD COLUMN email.order INT")
        else:
            db.execute("ALTER TABLE email ADD COLUMN 'order' INT")
    except Exception, ex:
        if 'already exists' in str(ex) or 'duplicate column name' in \
str(ex).lower():
            pass
        else:
            handle_exception()