Python platform.win32_ver() Examples

The following are 30 code examples of platform.win32_ver(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module platform , or try the search function .
Example #1
Source File: __init__.py    From python-zulip-api with Apache License 2.0 6 votes vote down vote up
def get_user_agent(self) -> str:
        vendor = ''
        vendor_version = ''
        try:
            vendor = platform.system()
            vendor_version = platform.release()
        except OSError:
            # If the calling process is handling SIGCHLD, platform.system() can
            # fail with an IOError.  See http://bugs.python.org/issue9127
            pass

        if vendor == "Linux":
            vendor, vendor_version, dummy = distro.linux_distribution()
        elif vendor == "Windows":
            vendor_version = platform.win32_ver()[1]
        elif vendor == "Darwin":
            vendor_version = platform.mac_ver()[0]

        return "{client_name} ({vendor}; {vendor_version})".format(
            client_name=self.client_name,
            vendor=vendor,
            vendor_version=vendor_version,
        ) 
Example #2
Source File: cli.py    From numerai-cli with MIT License 6 votes vote down vote up
def is_win10_professional():
    name = sys.platform
    if name != 'win32':
        return False

    version = platform.win32_ver()[0]

    if version == '10':
        # for windows 10 only, we need to know if it's pro vs home
        import winreg
        with winreg.OpenKey(
                winreg.HKEY_LOCAL_MACHINE,
                r"SOFTWARE\Microsoft\Windows NT\CurrentVersion") as key:
            return winreg.QueryValueEx(key, "EditionID")[0] == 'Professional'

    return False 
Example #3
Source File: gyptest.py    From gyp with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def print_configuration_info():
  print('Test configuration:')
  if sys.platform == 'darwin':
    sys.path.append(os.path.abspath('test/lib'))
    import TestMac
    print('  Mac %s %s' % (platform.mac_ver()[0], platform.mac_ver()[2]))
    print('  Xcode %s' % TestMac.Xcode.Version())
  elif sys.platform == 'win32':
    sys.path.append(os.path.abspath('pylib'))
    import gyp.MSVSVersion
    print('  Win %s %s\n' % platform.win32_ver()[0:2])
    print('  MSVS %s' %
          gyp.MSVSVersion.SelectVisualStudioVersion().Description())
  elif sys.platform in ('linux', 'linux2'):
    print('  Linux %s' % ' '.join(platform.linux_distribution()))
  print('  Python %s' % platform.python_version())
  print('  PYTHONPATH=%s' % os.environ['PYTHONPATH'])
  print() 
Example #4
Source File: gyptest.py    From android-xmrig-miner with GNU General Public License v3.0 6 votes vote down vote up
def print_configuration_info():
  print('Test configuration:')
  if sys.platform == 'darwin':
    sys.path.append(os.path.abspath('test/lib'))
    import TestMac
    print('  Mac %s %s' % (platform.mac_ver()[0], platform.mac_ver()[2]))
    print('  Xcode %s' % TestMac.Xcode.Version())
  elif sys.platform == 'win32':
    sys.path.append(os.path.abspath('pylib'))
    import gyp.MSVSVersion
    print('  Win %s %s\n' % platform.win32_ver()[0:2])
    print('  MSVS %s' %
          gyp.MSVSVersion.SelectVisualStudioVersion().Description())
  elif sys.platform in ('linux', 'linux2'):
    print('  Linux %s' % ' '.join(platform.linux_distribution()))
  print('  Python %s' % platform.python_version())
  print('  PYTHONPATH=%s' % os.environ['PYTHONPATH'])
  print() 
Example #5
Source File: test_basic.py    From AutoWIG with Apache License 2.0 6 votes vote down vote up
def setUpClass(cls):
        if 'libclang' in autowig.parser:
            autowig.parser.plugin = 'libclang'
        autowig.generator.plugin = 'boost_python_internal'
        cls.srcdir = Path('fp17')
        cls.prefix = Path(Path(sys.prefix).abspath())
        if any(platform.win32_ver()):
            cls.prefix = cls.prefix/'Library'
        if not cls.srcdir.exists():
            Repo.clone_from('https://github.com/StatisKit/FP17.git', cls.srcdir.relpath('.'), recursive=True)
        if any(platform.win32_ver()):
            cls.scons = subprocess.check_output(['where', 'scons.bat']).strip()
        else:
            cls.scons = subprocess.check_output(['which', 'scons']).strip()
        if six.PY3:
            cls.scons = cls.scons.decode("ascii", "ignore")
        subprocess.check_output([cls.scons, 'cpp', '--prefix=' + str(cls.prefix)],
                                 cwd=cls.srcdir)
        cls.incdir = cls.prefix/'include'/'basic' 
Example #6
Source File: test_subset.py    From AutoWIG with Apache License 2.0 6 votes vote down vote up
def setUpClass(cls):
        if 'libclang' in autowig.parser:
            autowig.parser.plugin = 'libclang'
        cls.srcdir = Path('fp17')
        if not cls.srcdir.exists():
            Repo.clone_from('https://github.com/StatisKit/FP17.git', cls.srcdir.relpath('.'), recursive=True)
        cls.srcdir = cls.srcdir/'share'/'git'/'ClangLite'
        cls.incdir = Path(sys.prefix).abspath()
        if any(platform.win32_ver()):
            cls.incdir = cls.incdir/'Library'
        subprocess.check_output(['scons', 'cpp', '--prefix=' + str(cls.incdir)],
                                cwd=cls.srcdir)
        if any(platform.win32_ver()):
            cls.scons = subprocess.check_output(['where', 'scons.bat']).strip()
        else:
            cls.scons = subprocess.check_output(['which', 'scons']).strip()
        cls.incdir = cls.incdir/'include'/'clanglite' 
Example #7
Source File: telemetry.py    From review with Mozilla Public License 2.0 6 votes vote down vote up
def set_os(self):
        """Collect human readable information about the OS version.

        For Linux it is setting a distribution name and version.
        """
        system, node, release, version, machine, processor = platform.uname()
        if system == "Linux":
            distribution_name, distribution_number, _ = distro.linux_distribution(
                full_distribution_name=False
            )
            distribution_version = " ".join([distribution_name, distribution_number])
        elif system == "Windows":
            _release, distribution_version, _csd, _ptype = platform.win32_ver()
        elif system == "Darwin":
            distribution_version, _versioninfo, _machine = platform.mac_ver()
        else:
            distribution_version = release

        self.metrics.mozphab.environment.distribution_version.set(distribution_version) 
Example #8
Source File: gyptest.py    From gyp with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def print_configuration_info():
  print('Test configuration:')
  if sys.platform == 'darwin':
    sys.path.append(os.path.abspath('test/lib'))
    import TestMac
    print('  Mac %s %s' % (platform.mac_ver()[0], platform.mac_ver()[2]))
    print('  Xcode %s' % TestMac.Xcode.Version())
  elif sys.platform == 'win32':
    sys.path.append(os.path.abspath('pylib'))
    import gyp.MSVSVersion
    print('  Win %s %s\n' % platform.win32_ver()[0:2])
    print('  MSVS %s' %
          gyp.MSVSVersion.SelectVisualStudioVersion().Description())
  elif sys.platform in ('linux', 'linux2'):
    print('  Linux %s' % ' '.join(platform.linux_distribution()))
  print('  Python %s' % platform.python_version())
  print('  PYTHONPATH=%s' % os.environ['PYTHONPATH'])
  print() 
Example #9
Source File: common.py    From marsnake with GNU General Public License v3.0 6 votes vote down vote up
def get_distribution():

	if is_windows():
		if sys.version_info[0] == 2:
			import _winreg
		else:
			import winreg as _winreg

		reg_key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion")
		info = _winreg.QueryValueEx(reg_key, "ProductName")[0]

		if info:
			return info
		else:
			return "Windows {}".format(platform.win32_ver()[0])

	elif is_linux():
		from utils import lib
		return "{} {}".format(*(lib.detect_distribution()))

	elif is_darwin():
		return "MacOS X {}".format(platform.mac_ver()[0])

	return "" 
Example #10
Source File: implant.py    From stegator with MIT License 6 votes vote down vote up
def build(self):
        if (any(platform.win32_ver())):
            stroutput = self.remove_accents(self.output)
        else:
            stroutput = self.output

        cmd = {'sender': self.sender,
                'receiver': self.receiver,
                'output': stroutput,
                'cmd': self.cmd,
                'jobid': self.jobid}
        return base64.b64encode(json.dumps(cmd))


#------------------------------------------------------------------------------
# Class ChromePasswords
#------------------------------------------------------------------------------ 
Example #11
Source File: test_platform.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_win32_ver(self):
        res = platform.win32_ver() 
Example #12
Source File: test_platform.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_win32_ver(self):
        res = platform.win32_ver() 
Example #13
Source File: mediafoundation.py    From SoundCard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self):
        COINIT_MULTITHREADED = 0x0
        if platform.win32_ver()[0] == '8':
            # On Windows 8, according to Microsoft, the first use of 
            # IAudioClient should be from the STA thread. Calls from 
            # an MTA thread may result in undefined behavior.
            
            # CoInitialize initialises calling thread to STA.
            hr = _ole32.CoInitialize(_ffi.NULL)
        else:
            hr = _ole32.CoInitializeEx(_ffi.NULL, COINIT_MULTITHREADED)

        try:
            self.check_error(hr)

            # Flag to keep track if this class directly initialized
            # COM, required for un-initializing in destructor:
            self.com_loaded = True

        except RuntimeError as e:
            # Error 0x80010106
            RPC_E_CHANGED_MODE = 0x80010106
            if hr + 2 ** 32 == RPC_E_CHANGED_MODE:
                # COM was already initialized before (e.g. by the
                # debugger), therefore trying to initialize it again
                # fails we can safely ignore this error, but we have
                # to make sure that we don't try to unload it
                # afterwards therefore we set this flag to False:
                self.com_loaded = False
            else:
                raise e 
