Bug#789277: UnicodeEncodeError: 'ascii' codec can't encode character...

2015-06-24 Thread Antoine Beaupré
Package: unattended-upgrades
Version: 0.83.3.1
Followup-For: Bug #789277

... and that doesn't work either. the problem is that the logging
library is called regardless of whether emails are enabled.

I can think of two more workarounds:

diff --git a/cron.daily/apt b/cron.daily/apt
index ee0761b..eef6dcb 100755
--- a/cron.daily/apt
+++ b/cron.daily/apt
@@ -475,7 +475,7 @@ fi
 # auto upgrade all upgradeable packages
 UPGRADE_STAMP=/var/lib/apt/periodic/upgrade-stamp
 if which unattended-upgrade /dev/null  check_stamp $UPGRADE_STAMP 
$UnattendedUpgradeInterval; then
-if unattended-upgrade $XUUPOPT; then
+if env LC_ALL=C LANG=C LANGUAGE=C unattended-upgrade $XUUPOPT; then
update_stamp $UPGRADE_STAMP
debug_echo unattended-upgrade (success)
 else

So that works. But it's only a workaround as it breaks
translations. It seems to me this package shouldn't break if trying to
do translations.

The other thing i can think of is patching unattended-upgrades to use
lgettext instead of gettext. I came up with this patch, which seems to
work okay:

diff --git a/unattended-upgrade b/unattended-upgrade
index 0205897..429bb38 100755
--- a/unattended-upgrade
+++ b/unattended-upgrade
@@ -41,7 +41,7 @@ import sys
 
 
 from email.message import Message
-from gettext import gettext as _
+from gettext import lgettext as _
 from io import StringIO
 from optparse import (
 OptionParser,
@@ -1052,7 +1052,7 @@ def main(options, rootdir=):
 logging.info(_(Starting unattended upgrades script))
 
 # display available origin
-logging.info(_(Allowed origins are: %s) % allowed_origins)
+logging.info(_(Allowed origins are: %s), allowed_origins)
 
 # check if the journal is dirty and if so, take emergceny action
 # the alternative is to leave the system potentially unsecure until

I sent this as a pull request upstream:

https://github.com/mvo5/unattended-upgrades/pull/10

Hopefully this can land in a jessie update?

-- System Information:
Debian Release: 8.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages unattended-upgrades depends on:
ii  apt1.0.9.8
ii  apt-utils  1.0.9.8
ii  debconf [debconf-2.0]  1.5.56
ii  init-system-helpers1.22
ii  lsb-base   4.1+Debian13+nmu1
ii  lsb-release4.1+Debian13+nmu1
ii  python33.4.2-2
ii  python3-apt0.9.3.11
ii  ucf3.0030
ii  xz-utils   5.1.1alpha+20120614-2+b3

unattended-upgrades recommends no packages.

Versions of packages unattended-upgrades suggests:
ii  bsd-mailx   8.1.2-0.20141216cvs-2
ii  postfix [mail-transport-agent]  2.11.3-1

-- Configuration Files:
/etc/apt/apt.conf.d/50unattended-upgrades changed [not included]

-- debconf information excluded


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#789277: UnicodeEncodeError: 'ascii' codec can't encode character...

2015-06-23 Thread Antoine Beaupré
Package: unattended-upgrades
Version: 0.83.3.1
Followup-For: Bug #789277

In fact, that workaround doesn't work. I'm trying to disable mails
completely:

Unattended-Upgrade::Mail ;

a.

-- System Information:
Debian Release: 8.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages unattended-upgrades depends on:
ii  apt1.0.9.8
ii  apt-utils  1.0.9.8
ii  debconf [debconf-2.0]  1.5.56
ii  init-system-helpers1.22
ii  lsb-base   4.1+Debian13+nmu1
ii  lsb-release4.1+Debian13+nmu1
ii  python33.4.2-2
ii  python3-apt0.9.3.11
ii  ucf3.0030
ii  xz-utils   5.1.1alpha+20120614-2+b3

unattended-upgrades recommends no packages.

Versions of packages unattended-upgrades suggests:
ii  bsd-mailx   8.1.2-0.20141216cvs-2
ii  postfix [mail-transport-agent]  2.11.3-1

-- Configuration Files:
/etc/apt/apt.conf.d/50unattended-upgrades changed [not included]

-- debconf information excluded


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#789277: UnicodeEncodeError: 'ascii' codec can't encode character...

2015-06-19 Thread Antoine Beaupré
Package: unattended-upgrades
Version: 0.83.3.1
Severity: important

I got this in my cron job email when running the first time:

--- Logging error ---
Traceback (most recent call last):
  File /usr/lib/python3.4/logging/__init__.py, line 980, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 68: 
ordinal not in range(128)
Call stack:
  File /usr/bin/unattended-upgrade, line 1321, in module
main(options)
  File /usr/bin/unattended-upgrade, line 1045, in main
 .join(blacklisted_pkgs))
