3 Star 0 Fork 0

Gitee 极速下载 / ramona

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/ateska/ramona
克隆/下载
demo.py 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
Ales Teska 提交于 2014-11-27 17:25 . Specifying python version.
#!/usr/bin/env python2
#
# Released under the BSD license. See LICENSE.txt file for details.
#
import os
import ramona
class MyDemoConsoleApp(ramona.console_app):
@ramona.tool
def tool_demo(self):
"""Printing message about demo of custom ramona.tool"""
print "This is implementation of custom tool (see ./demo.sh --help)"
# Example how to access configuration from tool:
print "Value of env:RAMONADEMO = {0}".format(self.config.get("env", "RAMONADEMO"))
env = ramona.config.get_env()
print "All environment variables", env
print
env_alternative1 = ramona.config.get_env("alternative1")
print "All alternative1 environment variables", env_alternative1
@ramona.tool
class tool_class_demo(object):
"""Demo of custom ramona.tool (class)"""
def init_parser(self, cnsapp, parser):
parser.description = 'You can use methods from argparse module of Python to customize tool (sub)parser.'
parser.add_argument('integers', metavar='N', type=int, nargs='+',
help='an integer for the accumulator'
)
parser.add_argument('--sum', dest='accumulate', action='store_const',
const=sum, default=max,
help='sum the integers (default: find the max)'
)
def main(self, cnsapp, args):
print args.accumulate(args.integers)
@ramona.proxy_tool
def proxy_tool_demo(self, argv):
"""Proxying execution of /bin/ls"""
os.execv('/bin/ls', argv)
if __name__ == '__main__':
app = MyDemoConsoleApp(configuration='./demo.conf')
app.run()
1
https://gitee.com/mirrors/ramona.git
git@gitee.com:mirrors/ramona.git
mirrors
ramona
ramona
master

搜索帮助