Example #14
Source File: platform.py    From artisan with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent = None, aw = None):
        super(platformDlg,self).__init__(parent, aw)
        self.setModal(True)
        self.setWindowTitle(QApplication.translate("Form Caption","Artisan Platform", None))
        platformdic = {}
        platformdic["Architecture"] = str(platform.architecture())
        platformdic["Machine"] = str(platform.machine())
        platformdic["Platform name"] =  str(platform.platform())
        platformdic["Processor"] = str(platform.processor())
        platformdic["Python Build"] = str(platform.python_build())
        platformdic["Python Compiler"] = str(platform.python_compiler())
        platformdic["Python Branch"] = str(platform.python_branch())
        platformdic["Python Implementation"] = str(platform.python_implementation())
        platformdic["Python Revision"] = str(platform.python_revision())
        platformdic["Release"] = str(platform.release())
        platformdic["System"] = str(platform.system())
        platformdic["Version"] = str(platform.version())
        platformdic["Python version"] = str(platform.python_version())
        system = str(platform.system())
        if system == "Windows":
            platformdic["Win32"] = str(platform.win32_ver())
        elif system == "Darwin":
            platformdic["Mac"] = str(platform.mac_ver())
        elif system == "Linux":
            platformdic["Linux"] = str(platform.linux_distribution())
            platformdic["Libc"] = str(platform.libc_ver())
        htmlplatform = "<b>version =</b> " + __version__ + " (" + __revision__ + ")<br>"
        for key in sorted(platformdic):
            htmlplatform += "<b>" + key + " = </b> <i>" + platformdic[key] + "</i><br>"
        platformEdit = QTextEdit()
        platformEdit.setHtml(htmlplatform)
        platformEdit.setReadOnly(True)
        layout = QVBoxLayout()
        layout.addWidget(platformEdit)
        self.setLayout(layout) 
