diff options
author | Huang Hao <hao.h.huang@intel.com> | 2014-01-14 12:43:14 +0800 |
---|---|---|
committer | Gui Chen <gui.chen@intel.com> | 2014-01-16 08:01:26 +0200 |
commit | f0a092b0fdd3126dced9015f01c900284fec476a (patch) | |
tree | 96e5856df18dae5bcd93b8310378e3985994537d /plugins | |
parent | c0e61fa1822562f7b92ac4cb14905fcf5803538e (diff) | |
download | mic-f0a092b0fdd3126dced9015f01c900284fec476a.tar.gz mic-f0a092b0fdd3126dced9015f01c900284fec476a.tar.bz2 mic-f0a092b0fdd3126dced9015f01c900284fec476a.zip |
Fix a bug that raise AttributeError.
When download attachment packages by using yum pkgmgr, the url
variable below is a unicode instead of SafeURL object.
Traceback (most recent call last):
......
File "/home/huanghao/workspace/mic/plugins/imager/loop_plugin.py", line 127, in do_create
creator.install()
File "/usr/local/lib/python2.7/dist-packages/mic/imager/baseimager.py", line 1051, in install
self.__attachment_packages(pkg_manager)
File "/usr/local/lib/python2.7/dist-packages/mic/imager/baseimager.py", line 966, in __attachment_packages
fpath = grabber.myurlgrab(url.full, fpath, proxies, None)
AttributeError: 'unicode' object has no attribute 'full'
Change-Id: Ib5c03ef053b8cf22f1b8ef1868ad244427df7cc6
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/backend/yumpkgmgr.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index 93c54cb..6884551 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -31,8 +31,10 @@ from mic.utils import misc, rpmmisc from mic.utils.grabber import TextProgress from mic.utils.proxy import get_proxy_for from mic.utils.errors import CreatorError +from mic.utils.safeurl import SafeURL from mic.imager.baseimager import BaseImageCreator + YUMCONF_TEMP = """[main] installroot=$installroot cachedir=/var/cache/yum @@ -471,18 +473,18 @@ class Yum(BackendPlugin, yum.YumBase): def package_url(self, pkgname): pkgs = self.pkgSack.searchNevra(name=pkgname) if pkgs: - proxy = None - proxies = None - url = pkgs[0].remote_url - repoid = pkgs[0].repoid - repos = filter(lambda r: r.id == repoid, self.repos.listEnabled()) - - if repos: - proxy = repos[0].proxy + pkg = pkgs[0] + + repo = pkg.repo + url = SafeURL(repo.baseurl[0]).join(pkg.remote_path) + + proxy = repo.proxy if not proxy: proxy = get_proxy_for(url) if proxy: proxies = {str(url.split(':')[0]): str(proxy)} + else: + proxies = None return (url, proxies) |