Decode messages for output to stderr

This commit is contained in:
alexanderlaw 2014-11-05 15:01:25 +03:00
parent dbf8c434e6
commit 95db824a77

View file

@ -458,7 +458,7 @@ def wget_url(url, target_file):
if p.returncode != 0: if p.returncode != 0:
print >> sys.stderr, ('Unable to get data from the url: %s ' print >> sys.stderr, ('Unable to get data from the url: %s '
'(error: %d).\n%s\n%s') % \ '(error: %d).\n%s\n%s') % \
(url, p.returncode, wget_out, wget_err) (url, p.returncode, wget_out.decode('utf-8'), wget_err.decode('utf-8'))
raise Exception('Unable to download data (%d).' % p.returncode) raise Exception('Unable to download data (%d).' % p.returncode)
if target_file is None: if target_file is None:
return wget_out return wget_out
@ -519,7 +519,7 @@ def urpm_get_packages(media):
if p.returncode != 0 or len(urpmqr_err) > 0: if p.returncode != 0 or len(urpmqr_err) > 0:
print >> sys.stderr, ('Unable to get a list of packages ' print >> sys.stderr, ('Unable to get a list of packages '
'from the media: %s.\n' 'from the media: %s.\n'
'%s\n%s') % (media, urpmqr_out, urpmq_err) '%s\n%s') % (media, urpmqr_out.decode('utf-8'), urpmq_err.decode('utf-8'))
raise Exception('Unable to get a list of packages (%d).' % p.returncode) raise Exception('Unable to get a list of packages (%d).' % p.returncode)
# urpmi --no-install --allow-nodeps --force # urpmi --no-install --allow-nodeps --force
# --download-all=/tmp/ xine-wavpack-1.2.4-1plf --media Desktop2012.1-8 # --download-all=/tmp/ xine-wavpack-1.2.4-1plf --media Desktop2012.1-8
@ -532,7 +532,7 @@ def urpm_get_packages(media):
if p.returncode != 0 or len(urpmqf_err) > 0: if p.returncode != 0 or len(urpmqf_err) > 0:
print >> sys.stderr, ('Unable to get a list of packages ' print >> sys.stderr, ('Unable to get a list of packages '
'from the media: %s.\n' 'from the media: %s.\n'
'%s\n%s') % (media, urpmqf_out, urpmqf_err) '%s\n%s') % (media, urpmqf_out.decode('utf-8'), urpmqf_err.decode('utf-8'))
raise Exception('Unable to get a list of packages (%d).' % p.returncode) raise Exception('Unable to get a list of packages (%d).' % p.returncode)
rpm_list = [] rpm_list = []
@ -572,7 +572,7 @@ def get_urpmi(urpm_package, target_dir):
'from the media %s.\n' 'from the media %s.\n'
'%s\n%s') % ( '%s\n%s') % (
package_name, urlp.netloc, package_name, urlp.netloc,
urpmi_out, urpmi_err) urpmi_out.decode('utf-8'), urpmi_err.decode('utf-8'))
raise Exception('Unable to get the package %s (%d).' % raise Exception('Unable to get the package %s (%d).' %
(package_name, p.returncode)) (package_name, p.returncode))