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 (54 lines) | stat: -rw-r--r-- 1,006 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''UniqueID facade.

Returns the following depending on the platform:

* **Android**: Android ID
* **OS X**: Serial number of the device
* **Linux**: Serial number using lshw
* **Windows**: MachineGUID from regkey
* **iOS**: UUID

Simple Example
--------------

To get the unique ID::

    >>> from plyer import uniqueid
    >>> uniqueid.id
    '1b1a7a4958e2a845'

.. versionadded:: 1.2.0

.. versionchanged:: 1.2.4
    On Android returns Android ID instead of IMEI.

Supported Platforms
-------------------
Android, iOS, Windows, OS X, Linux

'''


class UniqueID:
    '''
    UniqueID facade.
    '''

    @property
    def id(self):
        '''
        Property that returns the unique id of the platform.
        '''
        return self.get_uid()

    def get_uid(self):
        '''
        Public method for receiving unique ID via platform-specific
        API in plyer.platforms.
        '''
        return self._get_uid()

    # private

    def _get_uid(self):
        raise NotImplementedError()