예제 #1
0
    def syncold(self, filename, remove=False):
        """ sync with old config data """
        if os.path.isfile(filename):
            synckey = "persistconfig-syncold"
            oldconfig = Persist(filename)
            if not oldconfig.data.has_key(synckey):
                rlog(10, 'persistconfig', "syncing old config %s with \
persistconfig" % filename)
                for i, j in oldconfig.data.iteritems():
                    if i == synckey:
                        continue
                    if j and not self.get(i):
                        self.set(i, oldconfig.data[i])
                oldconfig.data[synckey] = time.localtime()
                oldconfig.save()
            del oldconfig
            if remove:
                os.unlink(filename)
예제 #2
0
            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
    try:
        from gozerbot.utils.generic import dosed
        from gozerbot.compat.persist import Persist
        from gozerbot.compat.todo import Todoitem
        dosed(oldfile, 's/cgozerbot\.compat/cgozerplugs/')
        oldpersist = Persist(oldfile)
        if not oldpersist or not oldpersist.data:
            return
        for name, itemlist in oldpersist.data.iteritems():
            for item in itemlist:
                todo.add(name, item.descr, datetime.fromtimestamp(item.time), item.duration, \
item.warnsec, item.priority)
                teller += 1
    except IOError, ex:
        if 'No such file' in str(ex):
            rlog(10, 'todo', 'nothing to upgrade')
    except Exception, ex:
        rlog(10, 'todo', "can't upgrade .. reason: %s" % str(ex))
        handle_exception()
    else:
        rlog(10, 'quote', "upgraded %s items" % teller)