系统信息发现和资产跟踪

grainsv2的Python项目详细描述


系统信息发现和资产跟踪

安装

pip install grainsv2

开发安装

克隆grainsrepo并使用pip安装:

^{pr2}$

执行

安装之后,现在应该可以使用grains命令。在

命令在垂直扩展之前没有输出(详细信息如下)。在

测试

安装要求-测试.txt使用pip并运行pytest:

pip install -r grains/requirements-test.txt
pytest grains/tests

垂直应用程序合并

延伸晶粒说明

安装pop:

pip install --upgrade pop

为项目创建新目录:

mkdir grains_{project_name}
cd grains_{project_name}

使用pop seed生成扩展粒度的项目结构:

pop-seed -t v grains_{project_name} -d grains
  • “-t v”指定这是一个垂直应用程序合并的项目
  • “-d grains”表示要实现“grains”的动态名称

请注意,已经为您创建了一些结构。 我们特别关注grains{project_name}/grains中的新目录

添加“谷物”到要求.txt公司名称:

echo "grains" >> requirements.txt

造粒

  • Create a new file in “grains_{project_name}/grains”
    • The directory should already have been created by pop-seed.
    • The file name is arbitrary.
    • Every file in this directory, then it’s subdirectories, will be parsed “simultaneously” (as far as that makes sense for asyncio).
    • Grains that are dependant on each other should be assigned in the same function.
    • Do NOT rely on the collector’s recursion strategy for grains to depend on each other.
    • Use hub.grains.init.wait_for(“grains”) to wait for grains to be generated by another sub
  • Add your new project to the python path
    • alternatively, run “pip install -e .” from your project’s root directory
      • you only need to do this once
  • Create an async function in this file with a descriptive yet arbitrary name
    • By convention it should start with “load”
    • Make it async unless you have a really really really good reason.
    • Grains that depend on each other already belong in the same function, don’t depend on synchronous programming for determinism
    • Use hub.grains.init.wait_for(“specific_grain”) to explicitly wait for an external grain to become available before moving on
    • Grains can be accessed and assigned like a dictionary, but our convention is to use the namespace
    • Use hub.grains.GRAINS._dict() or copy.copy(hub.grains.GRAINS) to retrieve a JSON serializable version of grains.

示例:

async def load_my_grain(hub):
    hub.grains.GRAINS.new_grain = "Hello World!"

就这样!现在,请验证是否已从命令行收集颗粒:

grains new_grain

输出:

new_grain:
    Hello World!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java如何在泛型类中调用我的类T的方法   java如何在XML配置中添加quartz JobListener(springframework)   java JPA查询以空值结束   密码学为什么Java DES密钥生成器生成的密钥大小不正确?   java布尔算法在输出为假时生成真输出   java缓存休眠混乱的行为   java如何让Android SDK 1.5版在我的G1手机上运行?   java无状态应用程序Spring安全性   Eclipse上的java,“首选项>常规>工作区>使用本机挂钩或轮询刷新”做了什么?   java私有静态方法从公共静态方法访问   滚动窗格JavaFX中图形上的java静态标签   如何从Oracle Java教程中调用findLargest方法(使用接口作为类型)   JavaEE:EJB远程接口中的自定义类