本文整理汇总了Python中util.Util.validate_role方法的典型用法代码示例。如果您正苦于以下问题:Python Util.validate_role方法的具体用法?Python Util.validate_role怎么用?Python Util.validate_role使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.validate_role方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import validate_role [as 别名]
def update():
'''
Sets target's siteurl, blogname, and homepage
'''
Util.validate_role()
config = env.config
db_table = 'wp_options'
entries = {
'siteurl': config['site_url'],
'blogname': config['site_name'],
'home': config['site_url']
}
with local_tunnel(config['db_port']):
cnx = mysql.connector.connect(user=config['db_user'],
password=config['db_pass'],
host='127.0.0.1',
port=config['db_port'],
database=config['db_name'])
cnx.start_transaction()
cursor = cnx.cursor()
update_option = ("UPDATE `{db_table}` "
"SET `option_value`=%s "
"WHERE `option_name` LIKE %s".format(db_table=db_table))
for key, value in entries.iteritems():
cursor.execute(update_option, (value, key))
cnx.commit()
cnx.close()
示例2: push
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import validate_role [as 别名]
def push():
Util.validate_role()
config = env.config
with local_tunnel(config['db_port']):
local("mysql --user={username} --port={port} --host=127.0.0.1 "
"--password='{password}' {db_name} < {snapshot}"
.format(
username=config['db_user'],
password=config['db_pass'],
port=config['db_port'],
db_name=config['db_name'],
snapshot=snapshot_path()
)
)
示例3: pull
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import validate_role [as 别名]
def pull():
Util.validate_role()
config = env.config
with local_tunnel(config['db_port']):
local("mysqldump --user={username} --protocol=TCP --port={port} "
"--host=localhost --password='{password}' {db_name} "
"> tmp_snapshot.sql"
.format(username=config['db_user'],
password=config['db_pass'],
port=config['db_port'],
db_name=config['db_name']
)
)
local('mv tmp_snapshot.sql {0}'.format(snapshot_path()))
local('git add {0}'.format(snapshot_path()))
local('git commit -m "Database snapshot from {host}"'
.format(host=env['host_string']))