Example #15
Source File: WindowsUtils.py    From ue4-docker with MIT License 5 votes vote down vote up
def isSupportedWindowsVersion():
		'''
		Verifies that the Windows host system meets our minimum Windows version requirements
		'''
		return semver.compare(platform.win32_ver()[1], WindowsUtils.minimumRequiredVersion()) >= 0 
Example #16
Source File: WindowsUtils.py    From ue4-docker with MIT License 5 votes vote down vote up
def getWindowsVersion():
		'''
		Returns the version information for the Windows host system as a semver instance
		'''
		return semver.parse(platform.win32_ver()[1]) 
Example #17
Source File: WindowsUtils.py    From ue4-docker with MIT License 5 votes vote down vote up
def getWindowsBuild():
		'''
		Returns the full Windows version number as a string, including the build number
		'''
		version = platform.win32_ver()[1]
		build = WindowsUtils._getVersionRegKey('BuildLabEx').split('.')[1]
		return '{}.{}'.format(version, build) 
Example #18
Source File: crash_report.py    From openxenmanager with GNU General Public License v2.0 5 votes vote down vote up
def capture_exception(self, exception, value, tb):
        if not RAVEN_AVAILABLE:
            return
        report_errors = True
        if report_errors:
            if self._client is None:
                self._client = raven.Client(CrashReport.DSN,
                                            release=__version__)

            tags = {"os:name": platform.system(),
                    "os:release": platform.release(),
                    "python:version": "{}.{}.{}".format(sys.version_info[0],
                                                    sys.version_info[1],
                                                    sys.version_info[2]),
                    "python:bit": struct.calcsize("P") * 8,
                    "python:encoding": sys.getdefaultencoding(),
                    "python:frozen": "{}".format(hasattr(sys, "frozen"))}

            if sys.platform == 'win32':
                tags['os:win32'] = " ".join(platform.win32_ver())
            elif sys.platform == 'darwin':
                tags['os:mac'] = "{} {}".format(platform.mac_ver()[0], platform.mac_ver()[2])
            else:
                tags['os:linux'] = " ".join(platform.linux_distribution())

            self._client.tags_context(tags)
            try:
                report = self._client.captureException((exception, value, tb))
            except Exception as e:
                log.error("Can't send crash report to Sentry: {}".format(e))
                return
            log.info("Crash report sent with event ID: {}".format(
                self._client.get_ident(report))) 
