A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
#!/bin/env python | |
""" argparse example. | |
url: https://mkaz.com/2014/07/26/python-argparse-cookbook/ | |
""" | |
import argparse | |
#!/bin/env python | |
#-*- coding: utf-8 -*- | |
""" 发布特定分支的 Nginx conf, 这里发布以 autodeploy 开头的分支. | |
此脚本跑在 Jenkins 任务下, 此任务通过 Jenkins 的 Gerrit Trigger | |
插件监控 Nginx conf (Gerrit 项目) 的 Ref Updated 和 Change Merged 事件, | |
而且分支要匹配 **/autodeploy*, 满足条件触发此任务. | |
1. 先计算出最近一次修改的以 autodeploy 开头的分支, |
#/usr/bin/python | |
#-*- coding: utf-8 -*- | |
import re | |
import os | |
import subprocess | |
def shell(cmd): |
#!/usr/bin/env/python | |
# | |
# More of a reference of using jinaj2 without actual template files. | |
# This is great for a simple output transformation to standard out. | |
# | |
# Of course you will need to "sudo pip install jinja2" first! | |
# | |
# I like to refer to the following to remember how to use jinja2 :) | |
# http://jinja.pocoo.org/docs/templates/ | |
# |