diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | sos/policies/__init__.py | 6 | ||||
-rw-r--r-- | sos/policies/debian.py | 4 | ||||
-rw-r--r-- | sos/policies/windows.py | 10 | ||||
-rw-r--r-- | sos/utilities.py | 2 |
5 files changed, 17 insertions, 6 deletions
@@ -7,3 +7,4 @@ tags buildjar/ gpgkeys/rhsupport.* rpm-build/* +sos/__init__.py diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index a2234016..7e49b9a3 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -24,8 +24,10 @@ def load(cache={}): for policy in import_policy(module): if policy.check(): cache['policy'] = policy() - return policy() - return GenericPolicy() + else: + cache['policy'] = GenericPolicy() + + return cache['policy'] class PackageManager(object): diff --git a/sos/policies/debian.py b/sos/policies/debian.py index 77a5487c..6d11482d 100644 --- a/sos/policies/debian.py +++ b/sos/policies/debian.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + from sos import _sos as _ from sos.plugins import DebianPlugin, IndependentPlugin from sos.policies import PackageManager, Policy @@ -45,7 +47,7 @@ class DebianPackageManager(PackageManager): version, release, arch = fields[-3:] name = "-".join(fields[:-3]) return (name, version, release, arch) - + class DebianPolicy(Policy): def __init__(self): super(DebianPolicy, self).__init__() diff --git a/sos/policies/windows.py b/sos/policies/windows.py index 64e780bf..abb46494 100644 --- a/sos/policies/windows.py +++ b/sos/policies/windows.py @@ -13,6 +13,7 @@ ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import os import time +import platform from sos.policies import PackageManager, Policy from sos.utilities import shell_out @@ -23,10 +24,13 @@ class WindowsPolicy(Policy): @classmethod def check(class_): + is_windows = False try: - return "Windows" in shell_out("ver") - except Exception, e: - return False + from java.lang import System + is_windows = "win" in System.getProperty('os.name').lower() + except: + is_windows = "win" in platform.system().lower() + return is_windows def is_root(self): if "S-1-16-12288" in shell_out("whoami /groups"): diff --git a/sos/utilities.py b/sos/utilities.py index 015c6c8e..55fab228 100644 --- a/sos/utilities.py +++ b/sos/utilities.py @@ -217,6 +217,8 @@ class ImporterHelper(object): try: path_to_zip, tail = self._get_path_to_zip(path) zf = zipfile.ZipFile(path_to_zip) + # the path will have os separators, but the zipfile will always have '/' + tail = tail.replace(os.path.sep, "/") root_names = [name for name in zf.namelist() if tail in name] candidates = self._get_plugins_from_list(root_names) zf.close() |