summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2023-07-28 15:15:22 +0900
committerbiao716.wang <biao716.wang@samsung.com>2023-07-28 15:15:22 +0900
commit2154b73ef02602f5beb905a7ff77e53ee1ea359e (patch)
treef194fe900fb5c2eb5f84fc2ab9b43b169314dfe0
parent07caadb33c235ec9580467ae602b1e4fb2fd9094 (diff)
downloadmic-2154b73ef02602f5beb905a7ff77e53ee1ea359e.tar.gz
mic-2154b73ef02602f5beb905a7ff77e53ee1ea359e.tar.bz2
mic-2154b73ef02602f5beb905a7ff77e53ee1ea359e.zip
update code from tools/mic
Change-Id: I15073ea4dd1222632c03c3984bac6c63428a40f5 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rwxr-xr-xmic/3rdparty/urlgrabber/grabber.py12
-rw-r--r--mic/msger.py5
-rw-r--r--mic/utils/errors.py6
-rwxr-xr-xmic/utils/misc.py4
4 files changed, 18 insertions, 9 deletions
diff --git a/mic/3rdparty/urlgrabber/grabber.py b/mic/3rdparty/urlgrabber/grabber.py
index 90d8b58..cfc33bb 100755
--- a/mic/3rdparty/urlgrabber/grabber.py
+++ b/mic/3rdparty/urlgrabber/grabber.py
@@ -1089,7 +1089,7 @@ class URLGrabberOptions:
return self.format()
def format(self, indent=' '):
- keys = self.__dict__.keys()
+ keys = list(self.__dict__.keys())
if self.delegate is not None:
keys.remove('delegate')
keys.sort()
@@ -1208,12 +1208,12 @@ class URLGrabber(object):
if not filename:
# This is better than nothing.
filename = 'index.html'
- if scheme == 'file' and not opts.copy_local:
+ if scheme == b'file' and not opts.copy_local:
# just return the name of the local file - don't make a
# copy currently
- path = url2pathname(path)
+ path = url2pathname(_urlunquote_convert(path))
if host:
- path = os.path.normpath('//' + host + path)
+ path = os.path.normpath('//' + _urlunquote_convert(host) + path)
if not os.path.exists(path):
err = URLGrabError(2,
_('Local file does not exist: %s') % (path, ))
@@ -1510,6 +1510,8 @@ class PyCurlFileObject(object):
self.curl_obj.setopt(pycurl.SSL_VERIFYPEER, opts.ssl_verify_peer)
if opts.ssl_verify_host: # 1 is meaningless to curl
self.curl_obj.setopt(pycurl.SSL_VERIFYHOST, 2)
+ else:
+ self.curl_obj.setopt(pycurl.SSL_VERIFYHOST, 0)
if opts.ssl_key:
self.curl_obj.setopt(pycurl.SSLKEY, opts.ssl_key)
if opts.ssl_key_type:
@@ -1855,7 +1857,7 @@ class PyCurlFileObject(object):
raise err
# re open it
try:
- self.fo = open(self.filename, 'r')
+ self.fo = open(self.filename, 'rb')
except IOError as e:
err = URLGrabError(16, _('error opening file from %s, IOError: %s')
% (self.url, e))
diff --git a/mic/msger.py b/mic/msger.py
index 8402f0e..f7131e1 100644
--- a/mic/msger.py
+++ b/mic/msger.py
@@ -148,6 +148,8 @@ class RedirectedStderr(object):
if self.tmpfile:
self.tmpfile.seek(0, 0)
self.value = self.tmpfile.read()
+ if isinstance(self.value, bytes):
+ self.value = self.value.decode()
def getvalue(self):
""" Read the bufferred data """
@@ -156,6 +158,8 @@ class RedirectedStderr(object):
self.value = self.tmpfile.read()
os.ftruncate(self.tmpfile.fileno(), 0)
os.lseek(self.tmpfile.fileno(), 0, os.SEEK_SET)
+ if isinstance(self.value, bytes):
+ self.value = self.value.decode()
return self.value
return None
@@ -213,7 +217,6 @@ class MicFileHandler(logging.FileHandler):
""" Log catched error message from stderr redirector """
if not self.errmsg:
return
-
sys.stdout.write(self.errmsg)
sys.stdout.flush()
diff --git a/mic/utils/errors.py b/mic/utils/errors.py
index d0c8e40..1377e9e 100644
--- a/mic/utils/errors.py
+++ b/mic/utils/errors.py
@@ -28,7 +28,11 @@ class CreatorError(Exception):
if isinstance(self.msg, str):
pass
else:
- self.msg = str(self.msg)
+ try:
+ self.msg = self.msg.deocde()
+ except:
+ self.msg = str(self.msg)
+ pass
return self.msg
def __repr__(self):
diff --git a/mic/utils/misc.py b/mic/utils/misc.py
index fd7a080..17136e7 100755
--- a/mic/utils/misc.py
+++ b/mic/utils/misc.py
@@ -637,7 +637,7 @@ def get_rpmver_in_repo(repometadata):
versionlist = []
for elm in root.iter("%spackage" % ns):
if elm.find("%sname" % ns).text == 'rpm':
- for node in elm.getchildren():
+ for node in list(elm):
if node.tag == "%sversion" % ns:
versionlist.append(node.attrib['ver'])
@@ -813,7 +813,7 @@ def get_source_name(pkg, repometadata):
ver = tmpver
fmt = elm.find("%sformat" % ns)
if fmt:
- fns = fmt.getchildren()[0].tag
+ fns = list(fmt)[0].tag
fns = fns[0:fns.rindex("}")+1]
pkgpath = fmt.find("%ssourcerpm" % fns).text
target_repo = repo