コード例 #1
0
 def from_export(self):
     export_dir = self.options.export_location
     self.warn(1, "Getting files from channel export: ", export_dir)
     if not self.options.channel:
         self.warn(2, "No channels specified, getting all files")
         # If no channels specified just upload all rpms from
         # all the rpm directories
         for hash_dir in uploadLib.listdir(os.path.join(
                 export_dir, "rpms")):
             self.options.dir = hash_dir
             self.directory()
         return
     # else...
     self.warn(2, "Getting only files in these channels",
               self.options.channel)
     # Read the channel xml and add only packages that are in these channels
     package_set = set([])
     for channel in self.options.channel:
         xml_path = os.path.join(export_dir, "channels", channel,
                                 "channel.xml.gz")
         if not os.access(xml_path, os.R_OK):
             self.warn(0, "Could not find metadata for channel %s, skipping..." % channel)
             print "Could not find metadata for channel %s, skipping..." % channel
             continue
         dom = minidom.parse(gzip.open(xml_path))
         # will only ever be the one
         dom_channel = dom.getElementsByTagName('rhn-channel')[0]
         package_set.update(dom_channel.attributes['packages']
                            .value.encode('ascii', 'ignore').split())
     # Try to find relevent packages in the export
     for hash_dir in uploadLib.listdir(os.path.join(export_dir, "rpms")):
         for rpm in uploadLib.listdir(hash_dir):
             # rpm name minus '.rpm'
             if os.path.basename(rpm)[:-4] in package_set:
                 self.files.append(rpm)
コード例 #2
0
 def from_export(self):
     export_dir = self.options.export_location
     self.warn(1, "Getting files from channel export: ", export_dir)
     if not self.options.channel:
         self.warn(2, "No channels specified, getting all files")
         # If no channels specified just upload all rpms from
         # all the rpm directories
         for hash_dir in uploadLib.listdir(os.path.join(
                 export_dir, "rpms")):
             self.options.dir = hash_dir
             self.directory()
         return
     # else...
     self.warn(2, "Getting only files in these channels",
               self.options.channel)
     # Read the channel xml and add only packages that are in these channels
     package_set = set([])
     for channel in self.options.channel:
         xml_path = os.path.join(export_dir, "channels", channel,
                                 "channel.xml.gz")
         if not os.access(xml_path, os.R_OK):
             self.warn(0, "Could not find metadata for channel %s, skipping..." % channel)
             print "Could not find metadata for channel %s, skipping..." % channel
             continue
         dom = minidom.parse(gzip.open(xml_path))
         # will only ever be the one
         dom_channel = dom.getElementsByTagName('rhn-channel')[0]
         package_set.update(dom_channel.attributes['packages']
                            .value.encode('ascii', 'ignore').split())
     # Try to find relevent packages in the export
     for hash_dir in uploadLib.listdir(os.path.join(export_dir, "rpms")):
         for rpm in uploadLib.listdir(hash_dir):
             # rpm name minus '.rpm'
             if os.path.basename(rpm)[:-4] in package_set:
                 self.files.append(rpm)