本文整理汇总了Python中backend.Backend.install方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.install方法的具体用法?Python Backend.install怎么用?Python Backend.install使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend.Backend
的用法示例。
在下文中一共展示了Backend.install方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import install [as 别名]
def main():
# Run pre-install tasks, if available.
if os.path.isdir('exec.d'):
dirnames = os.listdir('exec.d')
dirnames.sort()
for module in dirnames:
filename = os.path.join('exec.d', module, 'charm-pre-install')
try:
run(filename)
except OSError, e:
# If the exec.d file does not exist or is not runnable or
# is not a directory, assume we can recover. Log the problem
# and proceed. Note that Juju Core has a special need of
# errno.ENOTDIR because it apparently adds a ".empty" file in
# empty charm directories, so trying to run
# ./exec.d/.empty/charm-pre-install will trigger that error.
if e.errno in (errno.ENOENT, errno.EACCES, errno.ENOTDIR):
log('{}: {}'.format(e.strerror, filename))
else:
raise
config = get_config()
backend = Backend(config)
backend.install()
# Store current configuration.
config_json.set(config)
if __name__ == '__main__':
with log_hook():
main()