diff options
author | fujiwarat <takao.fujiwara1@gmail.com> | 2014-01-06 16:22:25 +0900 |
---|---|---|
committer | fujiwarat <takao.fujiwara1@gmail.com> | 2014-01-06 16:22:25 +0900 |
commit | 85330465240ba6a028c92290d74ef05dcb5d7cb9 (patch) | |
tree | 3ddbb6743ed49f534ebe70827533a2573efc25e4 /setup | |
parent | 9932e3920f19d78e5bfb5a357590e3e6893b24a9 (diff) | |
download | ibus-anthy-85330465240ba6a028c92290d74ef05dcb5d7cb9.tar.gz |
Fixed IOError in print sys.stderr when the parent process exits.
Diffstat (limited to 'setup')
-rw-r--r-- | setup/prefs.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/setup/prefs.py b/setup/prefs.py index ebbe116..1b88908 100644 --- a/setup/prefs.py +++ b/setup/prefs.py @@ -46,8 +46,8 @@ class Prefs(object): if self._config != None: self.__has_config_get_values = hasattr(self._config, 'get_values') else: - print >> sys.stderr, \ - 'ibus-config is not running or bus address is not correct.' + self.printerr( + 'ibus-config is not running or bus address is not correct.') def __log_handler(self, domain, level, message, data): if not data: @@ -71,7 +71,7 @@ class Prefs(object): # it returned the tuple of (strv, length) return variant.unpack() else: - print >> sys.stderr, 'Unknown variant type:', type_string + self.printerr('Unknown variant type:', type_string) sys.abrt() return variant @@ -207,7 +207,7 @@ class Prefs(object): elif type(v) == list: variant = GLib.Variant.new_strv(v) if variant == None: - print >> sys.stderr, 'Unknown value type:', type(v) + self.printerr('Unknown value type:', type(v)) sys.abrt() if self._config != None: self._config.set_value(s, key, variant) @@ -267,3 +267,11 @@ class Prefs(object): return string return unicode(string, 'utf-8') + # If the parent process exited, the std io/out/error will be lost. + @staticmethod + def printerr(sentence): + try: + print >> sys.stderr, sentence + except IOError: + pass + |