Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/variables.py @ 243:57ff12610dc5
Implemented OS:node to return the host's computername
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 21 May 2020 08:32:37 +0200 |
| parents | bfa4d125fd14 |
| children | ff964825a75a |
comparison
equal
deleted
inserted
replaced
| 242:bfa4d125fd14 | 243:57ff12610dc5 |
|---|---|
| 8 """ | 8 """ |
| 9 | 9 |
| 10 from __future__ import division, absolute_import, print_function | 10 from __future__ import division, absolute_import, print_function |
| 11 | 11 |
| 12 import os | 12 import os |
| 13 import platform | |
| 13 from functools import wraps | 14 from functools import wraps |
| 14 | 15 |
| 15 from .compat import PY2, native_os_str_to_text, u | 16 from .compat import PY2, native_os_str_to_text, u |
| 16 | 17 |
| 17 | 18 |
| 34 | 35 |
| 35 def _oslookup(name, default=_MARKER): | 36 def _oslookup(name, default=_MARKER): |
| 36 """Lookup some process and/or OS state """ | 37 """Lookup some process and/or OS state """ |
| 37 if name == "cwd": | 38 if name == "cwd": |
| 38 return native_os_str_to_text(os.getcwd()) | 39 return native_os_str_to_text(os.getcwd()) |
| 40 elif name == "node": | |
| 41 return native_os_str_to_text(platform.node()) | |
| 39 else: | 42 else: |
| 40 if default is _MARKER: | 43 if default is _MARKER: |
| 41 raise KeyError("key %r not found in the namespace" % name) | 44 raise KeyError("key %r not found in the namespace" % name) |
| 42 else: | 45 else: |
| 43 return default | 46 return default |
| 44 | 47 |
| 45 | 48 |
| 46 def _pylookup(name, default=_MARKER): | 49 def _pylookup(name, default=_MARKER): |
| 47 """Lookup Python specific information""" | 50 """Lookup Python specific information""" |
| 48 import platform | |
| 49 if name == "version": | 51 if name == "version": |
| 50 return u(platform.python_version()) | 52 return u(platform.python_version()) |
| 51 elif name == "implementation": | 53 elif name == "implementation": |
| 52 return u(platform.python_implementation()) | 54 return u(platform.python_implementation()) |
| 53 elif name == "version_maj_min": | 55 elif name == "version_maj_min": |
