# HG changeset patch # User Marcin Kuzminski # Date 2016-11-14 23:35:53 # Node ID 6e32b207549fd009ce79880bc056ae64a23be57a # Parent 4074d5a1c029d2e06044aa18f1aa2675cbb58229 system-info: added UUID placeholder for generating platform unique identifiers. diff --git a/rhodecode/controllers/admin/settings.py b/rhodecode/controllers/admin/settings.py --- a/rhodecode/controllers/admin/settings.py +++ b/rhodecode/controllers/admin/settings.py @@ -589,7 +589,8 @@ class SettingsController(BaseController) ('', '', ''), # spacer # Platform/Python - (_('Platform'), val('platform'), state('platform')), + (_('Platform'), val('platform')['name'], state('platform')), + (_('Platform UUID'), val('platform')['uuid'], state('platform')), (_('Python version'), val('python')['version'], state('python')), (_('Python path'), val('python')['executable'], state('python')), ('', '', ''), # spacer diff --git a/rhodecode/lib/system_info.py b/rhodecode/lib/system_info.py --- a/rhodecode/lib/system_info.py +++ b/rhodecode/lib/system_info.py @@ -107,8 +107,12 @@ def py_modules(): def platform_type(): - from rhodecode.lib.utils import safe_unicode - value = safe_unicode(platform.platform()) + from rhodecode.lib.utils import safe_unicode, generate_platform_uuid + + value = dict( + name=safe_unicode(platform.platform()), + uuid=generate_platform_uuid() + ) return SysInfoRes(value=value) diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -33,6 +33,7 @@ import tempfile import traceback import tarfile import warnings +import hashlib from os.path import join as jn import paste @@ -1001,3 +1002,17 @@ def get_registry(request): return request.registry except AttributeError: return get_current_registry() + + +def generate_platform_uuid(): + """ + Generates platform UUID based on it's name + """ + import platform + + try: + uuid_list = [platform.platform()] + return hashlib.sha256(':'.join(uuid_list)).hexdigest() + except Exception as e: + log.error('Failed to generate host uuid: %s' % e) + return 'UNDEFINED'