Ejemplo n.º 1
0
 def has_artifact(self, adesc):
     check.check_artifact_descriptor(adesc)
     sql = 'select count(name) from artifacts where {}'.format(
         adesc.WHERE_EXPRESSION)
     t = adesc.to_sql_tuple()
     row = self._db.select_one(sql, adesc.to_sql_tuple())
     return row[0] > 0
Ejemplo n.º 2
0
 def remove_artifact(self, adesc):
     check.check_artifact_descriptor(adesc)
     if self._read_only:
         raise RuntimeError('artifact_manager is read only.')
     md = self.find_by_artifact_descriptor(adesc, False)
     if not md:
         raise NotInstalledError('package \"%s\" not found' % (str(adesc)))
     file_util.remove(md.filename)
     self._db.remove_artifact(adesc)
Ejemplo n.º 3
0
 def create_package(self, adesc, mutations={}):
     if check.is_string(adesc):
         adesc = artifact_descriptor.parse(adesc)
     check.check_artifact_descriptor(adesc)
     key = str(adesc)
     if not key in self._recipes:
         raise KeyError('recipe not found: %s' % (key))
     recipe = self._recipes[key]
     if mutations:
         recipe = recipe.clone_with_mutations(mutations)
     tmp_file = temp_file.make_temp_file()
     return recipe.create_package(tmp_file, debug=self._debug).filename
Ejemplo n.º 4
0
 def __new__(clazz, metadata, files, env_files, requirements, properties,
             objects):
     files = files or []
     env_files = env_files or []
     requirements = requirements or []
     properties = properties or {}
     check.check_artifact_descriptor(metadata)
     check.check_temp_item_seq(files)
     check.check_temp_item_seq(env_files)
     check.check_requirement_list(requirements)
     check.check_dict(properties)
     objects = objects or {}
     check.check_dict(objects)
     return clazz.__bases__[0].__new__(clazz, metadata, files, env_files,
                                       requirements, properties, objects)
Ejemplo n.º 5
0
 def get_artifact(self, adesc):
     check.check_artifact_descriptor(adesc)
     md = self._load_artifact(adesc)
     if not md:
         raise NotInstalledError('Not installed: %s' % (str(adesc)), adesc)
     return md
Ejemplo n.º 6
0
 def find_artifact(self, adesc):
     check.check_artifact_descriptor(adesc)
     return self._load_artifact(adesc)
Ejemplo n.º 7
0
 def remove_artifact(self, adesc):
     check.check_artifact_descriptor(adesc)
     if not self.has_artifact(adesc):
         raise NotInstalledError('Not installed: %s' % (str(adesc)), adesc)
     self._remove_artifact(adesc)
     self._db.commit()
Ejemplo n.º 8
0
 def find_by_artifact_descriptor(self, adesc, relative_filename):
     check.check_artifact_descriptor(adesc)
     md = self._db.get_artifact(adesc)
     if relative_filename:
         return md
     return md.clone_with_filename(path.join(self._root_dir, md.filename))
Ejemplo n.º 9
0
 def _publish_one(self, adesc, mutations):
     if check.is_string(adesc):
         adesc = artifact_descriptor.parse(adesc)
     check.check_artifact_descriptor(adesc)
     filename = self.create_package(adesc, mutations=mutations)
     self.am.publish(filename, adesc.build_target, False, None)