#!/usr/bin/env python"""Provides a cross-platform way to figure out the system uname.This version of uname was written in Python for the xonsh project: http://xon.shBased on cat from GNU coreutils: http://www.gnu.org/software/coreutils/"""importplatformimportsysfromxonsh.cli_utilsimportArgParserAlias
[docs]defuname_fn(all=False,kernel_name=False,node_name=False,kernel_release=False,kernel_version=False,machine=False,processor=False,hardware_platform=False,operating_system=False,):"""This version of uname was written in Python for the xonsh project: https://xon.sh Based on uname from GNU coreutils: http://www.gnu.org/software/coreutils/ Parameters ---------- all : -a, --all print all information, in the following order, except omit -p and -i if unknown kernel_name : -s, --kernel-name print the kernel name node_name : -n, --nodename print the network node hostname kernel_release : -r, --kernel-release print the kernel release kernel_version : -v, --kernel-version print the kernel version machine : -m, --machine print the machine hardware name processor : -p, --processor print the processor type (non-portable) hardware_platform : -i, --hardware-platform print the hardware platform (non-portable) operating_system : -o, --operating-system print the operating system """info=platform.uname()defgen_lines():ifallornode_name:yieldinfo.nodeifallorkernel_release:yieldinfo.releaseifallorkernel_version:yieldinfo.versionifallormachine:yieldinfo.machineifallorprocessor:yieldinfo.processoror"unknown"ifallorhardware_platform:yield"unknown"ifalloroperating_system:yieldsys.platformlines=list(gen_lines())ifallorkernel_nameor(notlines):lines.insert(0,info.system)line=" ".join(lines)returnline