当前位置: 首页>>代码示例>>Python>>正文


Python winreg.QueryValueEx方法代码示例

本文整理汇总了Python中six.moves.winreg.QueryValueEx方法的典型用法代码示例。如果您正苦于以下问题:Python winreg.QueryValueEx方法的具体用法?Python winreg.QueryValueEx怎么用?Python winreg.QueryValueEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves.winreg的用法示例。


在下文中一共展示了winreg.QueryValueEx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wait_for_boot_completion

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def wait_for_boot_completion(self):
        try:
            with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
                                "SYSTEM\\Setup\\Status\\SysprepStatus", 0,
                                winreg.KEY_READ) as key:
                while True:
                    gen_state = winreg.QueryValueEx(key,
                                                    "GeneralizationState")[0]
                    if gen_state == 7:
                        break
                    time.sleep(1)
                    LOG.info('Waiting for sysprep completion. '
                             'GeneralizationState: %d', gen_state)
        except WindowsError as ex:
            if ex.winerror == 2:
                LOG.debug('Sysprep data not found in the registry, '
                          'skipping sysprep completion check.')
            else:
                raise ex 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:21,代码来源:windows.py

示例2: _init_from_registry

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def _init_from_registry(cls):
        if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
            return
        from six.moves import winreg
        for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
            try:
                hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
                                        'Software\\Imagemagick\\Current',
                                        0, winreg.KEY_QUERY_VALUE | flag)
                binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
                winreg.CloseKey(hkey)
                binpath += '\\convert.exe'
                break
            except Exception:
                binpath = ''
        rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:18,代码来源:animation.py

示例3: get_value

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def get_value(key, value_name):
    try:
        return winreg.QueryValueEx(key, value_name)[0]
    except OSError:
        return None 
开发者ID:tox-dev,项目名称:tox,代码行数:7,代码来源:pep514.py

示例4: lookup

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def lookup(self, key, name):
        """
        Look for values in registry in Microsoft software registry.

        Parameters
        ----------
        key: str
            Registry key path where look.
        name: str
            Value name to find.

        Return
        ------
        str: value
        """
        KEY_READ = winreg.KEY_READ
        openkey = winreg.OpenKey
        ms = self.microsoft
        for hkey in self.HKEYS:
            try:
                bkey = openkey(hkey, ms(key), 0, KEY_READ)
            except (OSError, IOError):
                if not self.pi.current_is_x86():
                    try:
                        bkey = openkey(hkey, ms(key, True), 0, KEY_READ)
                    except (OSError, IOError):
                        continue
                else:
                    continue
            try:
                return winreg.QueryValueEx(bkey, name)[0]
            except (OSError, IOError):
                pass 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:35,代码来源:msvc.py

示例5: win32FontDirectory

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def win32FontDirectory():
    """
    Return the user-specified font directory for Win32.  This is
    looked up from the registry key::

      \\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Fonts

    If the key is not found, $WINDIR/Fonts will be returned.
    """
    try:
        from six.moves import winreg
    except ImportError:
        pass # Fall through to default
    else:
        try:
            user = winreg.OpenKey(winreg.HKEY_CURRENT_USER, MSFolders)
            try:
                try:
                    return winreg.QueryValueEx(user, 'Fonts')[0]
                except OSError:
                    pass # Fall through to default
            finally:
                winreg.CloseKey(user)
        except OSError:
            pass # Fall through to default
    return os.path.join(os.environ['WINDIR'], 'Fonts') 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:28,代码来源:font_manager.py

示例6: _get_registry_dhcp_server

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def _get_registry_dhcp_server(adapter_name):
    with winreg.OpenKey(
            winreg.HKEY_LOCAL_MACHINE,
            "SYSTEM\\CurrentControlSet\\Services\\" +
            "Tcpip\\Parameters\\Interfaces\\%s" % adapter_name, 0,
            winreg.KEY_READ) as key:
        try:
            dhcp_server = winreg.QueryValueEx(key, "DhcpServer")[0]
            if dhcp_server == "255.255.255.255":
                dhcp_server = None
            return dhcp_server
        except Exception as ex:
            # Not found
            if ex.errno != 2:
                raise 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:17,代码来源:network.py

示例7: _query_tz_key

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def _query_tz_key(key):
        tzi = winreg.QueryValueEx(key, "TZI")[0]
        daylight_name = winreg.QueryValueEx(key, "Dlt")[0]
        standard_name = winreg.QueryValueEx(key, "Std")[0]
        return tzi, standard_name, daylight_name 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:7,代码来源:timezone.py

