def _checkDecks(self): self._decks = [] decks = self.mw.config.recentDecks() if not decks: return tx = time.time() self.mw.progress.start(max=len(decks)) for c, d in enumerate(decks): self.mw.progress.update( _("Checking deck %(x)d of %(y)d...") % { 'x': c + 1, 'y': len(decks) }) base = os.path.basename(d) if not os.path.exists(d): self._decks.append({ 'name': base, 'state': 'missing', 'path': d }) continue try: mod = os.stat(d)[stat.ST_MTIME] t = time.time() deck = Deck(d, queue=False, lock=False) counts = deck.sched.selCounts() dtime = deck.sched.timeToday() dreps = deck.sched.repsToday() self._decks.append({ 'path': d, 'state': 'ok', 'name': deck.name(), 'due': counts[1] + counts[2], 'new': counts[0], 'mod': deck.mod, # these multiply deck check time by a factor of 6 'time': dtime, 'reps': dreps }) deck.close(save=False) # reset modification time for the sake of backup systems try: os.utime(d, (mod, mod)) except: # some misbehaving filesystems may fail here pass except Exception, e: if "locked" in unicode(e): state = "in use" else: state = "corrupt" self._decks.append({'name': base, 'state': state, 'path': d})
def _checkDecks(self): self._decks = [] decks = self.mw.config.recentDecks() if not decks: return tx = time.time() self.mw.progress.start(max=len(decks)) for c, d in enumerate(decks): self.mw.progress.update(_("Checking deck %(x)d of %(y)d...") % { 'x': c+1, 'y': len(decks)}) base = os.path.basename(d) if not os.path.exists(d): self._decks.append({'name': base, 'state': 'missing', 'path':d}) continue try: mod = os.stat(d)[stat.ST_MTIME] t = time.time() deck = Deck(d, queue=False, lock=False) counts = deck.sched.selCounts() dtime = deck.sched.timeToday() dreps = deck.sched.repsToday() self._decks.append({ 'path': d, 'state': 'ok', 'name': deck.name(), 'due': counts[1]+counts[2], 'new': counts[0], 'mod': deck.mod, # these multiply deck check time by a factor of 6 'time': dtime, 'reps': dreps }) deck.close(save=False) # reset modification time for the sake of backup systems try: os.utime(d, (mod, mod)) except: # some misbehaving filesystems may fail here pass except Exception, e: if "locked" in unicode(e): state = "in use" else: state = "corrupt" self._decks.append({'name': base, 'state':state, 'path':d})