diff options
author | Livio Recchia <recchialivio@libero.it> | 2020-02-10 23:06:34 +0100 |
---|---|---|
committer | Livio Recchia <recchialivio@libero.it> | 2020-02-10 23:06:34 +0100 |
commit | 9a13903a2f7d3a65fdf15a65fb59cccd622e2066 (patch) | |
tree | 9403b7dff39eb5e5d7fa0f79efb69b496add4c4b /external/plyer/platforms/macosx/uniqueid.py | |
parent | 11cc316b74d5f3f283413a33e7693b314741aa4a (diff) | |
download | manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.gz manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.bz2 manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.xz manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.zip |
Initial commit
Diffstat (limited to 'external/plyer/platforms/macosx/uniqueid.py')
-rw-r--r-- | external/plyer/platforms/macosx/uniqueid.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/external/plyer/platforms/macosx/uniqueid.py b/external/plyer/platforms/macosx/uniqueid.py new file mode 100644 index 0000000..51ba169 --- /dev/null +++ b/external/plyer/platforms/macosx/uniqueid.py @@ -0,0 +1,32 @@ +from subprocess import Popen, PIPE +from plyer.facades import UniqueID +from plyer.utils import whereis_exe + +from os import environ + + +class OSXUniqueID(UniqueID): + def _get_uid(self): + old_lang = environ.get('LANG') + environ['LANG'] = 'C' + + ioreg_process = Popen(["ioreg", "-l"], stdout=PIPE) + grep_process = Popen(["grep", "IOPlatformSerialNumber"], + stdin=ioreg_process.stdout, stdout=PIPE) + ioreg_process.stdout.close() + output = grep_process.communicate()[0] + + environ['LANG'] = old_lang + + if output: + return output.split()[3][1:-1] + else: + return None + + +def instance(): + import sys + if whereis_exe('ioreg'): + return OSXUniqueID() + sys.stderr.write("ioreg not found.") + return UniqueID() |