Message: 'Paquets initialement sur la liste noire\xa0: %s'
Arguments: ('',)
--- Logging error ---
Traceback (most recent call last):
  File /usr/lib/python3.4/logging/__init__.py, line 980, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 30: 
ordinal not in range(128)
Call stack:
  File /usr/bin/unattended-upgrade, line 1321, in module
main(options)
  File /usr/bin/unattended-upgrade, line 1052, in main
logging.info(_(Starting unattended upgrades script))
Message: 'D\xe9marrage du script de mise \xe0 niveau automatique'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
  File /usr/lib/python3.4/logging/__init__.py, line 980, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xa0' in position 55: 
ordinal not in range(128)
Call stack:
  File /usr/bin/unattended-upgrade, line 1321, in module
main(options)
  File /usr/bin/unattended-upgrade, line 1055, in main
logging.info(_(Allowed origins are: %s) % allowed_origins)
Message: Les origines permises sont\xa0: 
['origin=Debian,codename=jessie,label=Debian-Security']
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
  File /usr/lib/python3.4/logging/__init__.py, line 980, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe0' in position 42: 
ordinal not in range(128)
Call stack:
  File /usr/bin/unattended-upgrade, line 1321, in module
main(options)
  File /usr/bin/unattended-upgrade, line 1225, in main
logging.info(_(No packages found that can be upgraded unattended))
Message: 'Aucun paquet \xe0 mettre \xe0 niveau automatiquement'
Arguments: ()

Classic Python encoding problem... Solution:

https://stackoverflow.com/questions/492483/setting-the-correct-encoding-when-piping-stdout-in-python

Workaround, reduce the verbosity:

Unattended-Upgrade::MailOnlyOnError true;

or disable emails completely:

Unattended-Upgrade::Mail ;

Another workaround would be to disable translations by changing the
default locale.

a.

-- System Information:
Debian Release: 8.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages unattended-upgrades depends on:
ii  apt1.0.9.8
ii  apt-utils  1.0.9.8
ii  debconf [debconf-2.0]  1.5.56
ii  init-system-helpers1.22
ii  lsb-base   4.1+Debian13+nmu1
ii  lsb-release4.1+Debian13+nmu1
ii  python33.4.2-2
ii  python3-apt0.9.3.11
ii  ucf3.0030
ii  xz-utils   5.1.1alpha+20120614-2+b3

unattended-upgrades recommends no packages.

Versions of packages unattended-upgrades suggests:
ii  bsd-mailx   8.1.2-0.20141216cvs-2
ii  postfix [mail-transport-agent]  2.11.3-1

-- Configuration Files:
/etc/apt/apt.conf.d/50unattended-upgrades changed:
// Unattended-Upgrade::Origins-Pattern controls which packages are
// upgraded.
//
// Lines below have the format format is keyword=value,  A
// package will be upgraded only if the values in its metadata match
// all the supplied keywords in a line.  (In other words, omitted
// keywords are wild cards.) The keywords originate from the Release
// file, but several aliases are accepted.  The accepted keywords are:
//   a,archive,suite (eg, stable)
//   c,component (eg, main, crontrib, non-free)
//   l,label (eg, Debian, Debian-Security)
//   o,origin(eg, Debian, Unofficial Multimedia Packages)
//   n,codename  (eg, jessie, jessie-updates)
// site  (eg, http.debian.net)
// The available values on the system are printed by the command
// apt-cache policy, and can be debugged by running
// unattended-upgrades -d and looking at the log file.
//
// Within lines unattended-upgrades allows 2 macros whose values are
// derived from /etc/debian_version:
//   ${distro_id}Installed origin.
//   ${distro_codename}  Installed codename (eg, jessie)
Unattended-Upgrade::Origins-Pattern {
// Codename based matching:
// This will follow the migration of a release through different
// archives (e.g. from testing to stable and later oldstable).
//