本文整理汇总了Python中monitors.Monitor.cid方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.cid方法的具体用法?Python Monitor.cid怎么用?Python Monitor.cid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitors.Monitor
的用法示例。
在下文中一共展示了Monitor.cid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: editcheck_page
# 需要导入模块: from monitors import Monitor [as 别名]
# 或者: from monitors.Monitor import cid [as 别名]
def editcheck_page(cname, cid):
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
data = startData(user)
data['active'] = 'dashboard'
data['url'] = '/dashboard/edit-monitors/' + cname + "/" + cid
tmpl = 'monitors/' + cname + '.html'
data['edit'] = True
data['js_bottom'] = ['monitors/base.js', 'monitors/' + cname + '.js']
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
# Get list of reactions and validate that there are some
data['reactions'] = user.getReactions(g.rdb_conn)
# Proces the form
cform = __import__(
"monitorforms." + cname, globals(), locals(), ['CheckForm'], -1)
form = cform.CheckForm(request.form)
oldmonitor = Monitor()
oldmonitor.get(cid, g.rdb_conn)
if oldmonitor.uid == user.uid:
data['monitor'] = {
'cid': oldmonitor.cid,
'name': oldmonitor.name,
'uid': oldmonitor.uid,
'ctype': oldmonitor.ctype,
'url': oldmonitor.url,
'data': oldmonitor.data
}
# Check if the form contains the timer SelectField
if form.__contains__("timer"):
form.timer.choices = data['choices']
reactchoices = []
reactdefaults = []
for key in data['reactions'].keys():
reactchoices.append(
(data['reactions'][key]['id'],
data['reactions'][key]['name']))
if data['reactions'][key]['id'] in \
data['monitor']['data']['reactions']:
reactdefaults.append(data['reactions'][key]['id'])
form.reactions.choices = reactchoices
for item in form.__iter__():
if item.type == "SelectField" or\
item.type == "SelectMultipleField":
item.default = data['monitor']['data'][item.name]
if request.method == 'POST':
if form.validate():
monitor = Monitor()
monitor.cid = cid
monitor.name = form.name.data
monitor.ctype = cname
monitor.uid = user.uid
monitor.status = "queued"
monitor.url = oldmonitor.url
tmpdata = {}
for item in form.__iter__():
tmpdata[item.name] = item.data
if item.type == "SelectField" or\
item.type == "SelectMultipleField":
item.default = item.data
monitor.data = tmpdata
data['monitor'] = {
'cid': monitor.cid,
'name': monitor.name,
'uid': monitor.uid,
'ctype': monitor.ctype,
'url': monitor.url,
'data': monitor.data
}
reactdefaults = data['monitor']['data']['reactions']
# Check if the user already exceeds their limit
if oldmonitor.uid == user.uid:
# Create the monitor if all checks out
results = monitor.editMonitor(g.rdb_conn)
else:
results = "NotYours"
print("/dashboard/edit-monitors/{0} - \
Monitor edit failed: not users".format(cname))
flash("This Monitor doesn't appear to be yours.",
'danger')
if results == "exists":
print("/dashboard/edit-monitors/{0} - \
Monitor edit failed: exists".format(cname))
flash('This monitor seems to already exist. \
Try using a different name.', 'danger')
elif results is False:
print("/dashboard/edit-monitors/{0} - Monitor \
edit failed: unknown reason".format(cname))
flash('Could not edit monitor.', 'danger')
elif results == 'toomany':
stathat.ez_count(
app.config['STATHAT_EZ_KEY'],
app.config['ENVNAME'] + ' Too many health checks',
#.........这里部分代码省略.........