Example #19
Source File: verify-host-dlls.py    From ue4-docker with MIT License 5 votes vote down vote up
def getOsVersion():
	version = platform.win32_ver()[1]
	build = getVersionRegKey('BuildLabEx').split('.')[1]
	return '{}.{}'.format(version, build)

# Print the host and container OS build numbers 
Example #20
Source File: test_arg_parsing.py    From aws-encryption-sdk-cli with Apache License 2.0 5 votes vote down vote up
def patch_platform_win32_ver(mocker):
    mocker.patch.object(arg_parsing.platform, "win32_ver")
    return arg_parsing.platform.win32_ver 
Example #21
Source File: launch.py    From sumatra with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self, **kwargs):
        for k, v in kwargs.items():
            setattr(self, k, v)
    #platform.mac_ver()
    #platform.win32_ver()
    #platform.dist()
    #platform.libc_ver()
    # Python compile options? distutils.sys_config?
    # some numpy information?
    # numpy.distutils.system_info import get_info
    # get_info('blas_opt') 
Example #22
Source File: test_platform.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_win32_ver(self):
        res = platform.win32_ver() 
Example #23
Source File: __init__.py    From CanCat with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def getCurrentDef(normname):
    bname, wver, stuff, whichkern = platform.win32_ver()
    wvertup = wver.split('.')
    arch = envi.getCurrentArch()
    if isSysWow64():
        arch = 'wow64'

    modname = 'vstruct.defs.windows.win_%s_%s_%s.%s' % (wvertup[0], wvertup[1], arch, normname)

    try:
        mod = __import__(modname, {}, {}, 1)
    except ImportError, e:
        mod = None 
