Ejemplo n.º 1
0
 def verify_plugin(self):
     """Verify plugin conforms to basic plugin structure.  Returns
     True if the plugin appears ok, False otherwise."""
     plugin_ok = True
     if self.plugin is not None:
         plugin_zip = UnZipper(self.plugin_contents, self.zip_password)
         if not plugin_zip.is_ok():
             module_logger.warning("Plugin archive corrupted - failed CRC check.")
             return False
         plugin_files = [each_file for each_file in plugin_zip.list_contents()]
         readme_found = False
         for valid_readme in self.readme_files:
             if valid_readme in plugin_files:
                 readme_found = True
                 break
         if not readme_found:
             module_logger.warning("Plugin does not conform to spec - no README found.")
             return False
         zip_name = os.path.basename(self.plugin_url)
         zip_name_base, ext = os.path.splitext(zip_name)
         plugin_main = ''.join([zip_name_base, '.py'])
         if plugin_main not in plugin_files:
             module_logger.warning("Plugin does not conform to spec - no main Python file found.")
             return False
         plugin_fldr = zip_name_base
         support_files = [el for el in plugin_files if
                          el not in self.readme_files and el != plugin_main]
         for each_file in support_files:
             install_fldr = os.path.dirname(each_file)
             if os.path.commonprefix([plugin_fldr, install_fldr]) != plugin_fldr:
                 module_logger.warning("Plugin does not conform to spec - incorrect folder structure.")
                 return False
     return plugin_ok
Ejemplo n.º 2
0
 def plugin_files(self):
     """Returns a list of the files in the plugin archive"""
     files = []
     plugin_reader = UnZipper(self.plugin_contents, self.zip_password)
     if plugin_reader.is_ok():
         files = plugin_reader.list_contents()
     else:
         module_logger.warning("Plugin archive corrupted - failed CRC check.")
     return files
Ejemplo n.º 3
0
 def retrieve_readme(self):
     """Returns the contents of the plugin archive's root-level
     README, or None if not found."""
     readme_content = None
     if self.plugin is not None:
         readme_extractor = UnZipper(self.plugin_contents, self.zip_password)
         if readme_extractor.is_ok():
             plugin_files = readme_extractor.list_contents()
             for readme_file in self.readme_files:
                 if readme_file in plugin_files:
                     readme_content = readme_extractor.read(readme_file)
         else:
             module_logger.warning("Plugin archive corrupted - failed CRC check.")
     return readme_content