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
Add class for windows version checking #210
Add class for windows version checking #210
Conversation
Adds a simple way to grab the windows version. eg.WindowsVersion.IsXp() eg.WindowsVersion.IsVista() eg.WindowsVersion.Is7() eg.WindowsVersion.is8() eg.WindowsVersion.Is10() This is going to be used by the Systemn.PowerBroadcastNotifier and also System.DeviceChangeNotifier (if the PR for the latter gets accepted)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of formatting changes. And constructing the WindowsVersion object. But it runs perfect as far as i can tell. sweet upgrade 👍 👏
eg/Classes/WindowsVersion.py
Outdated
|
||
def __eq__(self, other): | ||
self.check_os_value(other) | ||
return getattr(self, 'Is'+other)() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
return getattr(self, 'Is' + other)()
eg/Classes/WindowsVersion.py
Outdated
def __gt__(self, other): | ||
self.check_os_value(other) | ||
if other == 'XP': | ||
return self.THIS >self. WIN_XP32 and self.THIS >self. WIN_XP64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
return self.THIS > self.WIN_XP32 and self.THIS > self.WIN_XP64
eg/Classes/WindowsVersion.py
Outdated
if other == 'XP': | ||
return self.THIS >self. WIN_XP32 and self.THIS >self. WIN_XP64 | ||
if other == '8': | ||
return self.THIS >self. WIN_80 and self.THIS >self. WIN_81 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
return self.THIS > self.WIN_80 and self.THIS > self.WIN_81
eg/Classes/WindowsVersion.py
Outdated
def __lt__(self, other): | ||
self.check_os_value(other) | ||
if other == 'XP': | ||
return self.THIS <self. WIN_XP32 and self.THIS <self. WIN_XP64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
return self.THIS < self.WIN_XP32 and self.THIS < self.WIN_XP64
eg/Classes/WindowsVersion.py
Outdated
if other == 'XP': | ||
return self.THIS <self. WIN_XP32 and self.THIS <self. WIN_XP64 | ||
if other == '8': | ||
return self.THIS <self. WIN_80 and self.THIS <self. WIN_81 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
return self.THIS < self.WIN_80 and self.THIS < self.WIN_81
eg/Classes/WindowsVersion.py
Outdated
:return: Bool | ||
""" | ||
return ( | ||
self.THIS == self. WIN_80 or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
self.THIS == self.WIN_80 or
eg/Classes/WindowsVersion.py
Outdated
""" | ||
return ( | ||
self.THIS == self. WIN_80 or | ||
self.THIS == self. WIN_81 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
self.THIS == self.WIN_81
eg/Classes/WindowsVersion.py
Outdated
|
||
:return: Bool | ||
""" | ||
return self.THIS == self. WIN_80 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
return self.THIS == self.WIN_80
eg/Classes/WindowsVersion.py
Outdated
|
||
:return: Bool | ||
""" | ||
return self.THIS == self. WIN_81 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
return self.THIS == self.WIN_81
eg/Classes/WindowsVersion.py
Outdated
|
||
:return: Bool | ||
""" | ||
return self.THIS == self. WIN_10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting:
return self.THIS == self.WIN_10
Construct WindowsVersion
WindowsVersion = WindowsVersion()
I made some changes and and did a commit to my PR of this. it only has one issue with a docstring. and not sure as to how to clean that up to make it green. but take a look see if it's something you like then keep it. if not no worries.. the one i did also doesn't care if you do
instead of
|
b7a572d
to
da362de
Compare
the only thing i see which i do not understand is this
But i am thinking it has something to do with the build process and the docs. you could do from Classes.WindowsVersion import WindowsVersion and this can be placed in the eg_init_.py file at the top. only if you aren't using
at the module level but i am thinking that maybe some adjustment to the doc creation in the build process is really what is needed, |
eg/Classes/WindowsVersion.py
Outdated
| | Windows Media Center Edition 2004, | | ||
| | Windows Media Center Edition 2005 | | ||
+-----------+------------------------------------+ | ||
| ``XP64`` | Windows Server 2003, | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to add a line in here
| | Windows XP Professional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also not sure how you want to handle the Windows 2003 R2
you can Either change it to read Windows Server 2003 R2
or remove it since all R2 is, is a repackaged Server 2003 with SP1 slip streamed..
so technically it is Server 2003 SP1
does doing the import in the init take care of satisfying the building of the docs?? It's a step in the right direction for getting rid of the dynamic module. and it will also make IDE's happy |
Yes, it works. At the first steps i wasn't able to get class docs into the help file. I used |
i'm good to go.. it looks great! I know it was something simple turned into an animal LOL but it helped us to get a system together for what i think should be a model for new additions to EG. |
and i personally do not understand the eg.ActionClass eg.ActionBase thing.. I believe that was done for backwards compatibility with an earlier version of EG and eg.ActionClass was supposed to be depreciated.. but it didn't happen same goes for eg.PluginClass |
Reworked the compare functions (based on kdschlosser's idea) added more docstrings and layout the class docstring. added the class to help file (Developer documentation -> The eg module)
only show deprecation warning for eg
replace `eg.Utils.IsXP()` with `eg.WindowsVersion.IsXP()`
b4f061a
to
e6668da
Compare
replaces #208
based on the idea from @kdschlosser, extended to a class with compare functions.
Check for a specific Windows version:
eg.WindowsVersion.IsVista()
oreg.WindowsVersion == "Vista"
Check for a minimum Windows version:
eg.WindowsVersion >= "Vista"
Notice for plugin developers:
eg.Utils.IsXP()
andeg.Utils.IsVista()
are now deprecated.Functions:
Comparison: