本文整理汇总了Python中os.uname方法的典型用法代码示例。如果您正苦于以下问题:Python os.uname方法的具体用法?Python os.uname怎么用?Python os.uname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os
的用法示例。
在下文中一共展示了os.uname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _mac_ver_xml
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def _mac_ver_xml():
fn = '/System/Library/CoreServices/SystemVersion.plist'
if not os.path.exists(fn):
return None
try:
import plistlib
except ImportError:
return None
pl = plistlib.readPlist(fn)
release = pl['ProductVersion']
versioninfo=('', '', '')
machine = os.uname().machine
if machine in ('ppc', 'Power Macintosh'):
# for compatibility with the gestalt based code
machine = 'PowerPC'
return release,versioninfo,machine
示例2: _syscmd_uname
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def _syscmd_uname(option,default=''):
""" Interface to the system's uname command.
"""
if sys.platform in ('dos','win32','win16','os2'):
# XXX Others too ?
return default
try:
f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
except (AttributeError,os.error):
return default
output = f.read().strip()
rc = f.close()
if not output or rc:
return default
else:
return output
示例3: main
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def main():
arguments = docopt(__doc__)
logger.setLevel(logging.WARNING)
if arguments['--debug']:
logger.setLevel(logging.DEBUG)
logging.getLogger('ciftify').setLevel(logging.DEBUG)
## set up the top of the log
logger.info('{}{}'.format(ciftify.utils.ciftify_logo(),
ciftify.utils.section_header('Starting ciftify_atlas_report')))
ciftify.utils.log_arguments(arguments)
with ciftify.utils.TempDir() as tmpdir:
logger.info('Creating tempdir:{} on host:{}'.format(tmpdir,
os.uname()[1]))
ret = run_ciftify_dlabel_report(arguments, tmpdir)
示例4: main
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def main():
arguments = docopt(__doc__)
debug = arguments['--debug']
if debug:
logger.setLevel(logging.DEBUG)
logging.getLogger('ciftify').setLevel(logging.DEBUG)
## set up the top of the log
logger.info('{}{}'.format(ciftify.utils.ciftify_logo(),
ciftify.utils.section_header('Starting ciftify_vol_result')))
ciftify.utils.log_arguments(arguments)
settings = UserSettings(arguments)
with ciftify.utils.TempDir() as tmpdir:
logger.info('Creating tempdir:{} on host:{}'.format(tmpdir,
os.uname()[1]))
ret = run_ciftify_vol_result(settings, tmpdir)
logger.info(ciftify.utils.section_header('Done ciftify_vol_result'))
sys.exit(ret)
示例5: main
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def main():
arguments = docopt(__doc__)
logger.setLevel(logging.WARNING)
if arguments['--debug']:
logger.setLevel(logging.DEBUG)
logging.getLogger('ciftify').setLevel(logging.DEBUG)
## set up the top of the log
logger.info('{}{}'.format(ciftify.utils.ciftify_logo(),
ciftify.utils.section_header('Starting ciftify_statclust_report')))
ciftify.utils.log_arguments(arguments)
with ciftify.utils.TempDir() as tmpdir:
logger.info('Creating tempdir:{} on host:{}'.format(tmpdir,
os.uname()[1]))
ret = run_ciftify_dlabel_report(arguments, tmpdir)
示例6: main
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def main():
arguments = docopt(__doc__)
logger.setLevel(logging.WARNING)
if arguments['--debug']:
logger.setLevel(logging.DEBUG)
logging.getLogger('ciftify').setLevel(logging.DEBUG)
## set up the top of the log
logger.info('{}{}'.format(ciftify.utils.ciftify_logo(),
ciftify.utils.section_header('Starting ciftify_dlabel_to_vol')))
ciftify.utils.log_arguments(arguments)
with ciftify.utils.TempDir() as tmpdir:
logger.info('Creating tempdir:{} on host:{}'.format(tmpdir,
os.uname()[1]))
ret = run_ciftify_dlabel_to_vol(arguments, tmpdir)
示例7: platform
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def platform():
ret = {
"arch": sys.maxsize > 2**32 and "x64" or "x86",
}
if xbmc.getCondVisibility("system.platform.android"):
ret["os"] = "android"
if "arm" in os.uname()[4]:
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.linux"):
ret["os"] = "linux"
if "arm" in os.uname()[4]:
ret["arch"] = "arm"
elif xbmc.getCondVisibility("system.platform.xbox"):
system_platform = "xbox"
ret["arch"] = ""
elif xbmc.getCondVisibility("system.platform.windows"):
ret["os"] = "windows"
elif xbmc.getCondVisibility("system.platform.osx"):
ret["os"] = "darwin"
elif xbmc.getCondVisibility("system.platform.ios"):
ret["os"] = "ios"
ret["arch"] = "arm"
return ret
示例8: __init__
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def __init__(self):
if self.info is not None:
return
info = [ {} ]
ok, output = getoutput('uname -m')
if ok:
info[0]['uname_m'] = output.strip()
try:
fo = open('/proc/cpuinfo')
except EnvironmentError:
e = get_exception()
warnings.warn(str(e), UserWarning, stacklevel=2)
else:
for line in fo:
name_value = [s.strip() for s in line.split(':', 1)]
if len(name_value) != 2:
continue
name, value = name_value
if not info or name in info[-1]: # next processor
info.append({})
info[-1][name] = value
fo.close()
self.__class__.info = info
示例9: get_build_platform
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [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
示例10: _FakeProxyBypassHelper
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def _FakeProxyBypassHelper(fn,
original_module_dict=sys.modules.copy(),
original_uname=os.uname):
"""Setups and restores the state for the Mac OS X urllib fakes."""
def Inner(*args, **kwargs):
current_uname = os.uname
current_meta_path = sys.meta_path[:]
current_modules = sys.modules.copy()
try:
sys.modules.clear()
sys.modules.update(original_module_dict)
sys.meta_path[:] = []
os.uname = original_uname
return fn(*args, **kwargs)
finally:
sys.modules.clear()
sys.modules.update(current_modules)
os.uname = current_uname
sys.meta_path[:] = current_meta_path
return Inner
示例11: to_json
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def to_json(self):
inventory_content = self.base_structure
start_date = self.inventory_start.replace(
tzinfo=datetime.timezone.utc).astimezone().replace(microsecond=0).isoformat()
# add metadata
inventory_content["meta"] = {
"WARNING":
"THIS is an alpha version of this implementation and possible changes might occur without notice",
"start_of_data_collection": start_date,
"duration_of_data_collection_in_seconds": (datetime.datetime.utcnow()-self.inventory_start).total_seconds(),
"inventory_layout_version": inventory_layout_version_string,
"data_retrieval_issues": self.data_retrieval_issues,
"host_that_collected_inventory": os.uname()[1],
"script_version": self.plugin_version
}
output = {"inventory": inventory_content}
return json.dumps(output, default=lambda o: o.__dict__,
sort_keys=True, indent=4)
示例12: _mac_ver_xml
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def _mac_ver_xml():
fn = '/System/Library/CoreServices/SystemVersion.plist'
if not os.path.exists(fn):
return None
try:
import plistlib
except ImportError:
return None
pl = plistlib.readPlist(fn)
release = pl['ProductVersion']
versioninfo=('', '', '')
machine = os.uname()[4]
if machine in ('ppc', 'Power Macintosh'):
# for compatibility with the gestalt based code
machine = 'PowerPC'
return release,versioninfo,machine
示例13: _syscmd_uname
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def _syscmd_uname(option,default=''):
""" Interface to the system's uname command.
"""
if sys.platform in ('dos','win32','win16','os2'):
# XXX Others too ?
return default
try:
f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
except (AttributeError,os.error):
return default
output = string.strip(f.read())
rc = f.close()
if not output or rc:
return default
else:
return output
示例14: get_build_platform
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [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.
"""
from sysconfig 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
示例15: __init__
# 需要导入模块: import os [as 别名]
# 或者: from os import uname [as 别名]
def __init__(self):
if self.info is not None:
return
info = command_info(arch='arch',
mach='mach',
uname_i='uname_i',
isainfo_b='isainfo -b',
isainfo_n='isainfo -n',
)
info['uname_X'] = key_value_from_command('uname -X', sep='=')
for line in command_by_line('psrinfo -v 0'):
m = re.match(r'\s*The (?P<p>[\w\d]+) processor operates at', line)
if m:
info['processor'] = m.group('p')
break
self.__class__.info = info