当前位置:  开发笔记 > 编程语言 > 正文

Fabric和Jinja模板上传

如何解决《Fabric和Jinja模板上传》经验,为你挑选了1个好方法。

出于某种原因,Jinja声称它无法找到我在Fabric任务中指定的模板:

httpd_local = "/path/to/dir/conf/" # with httpd.conf located here
httpd_remote = "/etc/httpd/conf/httpd.conf"

with lcd(httpd_local):
    upload_template(filename='/path/to/dir/conf/httpd.conf', destination=httpd_remote, context=context[hostname], use_jinja=True)

但每次我跑,我都会

jinja2.exceptions.TemplateNotFound: /path/to/dir/conf/httpd.conf

它肯定住在那里.这是怎么回事?



1> alukach..:

为了澄清oselivanov的答案,这将是你的正确格式的例子:

httpd_local = "/path/to/dir/conf/" # with httpd.conf located here
httpd_remote = "/etc/httpd/conf/httpd.conf"

with lcd(httpd_local):
    upload_template(filename='httpd.conf', destination=httpd_remote, template_dir='/path/to/dir/conf', context=context[hostname], use_jinja=True)

推荐阅读
帆侮听我悄悄说星星
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有