一个基于twisted的juju客户端。

txjuju的Python项目详细描述


txjuju提供基于twisted的工具 用于与Juju交互。这个 包括一个api客户端和一个cli包装器。图书馆有限 对于Python2,但同时支持juju 1.x和2.x。 Python3正在被关注。

注意,在txjujuju中只暴露了jujuju功能的一部分。 这是因为代码源于 Landscape项目,没有增长 远远超出了景观的需要。的正式python绑定 菊苣(python-libjuju) 通常会提供更好的体验。在某个时刻,python libjujuju 可能完全取代TXJUU。

关键部件

以下是txjuju的基本类:

另外,txjuju.prepare_for_bootstrap()特别有用。

有关详细信息,请参见DOC.rst

示例用法

API客户端

fromtwisted.internetimportreactorfromtwisted.internet.deferimportinlineCallbacksfromtxjuju.apiimportEndpointendpoint=Endpoint(reactor,"ec2-1-2-3-4.compute-1.amazonaws.com")deferred=endpoint.connect()@inlineCallbacksdefconnected(client):yieldclient.login("user-admin","54830489236383334d1d9fd84adae72c")yieldclient.setAnnotations("unit","1",{"foo":"bar"})deferred.addCallback(connected)reactor.run()

cli包装器

importpprintfromtwisted.internetimportreactorfromtwisted.internet.deferimportinlineCallbacks,returnValuefromtxjujuimportprepare_for_bootstrapfromtxjuju.cliimportBootstrapSpec,Juju1CLIcfgdir="/tmp/my-juju"spec=BootstrapSpec("my-env","lxd")cli=Juju1CLI(cfgdir)@inlineCallbacksdefbootstrap():prepare_for_bootstrap(spec,"1.25.6",cfgdir)yieldcli.boostrap(spec.name,"0")raw=yieldcli.api_info(spec.name)returnValue(raw)deferred=bootstrap()deferred.addCallback(lambdav:pprint.pprint(v))reactor.run()

贡献

如果你想为txjuju做贡献,请随时打开一个问题或 给我们一个请求。就从txjuju借钱而言, 代码已获得lgplv3许可。

包装

可以使用python2 setup.py sdist创建python包。 有关构建Debian包的信息,请参见BUILDbuild.sh

风格

TXJUJU代码遵循PEP 8。经常跑步是个好主意 就像flake8当 做出改变。其他TXJUJU特定指南:

  • 对字符串使用双引号
  • 测试方法应具有docstrings

测试

要运行测试套件,请运行make testpython2 -m unittest txjuju.tests.test_XXX

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

推荐PyPI第三方库


热门话题
java Jetty是否有请求缓存?   数组中的java 2值与我的数据帧中的2列对应   对象序列化期间的java DbUtils类型转换问题   java根面板中不显示所有单独的面板   java通过代理或SSH隧道连接Hbase API   java困惑:与经典MVC控制器相比,JSF2中bean的角色   java在我的Triangle类中“找不到符号错误”   java在Android中设置从路径到自定义按钮的图像   java不绕轨道旋转椭圆   AES在socket上搞砸了序列化/反序列化。无效的流标头。JAVA   java在数组中搜索term和if语句   线程“main”java中出现异常。util。正则表达式。PatternSyntaxException:在索引0附近悬挂元字符“*”*   Websphere上的java Google反射无法打开url连接   java为什么inc/dec频道什么都不做?   java KeyListener无法访问keyPressed方法