本文整理汇总了Python中platform.machine方法的典型用法代码示例。如果您正苦于以下问题:Python platform.machine方法的具体用法?Python platform.machine怎么用?Python platform.machine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类platform
的用法示例。
在下文中一共展示了platform.machine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait_until_server_loaded
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def wait_until_server_loaded(self, timeout_s=900, port=2552):
"""
This function will wait until the LabVIEW server is loaded on the local
machine.
:param timeout_s: How long to wait for the LabVIEW server to load.
Default is 15 minutes (900 seconds).
:raises TimeoutError: Raised when timeout exceeded while waiting
"""
waiting = True
start_time = time.time()
while waiting:
try:
with self.client():
pass
except Exception:
if time.time() - start_time > timeout_s:
raise TimeoutError('Timed out while waiting for LabVIEW'
' server to load')
else:
waiting = False
示例2: _open_windows_native_key
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def _open_windows_native_key(self, key, sub_key):
"""
Opens a windows registry key using the OS bitness-based version of the
registry view.
This method eventually calls the _winreg.OpenKey() method.
This is useful because if we're running a 32-bit python interpreter, by
default _winreg accesses the 32-bit registry view. This is a problem on
64-bit OSes as it limits us to registries of 32-bit applications.
"""
import _winreg
python_bitness, linkage = platform.architecture()
# If we're running 32-bit python, by default _winreg accesses the
# 32-bit registry view. This is a problem on 64-bit OSes.
if python_bitness == '32bit' and platform.machine().endswith('64'):
# Force _winreg to access the 64-bit registry view with the access
# map as _winreg.KEY_WOW64_64KEY
return _winreg.OpenKey(key, sub_key, 0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY)
else:
return _winreg.OpenKey(key, sub_key)
return key
示例3: detectArch
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def detectArch():
try:
with open("/etc/os-release") as osr:
osReleaseLines = osr.readlines()
hasOsRelease = True
except (IOError,OSError):
osReleaseLines = []
hasOsRelease = False
try:
import platform
if platform.system() == "Darwin":
return "osx_x86-64"
except:
pass
try:
import platform, distro
platformTuple = distro.linux_distribution()
platformSystem = platform.system()
platformProcessor = platform.processor()
if " " in platformProcessor:
platformProcessor = platform.machine()
return doDetectArch(hasOsRelease, osReleaseLines, platformTuple, platformSystem, platformProcessor)
except:
return doDetectArch(hasOsRelease, osReleaseLines, ["unknown", "", ""], "", "")
示例4: __init__
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def __init__(self):
self.datetime_format = '%H:%M:%S %d/%m/%Y'
self.__raw_boot_time = psutil.boot_time()
self.__boot_time = datetime.fromtimestamp(self.raw_boot_time)
self.__boot_time = self.__boot_time.strftime(self.datetime_format)
self.__hostname = platform.node()
self.__os = Computer.__get_os_name()
self.__architecture = platform.machine()
self.__python_version = '{} ver. {}'.format(
platform.python_implementation(), platform.python_version()
)
self.__processor = Cpu(monitoring_latency=1)
self.__nonvolatile_memory = NonvolatileMemory.instances_connected_devices(monitoring_latency=10)
self.__nonvolatile_memory_devices = set(
[dev_info.device for dev_info in self.__nonvolatile_memory]
)
self.__virtual_memory = VirtualMemory(monitoring_latency=1)
self.__swap_memory = SwapMemory(monitoring_latency=1)
self.__network_interface = NetworkInterface(monitoring_latency=3)
super().__init__(monitoring_latency=3)
示例5: best_float
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def best_float():
""" Floating point type with best precision
This is nearly always np.longdouble, except on Windows, where np.longdouble
is Intel80 storage, but with float64 precision for calculations. In that
case we return float64 on the basis it's the fastest and smallest at the
highest precision.
Returns
-------
best_type : numpy type
floating point type with highest precision
"""
if (type_info(np.longdouble)['nmant'] > type_info(np.float64)['nmant'] and
machine() != 'sparc64'): # sparc has crazy-slow float128
return np.longdouble
return np.float64
示例6: _selected_real_kind_func
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def _selected_real_kind_func(p, r=0, radix=0):
# XXX: This should be processor dependent
# This is only good for 0 <= p <= 20
if p < 7:
return 4
if p < 16:
return 8
machine = platform.machine().lower()
if machine.startswith(('aarch64', 'power', 'ppc64', 's390x', 'sparc')):
if p <= 20:
return 16
else:
if p < 19:
return 10
elif p <= 20:
return 16
return -1
示例7: default_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def default_environment():
if hasattr(sys, 'implementation'):
iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
else:
iver = '0'
implementation_name = ''
return {
"implementation_name": implementation_name,
"implementation_version": iver,
"os_name": os.name,
"platform_machine": platform.machine(),
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"platform_python_implementation": platform.python_implementation(),
"python_version": platform.python_version()[:3],
"sys_platform": sys.platform,
}
示例8: __init__
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def __init__(self, base_path, home_path=Path.home(), apps=None, input_enabled=True):
self.base_path = base_path
self.home_path = home_path
self.dot_briefcase_path = home_path / ".briefcase"
self.global_config = None
self.apps = {} if apps is None else apps
# Some details about the host machine
self.host_arch = platform.machine()
self.host_os = platform.system()
# External service APIs.
# These are abstracted to enable testing without patching.
self.cookiecutter = cookiecutter
self.requests = requests
self.input = Console(enabled=input_enabled)
self.os = os
self.sys = sys
self.shutil = shutil
self.subprocess = Subprocess(self)
# The internal Briefcase integrations API.
self.integrations = integrations
示例9: get_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def get_environment():
"""
Returns a dictionary describing the environment in which stdpopsim
is currently running.
"""
env = {
"os": {
"system": platform.system(),
"node": platform.node(),
"release": platform.release(),
"version": platform.version(),
"machine": platform.machine(),
},
"python": {
"implementation": platform.python_implementation(),
"version": platform.python_version(),
},
"libraries": {
"msprime": {"version": msprime.__version__},
"tskit": {"version": tskit.__version__},
}
}
return env
示例10: get_build_platform
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def get_build_platform():
"""Return this platform's string for platform-specific distributions
XXX Currently this is the same as ``distutils.util.get_platform()``, but it
needs some hacks for Linux and Mac OS X.
"""
try:
# Python 2.7 or >=3.2
from sysconfig import get_platform
except ImportError:
from distutils.util import get_platform
plat = get_platform()
if sys.platform == "darwin" and not plat.startswith('macosx-'):
try:
version = _macosx_vers()
machine = os.uname()[4].replace(" ", "_")
return "macosx-%d.%d-%s" % (int(version[0]), int(version[1]),
_macosx_arch(machine))
except ValueError:
# if someone is running a non-Mac darwin system, this will fall
# through to the default implementation
pass
return plat
示例11: get_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def get_environment():
"""
Returns a dictionary describing the environment in which tsinfer
is currently running.
"""
env = {
"libraries": {
"zarr": {"version": zarr.__version__},
"numcodecs": {"version": numcodecs.__version__},
"lmdb": {"version": lmdb.__version__},
"tskit": {"version": tskit.__version__},
},
"os": {
"system": platform.system(),
"node": platform.node(),
"release": platform.release(),
"version": platform.version(),
"machine": platform.machine(),
},
"python": {
"implementation": platform.python_implementation(),
"version": platform.python_version_tuple(),
},
}
return env
示例12: _pv_linux_machine
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def _pv_linux_machine(machine):
if machine == 'x86_64':
return machine
cpu_info = subprocess.check_output(['cat', '/proc/cpuinfo']).decode()
hardware_info = [x for x in cpu_info.split('\n') if 'Hardware' in x][0]
model_info = [x for x in cpu_info.split('\n') if 'model name' in x][0]
if 'BCM' in hardware_info:
if 'rev 7' in model_info:
return 'arm11'
elif 'rev 5' in model_info:
return 'cortex-a7'
elif 'rev 4' in model_info:
return 'cortex-a53'
elif 'rev 3' in model_info:
return 'cortex-a72'
elif 'AM33' in hardware_info:
return 'beaglebone'
else:
raise NotImplementedError('unsupported CPU:\n%s' % cpu_info)
示例13: spawn
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def spawn(self, cmd, expect_timeout=10.0):
"""Run a command using pexpect.
The pexpect child is returned.
"""
pexpect = pytest.importorskip("pexpect", "3.0")
if hasattr(sys, "pypy_version_info") and "64" in platform.machine():
pytest.skip("pypy-64 bit not supported")
if sys.platform.startswith("freebsd"):
pytest.xfail("pexpect does not work reliably on freebsd")
logfile = self.tmpdir.join("spawn.out").open("wb")
# Do not load user config.
env = os.environ.copy()
env.update(self._env_run_update)
child = pexpect.spawn(cmd, logfile=logfile, env=env)
self.request.addfinalizer(logfile.close)
child.timeout = expect_timeout
return child
示例14: default_environment
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def default_environment():
if hasattr(sys, "implementation"):
iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
else:
iver = "0"
implementation_name = ""
return {
"implementation_name": implementation_name,
"implementation_version": iver,
"os_name": os.name,
"platform_machine": platform.machine(),
"platform_release": platform.release(),
"platform_system": platform.system(),
"platform_version": platform.version(),
"python_full_version": platform.python_version(),
"platform_python_implementation": platform.python_implementation(),
"python_version": platform.python_version()[:3],
"sys_platform": sys.platform,
}
示例15: is_host_target_supported
# 需要导入模块: import platform [as 别名]
# 或者: from platform import machine [as 别名]
def is_host_target_supported(host_target, msvc_version):
"""Check if the given (host, target) tuple is supported for given version.
Args:
host_target: tuple
tuple of (canonalized) host-targets, e.g. ("x86", "amd64")
for cross compilation from 32 bit Windows to 64 bits.
msvc_version: str
msvc version (major.minor, e.g. 10.0)
Returns:
bool:
Note:
This only checks whether a given version *may* support the given (host,
target), not that the toolchain is actually present on the machine.
"""
# We assume that any Visual Studio version supports x86 as a target
if host_target[1] != "x86":
maj, min = msvc_version_to_maj_min(msvc_version)
if maj < 8:
return False
return True