[yum-git] yum-builddep.py

Seth Vidal skvidal at linux.duke.edu
Mon Sep 15 12:25:56 UTC 2008


 yum-builddep.py |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

New commits:
commit af6518377b0fcb2ed9a7918d55ef8fa1a913470c
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Mon Sep 15 08:25:02 2008 -0400

    add all the crazy locale code from yum-complete-transaction to yum-build-dep
    so our confirmation can work on non-C and on-US locales.

diff --git a/yum-builddep.py b/yum-builddep.py
index f7425c7..ea570c7 100755
--- a/yum-builddep.py
+++ b/yum-builddep.py
@@ -139,6 +139,22 @@ class YumBuildDep(YumUtilBase):
     
     
 if __name__ == '__main__':
+    import locale
+    # This test needs to be before locale.getpreferredencoding() as that
+    # does setlocale(LC_CTYPE, "")
+    try:
+        locale.setlocale(locale.LC_ALL, '')
+    except locale.Error, e:
+        # default to C locale if we get a failure.
+        print >> sys.stderr, 'Failed to set locale, defaulting to C'
+        os.environ['LC_ALL'] = 'C'
+        locale.setlocale(locale.LC_ALL, 'C')
+        
+    if True: # not sys.stdout.isatty():
+        import codecs
+        sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
+        sys.stdout.errors = 'replace'
+
     util = YumBuildDep()
         
        



More information about the Yum-cvs-commits mailing list