Patch for unicode error messages
by Felix Schwarz
Hi,
when I tried to build a custom live cd I noticed some problems in the error
reporting when there were unicode error messages (e.g. some dependency was
missing).
Example:
...
> anaconda-11.4.1.63-1.i386 von updates hat Abhängigkeitsauflöse-Probleme
> --> Fehlende Abhängigkeit: booty wird benötigt von Paket anaconda-11.4.1.63-1.i386 (updates)
> Traceback (most recent call last):
> File "./tools/livecd-creator", line 140, in <module>
> sys.exit(main())
> File "./tools/livecd-creator", line 132, in main
> logging.error("Error creating Live CD : %s" % e)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 42: ordinal not in range(128)
My patch ensures that unicode error messages can be printed correctly every
time. To get 100% unicode support, one should go through all log calls and
ensure that all strings are unicode so that localized error messages are
always shown correctly.
With my patch, there should be no unicode exceptions anymore, even when the
error message may be printed as 'Fehlende Abh\xe4ngigkeit' instead of
'Fehlende Abhängigkeit' (notice the '\xe4' in the first string).
fs
diff --git a/imgcreate/errors.py b/imgcreate/errors.py
index ba08563..071d4b8 100644
--- a/imgcreate/errors.py
+++ b/imgcreate/errors.py
@@ -20,6 +20,29 @@ class CreatorError(Exception):
"""An exception base class for all imgcreate errors."""
def __init__(self, msg):
Exception.__init__(self, msg)
+
+ # Some error messages may contain unicode strings (especially if your system
+ # locale is different from 'C', e.g. 'de_DE'). Python's exception class does
+ # not handle this appropriately (at least until 2.5) because str(Exception)
+ # returns just self.message without ensuring that all characters can be
+ # represented using ASCII. So we try to return a str and fall back to repr
+ # if this does not work.
+ #
+ # Please use unicode for your error logging strings so that we can really
+ # print nice error messages, e.g.:
+ # log.error(u"Internal error: " % e)
+ # instead of
+ # log.error("Internal error: " % e)
+ # With our custom __str__ and __unicode__ methods both will work but the
+ # first log call print a more readable error message.
+ def __str__(self):
+ try:
+ return str(self.message)
+ except UnicodeEncodeError:
+ return repr(self.message)
+
+ def __unicode__(self):
+ return unicode(self.message)
class KickstartError(CreatorError):
pass
diff --git a/tools/livecd-creator b/tools/livecd-creator
index 1aab882..39f7478 100755
--- a/tools/livecd-creator
+++ b/tools/livecd-creator
@@ -129,7 +129,7 @@ def main():
creator.unmount()
creator.package()
except imgcreate.CreatorError, e:
- logging.error("Error creating Live CD : %s" % e)
+ logging.error(u"Error creating Live CD : %s" % e)
return 1
finally:
creator.cleanup()
15 years, 1 month
Re: Fedora-livecd-list Digest, Vol 46, Issue 3
by himanshu lad
guys I need to carry both 32 and 64 bit versions of Fedora electronics lab
for my friends and faculty. It would be better to have both in one dvd for
ease.Besides I it would help in reducing e-waste in long run i.e. less dvds
to burn lesser the e-waste.
Thanks
OPENFREAK
15 years, 1 month
livecd-create Bootable Fedora LiveCD Failed in Fedora 10
by Dino Lopez
I try to create a Bootable Fedora LiveCD but it Failed in Fedora 10
Fedora_Minimal.ks
####################
lang en_US.UTF-8
keyboard us
timezone US/Central
auth --useshadow --enablemd5
selinux --permissive
firewall --disabled
part / --size 1024
repo --name=development --mirrorlist=http://mirrors.fedoraproject.org/
mirrorlist?repo=rawhide&arch=$basearch
%packages
@core
bash
kernel
passwd
policycoreutils
chkconfig
authconfig
rootfiles
/usr/sbin/lokkit
%end
####################
livecd-creator --config=./Fedora_Minimal.ks --fslabel=Your_Distro
if you don't add the line: /usr/sbin/lokkit will stop with error !!!,
once you add the line wait until the process finish...
After the iso image gets generated the following message appear :
Error on boot:
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
Bug in initramfs /init detected. Dropping to a shell. Good luck!
bash: no job control in this shell
bash-4.0#
I really like to see a way to create your own custom Fedora Minimal
LIveCD or USB.
Maybe add the option to boot in about 5 seconds like reported at:
http://lwn.net/Articles/299483/
And why not to handle the awesome speed & compression from:
http://www.slax.org/
Seems like Build aufs kernel module and squashfs kernel module
(optionally patched to support LZMA) is the way to go.
If somebody have some ideas will be really appreciated...
Dinooz
15 years, 1 month
Re: [Fedora-livecd-list] Working to support multiple images from amedium
by Kam Salisbury
--snip
What do people think? Is this worth doing? Other ideas on
implementation? Anyone want to start whipping up any patches?
Jeremy
I feel we could do a better job documenting what is possible with the live image and its configuration. Having the procedures for implementing a multi-image flash drive available is better than changing how the live image works.
For example, just send me your process for a multi-image Fedora Live flash drive and I will find a place for it in the wiki and write the beats for it for F11.
--
Kam
http://kamsalisbury.com
GPG key: FAF1751E
15 years, 1 month
Working to support multiple images from a medium
by Jeremy Katz
It keeps coming up that people would like to support multiple live
images running off the same USB stick/hard drive/$arbitrary medium and
so it's probably worth considering some of the ways that it could
possibly be supported. Also, for the personal reason, it would make it
easier for me to effectively use my netbook with the super-slow SSD if I
just put a new rawhide live image on it regularly and keep my homedir on
the (faster) SD card :-)
Breaking it down into components, I think there are a few things which
we have to worry about
0) Where to put things on the disk. The more I think about it, the more
I think that having "everything" for one image (including the bootloader
bits) will be easiest. The part we had talked about last about using
the iso label for namespacing seems to make reasonable sense
1) Boot loader config
There are a couple of possibilities here... the simplest would just be
that we edit the syslinux.cfg and append more entries. A little bit
more complicated would be to just have a simple "top-level" syslinux.cfg
which uses CONFIG directives to load the additional config files. Third
would be a com32 module to iterate and set up the menu items
automatically. I lean towards the second, at least for at first.
2) How to know the new directory
There are multiple places scattered that have hard-coded looking for
LiveOS. There's the initrd, there's the livesys initscript and there's
livecd-iso-to-disk/liveusb-creator. While we could add a kernel command
line option[1] and go and change each of these to set it/respect it, it
feels like maybe the less general solution. Maybe it's just that we
should always have livelabel= available so that we can use it other
places ? I don't know. Open to other thoughts and suggestions.
What do people think? Is this worth doing? Other ideas on
implementation? Anyone want to start whipping up any patches?
Jeremy
[1] Till Maas sent a patch along these lines back in November and I've
kept meaning to get back to it. So consider this doing so :)
15 years, 1 month