You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
1.3 KiB

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2022/9/9 0:04
# @Author : old tom
# @File : fu_sys.py
# @Project : Futool
# @Desc : 用于获取当前系统信息内存及硬盘信息获取请使用psutil
import os
import platform
import getpass
def is_windows():
"""
是否windows
:return:
"""
return 'Windows' == platform.system()
def is_linux():
"""
是否linux
:return:
"""
return 'Linux' == platform.system()
def is_unix():
"""
是否unix
:return:
"""
return 'Unix' == platform.system()
def os_name():
"""
操作系统名称
:return:
"""
return platform.platform()
def host_name():
"""
获取主机名
:return:
"""
return platform.node()
def sys_user():
"""
系统用户
:return:
"""
return getpass.getuser()
def sys_user_dir():
"""
当前用户目录
:return:
"""
return os.path.expanduser('~')
class CpuInfo(object):
@staticmethod
def cpu_architecture():
"""
CPU架构AMD64i386
:return:
"""
return platform.machine()
@staticmethod
def cpu_count():
"""
CPU核数
:return:
"""
return os.cpu_count()