Exemplo n.º 1
0
 def check_cache(self):
     """changes layout according to the cache existens
     """
     # disables the search button if cache does not exists
     if not GutenbergCache.exists():
         # disables the search button if not
         self.queryBox.setDisabled(True)
         self.infoBox.setText(
             "Cache must be generated before first launch, it can take up to 10min",
             "warning")
     # disables the the cache generation button if it does exists
     else:
         self.cacheGenerationButton.setDisabled(True)
Exemplo n.º 2
0
 def generate_cache(self):
     """generates the cache
     """
     if not GutenbergCache.exists():
         try:
             self.infoBox.setText(
                 "The cache is being generated. This can take up to 10min.",
                 "warning")
             GutenbergCache.create(refresh=True,
                                   download=True,
                                   unpack=True,
                                   parse=True,
                                   deleteTemp=True)
             self.infoBox.setText("Cache generated!")
             self.cacheGenerationButton.setDisabled(True)
             self.queryBox.setEnabled(True)
         except Exception as exc:
             print(exc)
             self.infoBox.setText(
                 "An error occurred while building the cache", "error")
     else:
         self.infoBox.setText("The cache already exists.")