From dd9410e47fa583581477af506a4dd1ffa841f623 Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Wed, 2 Jun 2010 17:21:57 +0200 Subject: [PATCH] Changes for Windows compatibility - Replaced os.uname() with platform.uname() - Replaced locale.LC_MESSAGES with locale.LC_ALL --- tests/basetest.py | 2 +- zeroinstall/injector/arch.py | 2 ++ zeroinstall/injector/distro.py | 4 ++-- zeroinstall/injector/model.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/basetest.py b/tests/basetest.py index be99f4e..8f4c3f9 100755 --- a/tests/basetest.py +++ b/tests/basetest.py @@ -36,7 +36,7 @@ os.execvp = test_execvp test_locale = (None, None) assert model.locale class TestLocale: - LC_MESSAGES = 0 + LC_ALL = 0 # Note: LC_MESSAGES not present on Windows def getlocale(self, x): return test_locale model.locale = TestLocale() diff --git a/zeroinstall/injector/arch.py b/zeroinstall/injector/arch.py index 3e23060..ec82ba5 100644 --- a/zeroinstall/injector/arch.py +++ b/zeroinstall/injector/arch.py @@ -20,6 +20,8 @@ better, Unsupported architectures are not listed at all. from zeroinstall import _ import os +# TODO: "import platform"? + # os_ranks and mapping are mappings from names to how good they are. # 1 => Native (best) # Higher numbers are worse but usable. diff --git a/zeroinstall/injector/distro.py b/zeroinstall/injector/distro.py index e6f92fd..8e0f857 100644 --- a/zeroinstall/injector/distro.py +++ b/zeroinstall/injector/distro.py @@ -7,7 +7,7 @@ Integration with native distribution package managers. # See the README file for details, or visit http://0install.net. from zeroinstall import _ -import os, re, glob, subprocess, sys +import os, platform, re, glob, subprocess, sys from logging import warn, info from zeroinstall.injector import namespaces, model, arch from zeroinstall.support import basedir @@ -259,7 +259,7 @@ _canonical_machine = { 'ppc': 'ppc', } -host_machine = arch.canonicalize_machine(os.uname()[-1]) +host_machine = arch.canonicalize_machine(platform.uname()[4]) def canonical_machine(package_machine): machine = _canonical_machine.get(package_machine, None) if machine is None: diff --git a/zeroinstall/injector/model.py b/zeroinstall/injector/model.py index b469c78..e5dd5aa 100644 --- a/zeroinstall/injector/model.py +++ b/zeroinstall/injector/model.py @@ -69,7 +69,7 @@ def _join_arch(osys, machine): return "%s-%s" % (osys or '*', machine or '*') def _best_language_match(options): - (language, encoding) = locale.getlocale(locale.LC_MESSAGES) + (language, encoding) = locale.getlocale(locale.LC_ALL) return (options.get(language, None) or options.get(language.split('_', 1)[0], None) or options.get(None, None)) -- 2.11.4.GIT