[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Replacing os.uname() calls with platform.system()



commit 0354e9e656655f33c04fd75ebcb45ff0f70959c6
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Apr 8 14:03:55 2012 -0700

    Replacing os.uname() calls with platform.system()
    
    I was doing os detection by calling 'os.uname()' which has the unfortunate
    disadvantage of not functioning in Windows. The 'platform.system()' apparently
    does the same for our purposes but... well, works.
    
    Caught thanks to reganeet on...
    https://trac.torproject.org/projects/tor/ticket/5493
---
 stem/util/proc.py   |    3 ++-
 stem/util/system.py |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/stem/util/proc.py b/stem/util/proc.py
index e8e253d..7cf12bf 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -27,6 +27,7 @@ import sys
 import time
 import socket
 import base64
+import platform
 
 import stem.util.enum
 import stem.util.log as log
@@ -53,7 +54,7 @@ def is_available():
   global IS_PROC_AVAILABLE
   
   if IS_PROC_AVAILABLE == None:
-    if os.uname()[0] != "Linux":
+    if platform.system() != "Linux":
       IS_PROC_AVAILABLE = False
     else:
       # list of process independent proc paths we use
diff --git a/stem/util/system.py b/stem/util/system.py
index f8f128a..f54e346 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -54,7 +54,7 @@ def is_bsd():
     bool to indicate if we're a BSD OS
   """
   
-  return os.uname()[0] in ("Darwin", "FreeBSD", "OpenBSD")
+  return platform.system() in ("Darwin", "FreeBSD", "OpenBSD")
 
 def is_available(command, cached=True):
   """
@@ -481,7 +481,7 @@ def get_bsd_jail_id(pid):
     jid = ps_output[1].strip()
     if jid.isdigit(): return int(jid)
   
-  os_name = os.uname()[0]
+  os_name = platform.system()
   if os_name == "FreeBSD":
     log.warn("Unable to get the jail id for process %s." % pid)
   else:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits