Use "platform" module instead of os.uname, or -- even worse -- a system
authorZac Medico <zmedico@gentoo.org>
Wed, 4 Jun 2008 03:47:56 +0000 (03:47 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 4 Jun 2008 03:47:56 +0000 (03:47 -0000)
call to uname.  Change repoman's identification string not to use
"processor" on Linux (where it is huge), Interix (where it doesn't
exist) and AIX/HP-UX (where it prints "unknown"), but "machine" instead.
(branches/prefix r10554)

svn path=/main/trunk/; revision=10574

bin/repoman
pym/portage/__init__.py
pym/portage/data.py

index 7f381da942923c683e493cb72db904dbd95271af..cf8047eaf10ed0ba9b6ee5f77d0e6b863c3c3321 100755 (executable)
@@ -20,6 +20,7 @@ import stat
 import sys
 import tempfile
 import time
+import platform
 
 from itertools import izip
 from stat import S_ISDIR, ST_CTIME
@@ -1754,7 +1755,11 @@ else:
                sys.stderr.write("Failed to insert portage version in message!\n")
                sys.stderr.flush()
                portage_version = "Unknown"
-       unameout = commands.getstatusoutput("uname -srp")[1]
+       unameout = platform.system() + " " + platform.release() + " "
+       if platform.system() in ["Darwin", "SunOS"]:
+               unameout += platform.processor()
+       else:
+               unameout += platform.machine()
        commitmessage+="\n(Portage version: "+str(portage_version)+"/"+vcs+"/"+unameout
        if options.force:
                commitmessage += ", RepoMan options: --force"
index 3423ec241419afb72d08ec8f323efdcf7cca98f5..051d6dd4aee003b1fca860711ff979eea671ce82 100644 (file)
@@ -29,6 +29,7 @@ try:
        from random import shuffle
        import UserDict
        from itertools import chain, izip
+       import platform
 except ImportError, e:
        sys.stderr.write("\n\n")
        sys.stderr.write("!!! Failed to complete python imports. These are internal modules for\n")
@@ -41,7 +42,7 @@ except ImportError, e:
        raise
 
 bsd_chflags = None
-if os.uname()[0] in ["FreeBSD"]:
+if platform.system() in ["FreeBSD"]:
        def bsd_chflags():
                pass
        def _chflags(path, flags, opts=""):
index 5fc811e43d356d7f4122de21be3212d4bb5cebeb..5f4d056300e264ba1098bb995173d87fcf5f6e40 100644 (file)
@@ -3,13 +3,13 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import os, sys, pwd, grp
+import os, sys, pwd, grp, platform
 from portage.util import writemsg
 from portage.output import green,red
 from portage.output import create_color_func
 bad = create_color_func("BAD")
 
-ostype=os.uname()[0]
+ostype=platform.system()
 userland = None
 if ostype == "DragonFly" or ostype.endswith("BSD"):
        userland = "BSD"