Created
June 15, 2015 22:23
-
-
Save tomekr/c33cbf29f12477ca63b0 to your computer and use it in GitHub Desktop.
system.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If ctypes is available, use it to find system routines for UUID generation. | |
_uuid_generate_random = _uuid_generate_time = _UuidCreate = None | |
try: | |
import ctypes, ctypes.util | |
# The uuid_generate_* routines are provided by libuuid on at least | |
# Linux and FreeBSD, and provided by libc on Mac OS X. | |
for libname in ['uuid', 'c']: | |
try: | |
lib = ctypes.CDLL(ctypes.util.find_library(libname)) | |
except: | |
continue | |
if hasattr(lib, 'uuid_generate_random'): | |
_uuid_generate_random = lib.uuid_generate_random | |
if hasattr(lib, 'uuid_generate_time'): | |
_uuid_generate_time = lib.uuid_generate_time | |
if _uuid_generate_random is not None: | |
break # found everything we were looking for |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment