예제 #1
0
파일: fetch.py 프로젝트: ferhat1234/proje
 def run(self):
     """ Go, go, go! """
     from pybombs.fetcher import Fetcher
     from pybombs import recipe
     if self.args.all:
         self.log.debug("Loading all recipes!")
         self.args.packages = self.recipe_manager.list_all()
     try:
         self.log.debug("Getting recipes for: {0}".format(
             self.args.packages))
         recipe_list = [ \
             recipe.Recipe(self.recipe_manager.get_recipe_filename(x)) \
             for x in self.args.packages if len(x) \
         ]
     except KeyError as e:
         self.log.error("Package has no recipe: {0}".format(e))
         return 1
     for r in recipe_list:
         if (not hasattr(r, 'source')) or (not len(r.source)):
             self.log.warn("Package {0} has no sources listed.".format(
                 r.id))
             continue
         self.log.info("Downloading source for package {0}".format(r.id))
         try:
             if self.cmd == 'refetch':
                 Fetcher().update(r)
             else:
                 Fetcher().fetch(r)
         except PBException as ex:
             self.log.error("Unable to fetch package {0}. Skipping.".format(
                 r.id))
             self.log.error(ex)
예제 #2
0
 def _lint_recipe(self, recipe_file):
     """
     Check if recipe_file is a valid recipe
     """
     print("Linting recipe `{0}'".format(recipe_file))
     # Basic file checks
     try:
         recipe_dict = PBConfigFile(recipe_file).get()
     except IOError:
         self.log.error("Can't open `{0}'".format(recipe_file))
         return -1
     except AttributeError:
         self.log.error(
             "Can't parse contents of file `{0}'".format(recipe_file))
         return -1
     if not isinstance(recipe_dict, dict):
         self.log.error("Invalid recipe file. Not a dict.")
         return -1
     # Try loading as recipe
     try:
         rec = recipe.Recipe(recipe_file)
         if not hasattr(rec, 'satisfy'):
             print("[HMM] - No satisfy rules declared")
         else:
             for pkgtype in rec.satisfy.keys():
                 rec.get_package_reqs(pkgtype)
     except PBException as ex:
         print("[VERY BAD] - Recipe error: " + str(ex))
     # Check keys
     key_check = {
         'HMM': ['source', 'depends'],
         'BAD': ['inherit', 'category'],
     }
     for err_type, key_list in iteritems(key_check):
         for key in key_list:
             if not key in recipe_dict:
                 print("[{err}] Recipe doesn't have key: {key}".format(
                     err=err_type, key=key))
     # Check dependencies is a list
     dependencies = recipe_dict.get('depends', [])
     if not isinstance(dependencies, list):
         print("[VERY BAD] Dependencies is not a list: {}".format(
             dependencies))
예제 #3
0
파일: lint.py 프로젝트: djgrasss/pybombs2
 def _lint_recipe(self, recipe_file):
     """
     Check if recipe_file is a valid recipe
     """
     print("Linting recipe `{0}'".format(recipe_file))
     # Basic file checks
     try:
         recipe_source = open(recipe_file).read()
     except IOError:
         self.log.error("Can't open `{0}'".format(recipe_file))
         exit(1)
     try:
         recipe_dict = yaml.safe_load(recipe_source)
     except AttributeError:
         self.log.error("Can't parse contents of file `{0}'".format(recipe_file))
         exit(1)
     if not isinstance(recipe_dict, dict):
         self.log.error("Invalid recipe file. Not a dict.")
         exit(1)
     # Try loading as recipe
     try:
         rec = recipe.Recipe(recipe_file)
         if not hasattr(rec, 'satisfy'):
             print("[HMM] - No satisfy rules declared")
         else:
             for pkgtype in rec.satisfy.keys():
                 rec.get_package_reqs(pkgtype)
     except PBException as ex:
         print("[VERY BAD] - Recipe error: " + str(ex))
     # Check keys
     key_check = {
         'HMM': ['source', 'depends'],
         'BAD': ['inherit', 'category'],
     }
     for err_type, key_list in key_check.iteritems():
         for key in key_list:
             if not recipe_dict.has_key(key):
                 print("[{err}] Recipe doesn't have key: {key}".format(err=err_type, key=key))