def __init__(self, filename): self.userhosts = {} self.masks = {} self.compiled = {} Persist.__init__(self, filename) if not self.data: self.data = [] for i in self.data: for j in i.userhosts: self.adduserhost(j, i)
def __init__(self, filename): Persist.__init__(self, filename) if not self.data: return for key in self.data.keys(): todoos = self.data[key] for (k, v) in todoos.data.items(): v.num = k newd = Todolist() for i in todoos: newd.append(i) self.data[key] = newd
def __init__(self, filename): Persist.__init__(self, filename) if not self.data: self.data = {} if self.data.has_key("itemslists"): del self.data["itemslists"] self.itemslists = Pdol(filename + ".itemslists") self.handlers = {} self.results = {} self.jobids = {} self.rawresults = {} self.results = Dol() self.modified = {} self.etag = {} self.markup = Pdod(filename + ".markup")
def __init__(self, filename): Persist.__init__(self, filename) if not self.data: self.data = {} if self.data.has_key('itemslists'): del self.data['itemslists'] self.itemslists = Pdol(filename + '.itemslists') self.handlers = {} self.results = {} self.jobids = {} self.rawresults = {} self.results = Dol() self.modified = {} self.etag = {} self.markup = Pdod(filename + '.markup')
def __init__(self): self.__basename__ = self.__class__.__name__ self.plugname = calledfrom(sys._getframe()) Persist.__init__(self, os.path.join(datadir, "%s-config" % \ self.plugname), {}) self.__callbacks = {} cmndname = "%s-cfg" % self.plugname rlog(-3, 'persistconfig', 'added command %s (%s)' % (cmndname, \ self.plugname)) cmnds[cmndname] = Command(self.cmnd_cfg, 'OPER', self.plugname, \ threaded=True) examples.add(cmndname, "plugin configuration", cmndname) cmndnamesave = cmndname + "save" cmnds[cmndnamesave] = Command(self.cmnd_cfgsave, 'OPER', \ self.plugname, threaded=True) examples.add(cmndnamesave, "save plugin configuration", cmndnamesave)
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)
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)
def __init__(self, fname): Persist.__init__(self, fname) if not self.data: self.data = []