From 0e0beab150db6bd0354df9e9630c6d1535f95627 Mon Sep 17 00:00:00 2001 From: Yeong-il Choe Date: Mon, 25 Mar 2013 09:45:38 +0900 Subject: [PATCH] Added Windows class to enable detecting Windows OS --- src/rospkg/os_detect.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/rospkg/os_detect.py b/src/rospkg/os_detect.py index c42b8426..2bdb2db1 100644 --- a/src/rospkg/os_detect.py +++ b/src/rospkg/os_detect.py @@ -335,6 +335,23 @@ def get_codename(self): return '' raise OsNotDetected('called in incorrect OS') +class Windows(OsDetector): + """ + Detect Windows OS. + """ + def is_os(self): + return platform.system() == "Windows" + + def get_version(self): + if self.is_os(): + return platform.version() + raise OsNotDetected('called in incorrect OS') + + def get_codename(self): + if self.is_os(): + return platform.release() + raise OsNotDetected('called in incorrect OS') + class OsDetect: """ This class will iterate over registered classes to lookup the @@ -454,6 +471,7 @@ def get_codename(self): OS_OSX='osx' OS_RHEL='rhel' OS_UBUNTU='ubuntu' +OS_WINDOWS='windows' OsDetect.register_default(OS_ARCH, Arch()) OsDetect.register_default(OS_CYGWIN, Cygwin()) @@ -466,6 +484,7 @@ def get_codename(self): OsDetect.register_default(OS_OSX, OSX()) OsDetect.register_default(OS_RHEL, Rhel()) OsDetect.register_default(OS_UBUNTU, LsbDetect("Ubuntu")) +OsDetect.register_default(OS_WINDOWS, Windows()) if __name__ == '__main__':