Created
March 5, 2014 09:21
-
-
Save chengui/9363946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import zypp # import the module | |
#myRepoString = "http://download.meego.com/snapshots/1.2.80.6.0.20110630.1/repos/non-oss/ia32/packages/?proxy=proxy01.pd.intel.com&proxyport=911" | |
myRepoString = "http://download.meego.com/snapshots/1.2.0.90.6.20110630.1/repos/non-oss/ia32/packages/?proxy=proxy01.pd.intel.com&proxyport=911" | |
repoTmpPath = "/tmp/repoTmpPath" # temporary Path | |
myZypp = zypp.ZYppFactory_instance().getZYpp() # create the instance | |
myTarget = myZypp.initializeTarget(zypp.Pathname(repoTmpPath)) # target (aka "root") | |
repoManagerOptions = zypp.RepoManagerOptions(zypp.Pathname(repoTmpPath)) # where to store the metadata | |
repoManager = zypp.RepoManager(repoManagerOptions) # manages multiple repositories | |
pool = myZypp.pool() # pool of packages | |
myRepoInfo = zypp.RepoInfo() # constructor | |
myRepoInfo.addBaseUrl(zypp.Url(myRepoString)) # add URL | |
myRepoInfo.setAlias("default") # add alias | |
myRepoInfo.setName("default") # add name | |
myRepoInfo.setEnabled(True) # enable | |
myRepoInfo.setType(zypp.RepoType.RPMMD) # for only RPMMD - notice the checkbox ;) | |
myRepoInfo.setGpgCheck(False) # don't check for now | |
repoManager.addRepository(myRepoInfo) # add the repoInfo | |
repoManager.refreshMetadata(myRepoInfo) # fetch metadata | |
repoManager.buildCache(myRepoInfo) # build cache | |
repoManager.loadFromCache(myRepoInfo) # load cache | |
lowerLog = [] | |
for item in pool: # iterate over the pool | |
msg = "" | |
if zypp.isKindPackage(item): | |
msg += "Name: " | |
msg += str(item.name()) | |
msg += " - " | |
msg += "Version: " | |
msg += str(zypp.asKindPackage(item).edition()) | |
msg += " - " | |
msg += "Summary: " | |
msg += str(zypp.asKindPackage(item).summary()) | |
msg += "\n" | |
lowerLog.append(str(msg)) | |
for i in lowerLog: | |
print i | |
repoManager.removeRepository(myRepoInfo) # add the repoInfo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment