Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling detection of Windows OS #34

Merged
merged 1 commit into from
Mar 25, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/rospkg/os_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand All @@ -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__':
Expand Down