用户友好格式的通用操作系统属性。
easyos的Python项目详细描述
编写代码时所需的通用操作系统信息的方便字典。
更新2015年1月4日:将支持移到python 3.x
获得easyos:
简单:
pip install easyos
使用easyos很简单:
要列出所有键,只需导入并打印easyos
:
$python>>>frompprintimportpprint>>>fromeasyosimporteasyos{'current_gid':20,'current_uid':501,'current_user':'tfisher','current_user_desktop':'/Users/tfisher/Desktop','current_user_group':'staff','homedir':'/Users/tfisher','os':'Darwin','platform':'Darwin-14.4.0-x86_64-i386-64bit','python_installed_packages':['easyos==2.2','coverage==3.7.1','cython==0.22.1','nose==1.3.4','pip==7.1.0','setuptools==18.0.1','six==1.8.0','sqlalchemy==0.9.8','wheel==0.24.0',],'python_version':'3.4.3','python_version_feature_branch':'3.4','python_version_major':'3','release':'10.10.4','tmp_dir':'/var/folders/k6/dzxr5tss2kn_2tbbk_jfk4c40000gn/T','type':'Darwin'}>>>
要在脚本中使用easyos
,只需调用相关键:
ifeasyos['os']=='Darwin'andeasyos['python_version']=='3.4.2':print("Python3 on OS X.")
抽象出跨平台编码的繁琐部分:
withopen(easyos['tmp_dir']+'/script','w')aslog:message="wow that's easy"log.write(message)
新功能/拉取请求:
使用您的更改或添加进行拉取请求,如果将模块推向正确的方向,我将对其进行合并。
作为一个非windows用户,我不太可能添加更多的windows属性,但是如果您需要添加一些内容,只需分支,发出一个pull请求,我就可能合并。