コード例 #1
0
 def refresh_packages(self):
     """
     Refresh packages from Koji: add packages not yet known by Koschei
     and update blocked flag.
     """
     source_tag = util.koji_config['source_tag']
     koji_packages = self.koji_session.listPackages(tagID=source_tag,
                                                    inherited=True)
     whitelisted = {
         p['package_name']
         for p in koji_packages if not p['blocked']
     }
     packages = self.db.query(Package).all()
     to_update = [
         p.id for p in packages if p.blocked == (p.name in whitelisted)
     ]
     if to_update:
         self.db.query(Package).filter(Package.id.in_(to_update))\
                .update({'blocked': ~Package.blocked}, synchronize_session=False)
         self.db.expire_all()
         self.db.flush()
     existing_names = {p.name for p in packages}
     to_add = [
         p for p in koji_packages if p['package_name'] not in existing_names
     ]
     if to_add:
         for p in to_add:
             pkg = Package(name=p['package_name'])
             pkg.blocked = p['blocked']
             pkg.tracked = False
             self.db.add(pkg)
         self.db.flush()
コード例 #2
0
ファイル: __init__.py プロジェクト: W3SS/koschei
 def refresh_packages(self):
     """
     Refresh packages from Koji: add packages not yet known by Koschei
     and update blocked flag.
     """
     for collection in self.db.query(Collection):
         koji_packages = self.koji_sessions['secondary']\
             .listPackages(tagID=collection.target_tag, inherited=True)
         whitelisted = {
             p['package_name']
             for p in koji_packages if not p['blocked']
         }
         packages = self.db.query(Package).filter_by(
             collection_id=collection.id).all()
         to_update = [
             p.id for p in packages if p.blocked == (p.name in whitelisted)
         ]
         if to_update:
             self.db.query(Package).filter(Package.id.in_(to_update))\
                    .update({'blocked': ~Package.blocked}, synchronize_session=False)
             self.db.flush()
         existing_names = {p.name for p in packages}
         to_add = [
             p for p in koji_packages
             if p['package_name'] not in existing_names
         ]
         if to_add:
             for p in to_add:
                 pkg = Package(name=p['package_name'],
                               collection_id=collection.id)
                 pkg.blocked = p['blocked']
                 pkg.tracked = False
                 self.db.add(pkg)
             self.db.flush()
         self.db.expire_all()
コード例 #3
0
ファイル: __init__.py プロジェクト: W3SS/koschei
 def refresh_packages(self):
     """
     Refresh packages from Koji: add packages not yet known by Koschei
     and update blocked flag.
     """
     for collection in self.db.query(Collection):
         koji_packages = self.koji_sessions['secondary']\
             .listPackages(tagID=collection.target_tag, inherited=True)
         whitelisted = {p['package_name'] for p in koji_packages if not p['blocked']}
         packages = self.db.query(Package).filter_by(collection_id=collection.id).all()
         to_update = [p.id for p in packages if p.blocked == (p.name in whitelisted)]
         if to_update:
             self.db.query(Package).filter(Package.id.in_(to_update))\
                    .update({'blocked': ~Package.blocked}, synchronize_session=False)
             self.db.flush()
         existing_names = {p.name for p in packages}
         to_add = [p for p in koji_packages if p['package_name'] not in existing_names]
         if to_add:
             for p in to_add:
                 pkg = Package(name=p['package_name'], collection_id=collection.id)
                 pkg.blocked = p['blocked']
                 pkg.tracked = False
                 self.db.add(pkg)
             self.db.flush()
         self.db.expire_all()