示例8: get_uac_remote_restrictions

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def get_uac_remote_restrictions(self):
        try:
            with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
                                self._SYSTEM_POLICIES_KEY) as key:
                (value, regtype) = winreg.QueryValueEx(key,
                                                       self._LATFP_VALUE_NAME)
                return not bool(value)
        except WindowsError as e:
            if e.errno == 0x2:
                return True
            else:
                raise 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:14,代码来源:security.py

示例9: get_san_policy

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def get_san_policy(self):
        with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
                            'SYSTEM\\CurrentControlSet\\Services\\partmgr\\'
                            'Parameters') as key:
            try:
                san_policy = winreg.QueryValueEx(key, 'SanPolicy')[0]
            except WindowsError as ex:
                if ex.winerror != 2:
                    raise
                san_policy = base.SAN_POLICY_OFFLINE_SHARED
            return san_policy 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:13,代码来源:wsm_storage_manager.py

示例10: get_user_home

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def get_user_home(self, username):
        user_sid = self.get_user_sid(username)
        if user_sid:
            with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\'
                                'Microsoft\\Windows NT\\CurrentVersion\\'
                                'ProfileList\\%s' % user_sid) as key:
                return winreg.QueryValueEx(key, 'ProfileImagePath')[0]
        LOG.debug('Home directory not found for user %r', username)
        return None 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:11,代码来源:windows.py

示例11: _check_server_level

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def _check_server_level(self, server_level):
        try:
            with winreg.OpenKey(
                    winreg.HKEY_LOCAL_MACHINE,
                    "Software\\Microsoft\\Windows NT\\CurrentVersion\\Server\\"
                    "ServerLevels") as key:
                return winreg.QueryValueEx(key, server_level)[0] == 1
        except WindowsError as ex:
            if ex.winerror == 2:
                return False
            else:
                raise 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:14,代码来源:windows.py

示例12: is_real_time_clock_utc

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def is_real_time_clock_utc(self):
        with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
                            'SYSTEM\\CurrentControlSet\\Control\\'
                            'TimeZoneInformation') as key:
            try:
                utc = winreg.QueryValueEx(key, 'RealTimeIsUniversal')[0]
                return utc != 0
            except WindowsError as ex:
                if ex.winerror == 2:
                    return False
                raise 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:13,代码来源:windows.py

示例13: get_page_files

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def get_page_files(self):
        with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
                            'SYSTEM\\CurrentControlSet\\Control\\'
                            'Session Manager\\Memory Management') as key:
            values = winreg.QueryValueEx(key, 'PagingFiles')[0]

        page_files = []
        for value in values:
            v = value.split(" ")
            path = v[0]
            min_size_mb = int(v[1]) if len(v) > 1 else 0
            max_size_mb = int(v[2]) if len(v) > 2 else 0
            page_files.append((path, min_size_mb, max_size_mb))
        return page_files 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:16,代码来源:windows.py

示例14: check_dotnet_is_installed

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def check_dotnet_is_installed(self, version):
        # See: https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx
        if str(version) != "4":
            raise exception.CloudbaseInitException(
                "Only checking for version 4 is supported at the moment")
        try:
            with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\'
                                'Microsoft\\NET Framework Setup\\NDP\\'
                                'v%s\\Full' % version) as key:
                return winreg.QueryValueEx(key, 'Install')[0] != 0
        except WindowsError as ex:
            if ex.winerror == 2:
                return False
            else:
                raise 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:17,代码来源:windows.py

示例15: win32FontDirectory

# 需要导入模块: from six.moves import winreg [as 别名]
# 或者: from six.moves.winreg import QueryValueEx [as 别名]
def win32FontDirectory():
    """
    Return the user-specified font directory for Win32.  This is
    looked up from the registry key::

      \\\\HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Fonts

    If the key is not found, $WINDIR/Fonts will be returned.
    """
    try:
        from six.moves import winreg
    except ImportError:
        pass  # Fall through to default
    else:
        try:
            user = winreg.OpenKey(winreg.HKEY_CURRENT_USER, MSFolders)
            try:
                try:
                    return winreg.QueryValueEx(user, 'Fonts')[0]
                except OSError:
                    pass  # Fall through to default
            finally:
                winreg.CloseKey(user)
        except OSError:
            pass  # Fall through to default
    return os.path.join(os.environ['WINDIR'], 'Fonts') 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:28,代码来源:font_manager.py


注:本文中的six.moves.winreg.QueryValueEx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。