Example #24
Source File: test_platform.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_win32_ver(self):
        res = platform.win32_ver() 
Example #25
Source File: helpers.py    From Loki with GNU General Public License v3.0 5 votes vote down vote up
def getPlatformFull():
    type_info = ""
    try:
        type_info = "%s PROC: %s ARCH: %s" % ( " ".join(platform.win32_ver()), platform.processor(), " ".join(platform.architecture()))
    except Exception, e:
        type_info = " ".join(platform.win32_ver()) 
Example #26
Source File: test_platform.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_win32_ver(self):
        res = platform.win32_ver() 
Example #27
Source File: platform_.py    From keyring with MIT License 5 votes vote down vote up
def _data_root_Windows():
    release, version, csd, ptype = platform.win32_ver()
    root = _settings_root_XP() if release == 'XP' else _settings_root_Vista()
    return os.path.join(root, 'Python Keyring') 
Example #28
Source File: yarAnalyzer.py    From yarAnalyzer with MIT License 5 votes vote down vote up
def get_platform_full():
    type_info = ""
    try:
        type_info = "%s PROC: %s ARCH: %s" % ( " ".join(platform.win32_ver()), platform.processor(), " ".join(platform.architecture()))
    except Exception as e:
        type_info = " ".join(platform.win32_ver())
    return type_info 
Example #29
Source File: win.py    From luci-py with Apache License 2.0 5 votes vote down vote up
def get_os_version_names():
  """Returns the marketing/user-friendly names of the OS.

  The return value contains the base marketing name, e.g. Vista, 10, or
  2008Server. For Windows Server starting with 2016, this value is always
  "Server".

  For versions released before Windows 10, the return value also contains the
  name with the service pack, e.g. 7-SP1 or 2012ServerR2-SP0.

  For Windows 10 and Windows Server starting with 2016, the return value
  includes "10-" or "Server-" followed by one or more parts of the build number.
  E.g. for Windows 10 with build number 18362.207, the return value includes
  10-18362, 10-18362.207. For Windows Server 2019 with build number 17763.557,
  the return value includes Server-17763, Server-17763.557.
  """
  # Python keeps a local map in platform.py and it is updated at newer python
  # release. Since our python release is a bit old, do not rely on it.
  is_server = sys.getwindowsversion().product_type != 1
  lookup = _WIN32_SERVER_NAMES if is_server else _WIN32_CLIENT_NAMES
  version_number, build_number = _get_os_numbers()
  marketing_name = lookup.get(version_number, version_number)
  if version_number == u'10.0':
    rv = [marketing_name]
    # Windows 10 doesn't have service packs, the build number now is the
    # reference number. More discussion in
    # https://docs.google.com/document/d/1iF1tbc1oedCQ9J6aL7sHeuaayY3bs52fuvKxvLLZ0ig
    if '.' in build_number:
      major_version = build_number.split(u'.')[0]
      rv.append(u'%s-%s' % (marketing_name, major_version))
    rv.append(u'%s-%s' % (marketing_name, build_number))
    rv.sort()
    return rv
  service_pack = platform.win32_ver()[2] or u'SP0'
  return [marketing_name, u'%s-%s' % (marketing_name, service_pack)] 
Example #30
Source File: test_arg_parsing.py    From aws-encryption-sdk-cli with Apache License 2.0 5 votes vote down vote up
def test_f_comment_ignoring_argument_parser_convert_filename():
    # Actually checks against the current local system
    parser = arg_parsing.CommentIgnoringArgumentParser()

    if any(platform.win32_ver()):
        assert parser._CommentIgnoringArgumentParser__is_windows
        expected_transform = NON_POSIX_FILEPATH
    else:
        assert not parser._CommentIgnoringArgumentParser__is_windows
        expected_transform = POSIX_FILEPATH

    parsed_line = list(parser.convert_arg_line_to_args(expected_transform[0]))
    assert expected_transform[1] == parsed_line