本文整理汇总了Python中monitors.Monitor.get方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.get方法的具体用法?Python Monitor.get怎么用?Python Monitor.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monitors.Monitor
的用法示例。
在下文中一共展示了Monitor.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: detailhistory_page
# 需要导入模块: from monitors import Monitor [as 别名]
# 或者: from monitors.Monitor import get [as 别名]
def detailhistory_page(cid, hid):
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/detail-history/' + hid
tmpl = 'monitors/detail-history.html'
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
monitor = Monitor()
monitor.get(cid, g.rdb_conn)
if monitor.uid == user.uid:
data['monitor'] = {
'cid': monitor.cid,
'name': monitor.name,
'ctype': monitor.ctype,
'uid': monitor.uid,
'data': monitor.data
}
data['monitor-history'] = monitor.history(
method="detail-history", hid=hid, rdb=g.rdb_conn)
else:
flash('This monitor does not belong to your user.', 'warning')
page = render_template(tmpl, data=data)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
示例2: delcheck_page
# 需要导入模块: from monitors import Monitor [as 别名]
# 或者: from monitors.Monitor import get [as 别名]
def delcheck_page(cid):
'''
Dashboard Delete Checks:
This will delete health checks via the url parameters
'''
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
if user.status != "active":
pass
else:
# Delete the Monitor
monitor = Monitor(cid)
monitor.get(cid, g.rdb_conn)
result = monitor.deleteMonitor(user.uid, cid, g.rdb_conn)
if result:
print("/dashboard/delete-checks - Delete successful")
flash('Health Check was successfully deleted.', 'success')
else:
print("/dashboard/delete-checks - Delete failed")
flash('Health Check was not deleted', 'danger')
return redirect(url_for('member.dashboard_page'))
示例3: checkaction_page
# 需要导入模块: from monitors import Monitor [as 别名]
# 或者: from monitors.Monitor import get [as 别名]
def checkaction_page(cid, action):
''' Dashboard Delete Checks: This will delete health checks via the url parameters '''
verify = verifyLogin(app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.get('uid', verify, g.rdb_conn)
if user.status != "active":
pass
else:
## Delete the Monitor
monitor = Monitor(cid)
monitor.get(cid, g.rdb_conn)
if user.uid == monitor.uid:
if action == "failed":
monitor.healthcheck = "web-failed"
result = monitor.webCheck(g.rdb_conn)
print("/dashboard/action-checks - Manual monitor failure")
elif action == "healthy":
monitor.healthcheck = "web-healthy"
print("/dashboard/action-checks - Manual monitor healthy")
result = monitor.webCheck(g.rdb_conn)
if result:
print("/dashboard/action-checks - Manual monitor queued")
flash('Health check status change is queued', 'success')
else:
print("/dashboard/action-checks - Manual monitor action failed")
flash('Something went wrong. Could not modify health check', 'danger')
else:
print("/dashboard/action-checks - Manual monitor action failed: do not own")
flash('It does not appear you own this health check', 'danger')
return redirect(url_for('dashboard_page'))
示例4: viewhistory_page
# 需要导入模块: from monitors import Monitor [as 别名]
# 或者: from monitors.Monitor import get [as 别名]
def viewhistory_page(cid, start, limit):
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.config = app.config
user.get('uid', verify, g.rdb_conn)
data = startData(user)
data['active'] = 'dashboard'
data['url'] = '/dashboard/view-history/' + cid
tmpl = 'monitors/view-history.html'
# Check Users Status
if user.status != "active":
data['url'] = '/dashboard/mod-subscription'
tmpl = 'member/mod-subscription.html'
else:
monitor = Monitor()
monitor.config = app.config
monitor.get(cid, g.rdb_conn)
if monitor.uid == user.uid:
data['monitor'] = {
'cid': monitor.cid,
'name': monitor.name,
'ctype': monitor.ctype,
'uid': monitor.uid,
'data': monitor.data
}
chktime = time.time() - float(data['dataret'])
data['monitor-history-count'] = monitor.history(
method="count", time=chktime, rdb=g.rdb_conn)
data['monitor-history'] = monitor.history(
method="mon-history", time=chktime,
start=int(start), limit=int(limit), rdb=g.rdb_conn)
data['monitor-history-paging'] = []
data['monitor-history-paging-start'] = int(start)
cur = 0
while cur < data['monitor-history-count'] - 200:
cur = cur + 200
data['monitor-history-paging'].append(cur)
else:
flash('This monitor does not belong to your user.', 'warning')
page = render_template(tmpl, data=data)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
示例5: delreaction_page
# 需要导入模块: from monitors import Monitor [as 别名]
# 或者: from monitors.Monitor import get [as 别名]
def delreaction_page(rid):
'''
Dashboard Delete Domains:
This will delete a domain based on url parameters
'''
verify = verifyLogin(
app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
if verify:
user = User()
user.config = app.config
user.get('uid', verify, g.rdb_conn)
if user.status != "active":
pass
else:
appliedcount = 0
results = r.table('monitors').filter(
{'uid': user.uid}).run(g.rdb_conn)
for x in results:
monitor = Monitor()
monitor.config = app.config
monitor.get(x['id'], g.rdb_conn)
mondata = monitor.data
if rid in mondata['reactions']:
appliedcount = appliedcount + 1
if appliedcount < 1:
# Delete the Reaction
reaction = Reaction(rid)
reaction.config = app.config
result = reaction.deleteReaction(user.uid, rid, g.rdb_conn)
if result:
flash('Reaction was successfully deleted.', 'success')
else:
flash('Reaction was not deleted.', 'danger')
else:
flash('You must first detach this reaction \
from all monitors before deleting.', 'danger')
return redirect(url_for('member.dashboard_page'))
示例6: addcheck_page
# 需要导入模块: from monitors import Monitor [as 别名]
# 或者: from monitors.Monitor import get [as 别名]
def addcheck_page(cname):
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/monitors/' + cname
tmpl = 'monitors/' + cname + '.html'
data['js_bottom'] = ['monitors/monitorlist.js', '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)
if form.__contains__("timer"):
form.timer.choices = data['choices']
reactchoices = []
for key in data['reactions'].keys():
reactchoices.append(
(data['reactions'][key]['id'],
data['reactions'][key]['name']))
form.reactions.choices = reactchoices
if request.method == 'POST':
if form.validate():
monitor = Monitor()
monitor.name = form.name.data
monitor.ctype = cname
monitor.uid = user.uid
monitor.status = "queued"
monitor.url = None
tmpdata = {}
for item in form.__iter__():
tmpdata[item.name] = item.data
monitor.data = tmpdata
# Check if the user already exceeds their limit
if monitor.count(user.uid, g.rdb_conn) < data['limit']:
# Create the monitor if all checks out
results = monitor.createMonitor(g.rdb_conn)
else:
results = "toomany"
if results == "exists":
print("/dashboard/monitors/{0} - \
Monitor already exists".format(cname))
flash('{0} seems to already exist. \
Try using a different name.'.format(
monitor.name), 'danger')
elif results is False:
print("/dashboard/monitors/{0} - \
Monitor creation failed".format(cname))
flash('Could not create monitor.', 'danger')
elif results == 'toomany':
stathat.ez_count(
app.config['STATHAT_EZ_KEY'],
app.config['ENVNAME'] + ' Too many health checks',
1)
flash('You have too many monitors. \
Please upgrade your plan or clean \
up old ones.', 'danger')
print("/dashboard/monitors/{0} - \
Monitor creation failed: toomany".format(cname))
else:
stathat.ez_count(
app.config['STATHAT_EZ_KEY'],
app.config['ENVNAME'] + ' Monitor Added', 1)
print("/dashboard/monitors/%s - \
Monitor creation successful") % cname
flash('Monitor "{0}" successfully added.'.format(
monitor.name), 'success')
newmonitor = Monitor()
newmonitor.get(results, g.rdb_conn)
if newmonitor.uid == user.uid:
data['monitor'] = {
'cid': newmonitor.cid,
'name': newmonitor.name,
'uid': newmonitor.uid,
'ctype': newmonitor.ctype,
'url': newmonitor.url,
'data': newmonitor.data
}
else:
print("/dashboard/monitors/{0} - \
Monitor creation failed: Form invalid".format(cname))
flash('Form is not valid.', 'danger')
page = render_template(tmpl, data=data, form=form)
return page
else:
flash('Please Login.', 'warning')
return redirect(url_for('user.login_page'))
示例7: editcheck_page
# 需要导入模块: from monitors import Monitor [as 别名]
# 或者: from monitors.Monitor import get [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',
#.........这里部分代码省略.........