File: uniqueid.py

package info (click to toggle)
python-plyer 2.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,808 kB
  • sloc: python: 13,395; sh: 217; makefile: 177
file content (36 lines) | stat: -rw-r--r-- 785 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'''
Module of Windows API for plyer.uniqueid.
'''

try:
    import _winreg as regedit
except ImportError:
    try:
        import winreg as regedit
    except ImportError:
        raise NotImplementedError()

from plyer.facades import UniqueID


class WinUniqueID(UniqueID):
    '''
    Implementation of Windows battery API.
    '''

    def _get_uid(self):
        # Win XP+, REG QUERY KEY /V VALUE, case-insensitive
        handle = regedit.OpenKey(
            regedit.HKEY_LOCAL_MACHINE,
            r"SOFTWARE\\Microsoft\\Cryptography", 0,
            regedit.KEY_READ | regedit.KEY_WOW64_64KEY
        )
        value, _ = regedit.QueryValueEx(handle, "MachineGuid")
        return value


def instance():
    '''
    Instance for facade proxy.
    '''
    return WinUniqueID()