从命令行接收json字符串的jinja2呈现程序。用于在部署环境中生成配置文件

jinjaconfig的Python项目详细描述


金针鱼

从命令行接收json字符串的jinja2呈现程序。用于在部署中生成配置文件 环境。

安装

安装jinja配置

pip install jinjaconfig

从源安装

pip install git+https://bitbucket.org/luisfernando/jinjaconfig.git

用法

usage: jinjaconfig [-h] --values [values] [file]

A jinja2 renderer receiving arguments from commandline. Useful for generating
config files in deployment enviroments

positional arguments:
  file               template to parse

optional arguments:
  -h, --help         show this help message and exit
  --values [values]  json encoded values

基本用途

  1. 从命令行传递参数

    jinjaconfig example.conf --values="{"celery":{"task":"mytask","path":"/home/x/Env/myenv/bin/celery"},
    "num_procs":2,"user":"user","workdir":"/home/x/app/app/","logs":{"error":"/home/x/app/logs/err.log",
    "log":"/home/x/app/logs/log.log"}}"
    
  2. 从文件中传递参数(*nix,bash)并输出到文件

    jinjaconfig example.conf --values="`cat arguments.json`" > result.conf
    

example.conf

; ==================================
;  configuration example
; ==================================

[program:celery]
; Set full path to celery program if using virtualenv
command={{ celery.path }} worker -A {{ celery.task }}

directory={{ workdir }}
user={{ user }}
numprocs={{ num_procs }}
stdout_logfile={{ logs.log }}
stderr_logfile={{ logs.error }}
autostart=true
autorestart=true
startsecs=10

; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600

; When resorting to send SIGKILL to the program to terminate it
; send SIGKILL to its whole process group instead,
; taking care of its children as well.
killasgroup=true

; if rabbitmq is supervised, set its priority higher
; so it starts first
priority=998

arguments.json

{
   "celery" : {
      "task" : "mytask",
      "path" : "/home/x/Env/myenv/bin/celery"
   },
   "num_procs" : 2,
   "user" : "user",
   "workdir" : "/home/x/app/app/",
   "logs" : {
      "error" : "/home/x/app/logs/err.log",
      "log" : "/home/x/app/logs/log.log"
   }
}

作者:

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

推荐PyPI第三方库


热门话题
java从资产中读取JSON文件   JavaFX上带线程程序的java暂停事件执行   java如何将datepicker格式转换为ddMMyyyy   多次点击swing Java按钮   java primefaces使用DefaultMenuItem同时进行重定向和操作   在JAVA中,如何将身份验证器POST请求中的会话转发到GET请求中?   用于在mongodb集合中插入包含元素数组的文档的json Java API   java DriverManager无法打开SQL连接器jar   java使用一个通用工厂方法创建实例   Java中的多线程等待条件   java Liferay 7.1限制了对虚拟实例(公司)的portlet/modules访问   安卓 Java:在读取进程的InputStream之前,等待进程的子进程完成   java只允许使用一种HTTP方法。找到,得到,放   docker我无法从我的java制作人生成kafka主题的消息