Python winreg.KEY_QUERY_VALUE Examples
The following are 4
code examples of winreg.KEY_QUERY_VALUE().
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
winreg
, or try the search function
.
Example #1
Source File: animation.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def _init_from_registry(cls): if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert': return import winreg for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY): try: hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, r'Software\Imagemagick\Current', 0, winreg.KEY_QUERY_VALUE | flag) binpath = winreg.QueryValueEx(hkey, 'BinPath')[0] winreg.CloseKey(hkey) break except Exception: binpath = '' if binpath: for exe in ('convert.exe', 'magick.exe'): path = os.path.join(binpath, exe) if os.path.exists(path): binpath = path break else: binpath = '' rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath
Example #2
Source File: animation.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _init_from_registry(cls): if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert': return import winreg for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY): try: hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, r'Software\Imagemagick\Current', 0, winreg.KEY_QUERY_VALUE | flag) binpath = winreg.QueryValueEx(hkey, 'BinPath')[0] winreg.CloseKey(hkey) break except Exception: binpath = '' if binpath: for exe in ('convert.exe', 'magick.exe'): path = os.path.join(binpath, exe) if os.path.exists(path): binpath = path break else: binpath = '' rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath
Example #3
Source File: animation.py From coffeegrindsize with MIT License | 6 votes |
def _init_from_registry(cls): if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert': return import winreg for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY): try: hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, r'Software\Imagemagick\Current', 0, winreg.KEY_QUERY_VALUE | flag) binpath = winreg.QueryValueEx(hkey, 'BinPath')[0] winreg.CloseKey(hkey) break except Exception: binpath = '' if binpath: for exe in ('convert.exe', 'magick.exe'): path = os.path.join(binpath, exe) if os.path.exists(path): binpath = path break else: binpath = '' rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath
Example #4
Source File: util.py From pympress with GNU General Public License v2.0 | 4 votes |
def set_screensaver(must_disable, window): """ Enable or disable the screensaver. Args: must_disable (`bool`): if `True`, indicates that the screensaver must be disabled; otherwise it will be enabled window (:class:`~Gdk.Window`): The window on the screen where the screensaver is to be suspended. """ if IS_MAC_OS: # On Mac OS X we can use caffeinate to prevent the display from sleeping if must_disable: if set_screensaver.dpms_was_enabled is None or set_screensaver.dpms_was_enabled.poll(): set_screensaver.dpms_was_enabled = subprocess.Popen(['caffeinate', '-d', '-w', str(os.getpid())]) else: if set_screensaver.dpms_was_enabled and not set_screensaver.dpms_was_enabled.poll(): set_screensaver.dpms_was_enabled.kill() set_screensaver.dpms_was_enabled.poll() set_screensaver.dpms_was_enabled = None elif IS_POSIX: # Import here because util should be imported without depending on gi from gi.repository import Gio # On Linux and Wayland we can use a dbus interface to tell the screensaver # to not lock the screen, should work on all freedesktop compliant desktops # eg. Gnome, KDE,... bus = Gio.bus_get_sync(Gio.BusType.SESSION, None) iface = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None, 'org.freedesktop.ScreenSaver', '/org/freedesktop/ScreenSaver', 'org.freedesktop.ScreenSaver', None) if must_disable and not set_screensaver.dpms_was_enabled: set_screensaver.dbus_cookie = iface.Inhibit("(ss)", "pympress", _("Fullscreen Presentation running")) set_screensaver.dpms_was_enabled = True if not must_disable and set_screensaver.dpms_was_enabled: iface.UnInhibit("(u)", set_screensaver.dbus_cookie) set_screensaver.dbus_cookie = None set_screensaver.dpms_was_enabled = False elif IS_WINDOWS: try: with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'Control Panel\Desktop', 0, winreg.KEY_QUERY_VALUE | winreg.KEY_SET_VALUE) as key: if must_disable: value, regtype = winreg.QueryValueEx(key, "ScreenSaveActive") assert(regtype == winreg.REG_SZ) set_screensaver.dpms_was_enabled = (value == "1") if set_screensaver.dpms_was_enabled: winreg.SetValueEx(key, "ScreenSaveActive", 0, winreg.REG_SZ, "0") elif set_screensaver.dpms_was_enabled: winreg.SetValueEx(key, "ScreenSaveActive", 0, winreg.REG_SZ, "1") except (OSError, PermissionError): logger.exception(_("access denied when trying to access screen saver settings in registry!")) else: logger.warning(_("Unsupported OS: can't enable/disable screensaver")) #: remember DPMS setting before we change it