Skip to content

Instantly share code, notes, and snippets.

View calmzhu's full-sized avatar

Calm Zhu calmzhu

  • China\ShangHai
View GitHub Profile
@calmzhu
calmzhu / env_substitute.py
Last active May 11, 2022 05:41
Support env substitute with default value like bash in python
from io import StringIO
def env_substitute(_str, **context):
buffer = StringIO()
var_scope = None
for id_char, char in enumerate(_str):
if char == '$' and _str[id_char + 1] == '{':
continue
if char == '{' and _str[id_char - 1] == '$':
import hashlib
import os
import xlrd
import re
# 获取指定路径文件的MD5的全大写
def get_md5(file_path):
if not os.path.isfile(file_path):
return None
with open(file_path,'rb') as f:
node {
def deployOptions = 'no\nyes'
def userInput = input(
id: 'userInput', message: 'Are you prepared to deploy?', parameters: [
[$class: 'ChoiceParameterDefinition', choices: deployOptions, description: 'Approve/Disallow deployment', name: 'deploy-check']
]
)
echo "you selected: ${userInput}"
}