本文整理汇总了Python中shinken.webui.bottle.redirect函数的典型用法代码示例。如果您正苦于以下问题:Python redirect函数的具体用法?Python redirect怎么用?Python redirect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redirect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post_user
def post_user():
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/user/login")
return
# Take the user that send the post and not the
# form value for secutiry reason of course :)
username = user.get('username')
email = app.request.forms.get('email')
password = app.request.forms.get('password')
password2 = app.request.forms.get('password2')
password_hash = None
if password:
password_hash = hashlib.sha512(password).hexdigest()
if password != password2:
abort(400, 'Wrong password')
print "Get a user %s update with email %s and hash %s" % (username, email, password_hash)
app.update_user(username, password_hash, email)
return
开发者ID:6jo6jo,项目名称:shinken,代码行数:25,代码来源:user.py
示例2: do_register
def do_register():
username = app.request.forms.get("username")
email = app.request.forms.get("email")
password = app.request.forms.get("password")
password_hash = hashlib.sha512(password).hexdigest()
cli_mode = app.request.forms.get("cli_mode", "0")
print "Get a new user %s with email %s and hash %s" % (username, email, password_hash)
if not app.is_name_available(username):
if cli_mode == "1":
app.response.content_type = "application/json"
return json.dumps({"state": 400, "text": "Sorry, this username is not available"})
redirect("/register?error=Sorry, this username is not available")
app.register_user(username, password_hash, email)
if cli_mode == "1":
app.response.content_type = "application/json"
return json.dumps(
{
"state": 200,
"text": "Registering success, please look at your email and click in the link in it to validate your account",
}
)
redirect(
"/register?success=Registering success, please look at your email and click in the link in it to validate your account"
)
开发者ID:jstoja,项目名称:shinken,代码行数:26,代码来源:register.py
示例3: get_launch
def get_launch():
user = app.get_user_auth()
if not user:
redirect("/user/login")
print "Got forms in /newhosts/launch page"
names = app.request.forms.get('names', '')
runners = []
for (k,v) in app.request.forms.iteritems():
print "DUMP OF K, V FOR LAUNCH", k, v
print k.startswith('enable-runner-')
if k.startswith('enable-runner-'):
r_name = k[len('enable-runner-'):]
print "NAME", r_name, v, to_bool(v)
if to_bool(v):
runners.append(r_name)
print "Selected runners", runners
print "Got in request form"
print names
# We are putting a ask ask in the database
i = random.randint(1, 65535)
scan_ask = {'_id': i, 'names': names, 'runners': runners, 'state': 'pending', 'creation': int(time.time())}
print "Saving", scan_ask, "in", app.db.scans
r = app.db.scans.save(scan_ask)
# We just want the id as string, not the object
print "We create the scan", i
app.ask_new_scan(i)
return {'app': app, 'user': user}
开发者ID:6jo6jo,项目名称:shinken,代码行数:33,代码来源:newhosts.py
示例4: get_last_errors_widget
def get_last_errors_widget():
user = app.get_user_auth()
if not user:
redirect("/user/login")
# We want to limit the number of elements, The user will be able to increase it
nb_elements = max(0, int(app.request.GET.get("nb_elements", "10")))
pbs = app.datamgr.get_problems_time_sorted()
# Filter with the user interests
pbs = only_related_to(pbs, user)
# Keep only nb_elements
pbs = pbs[:nb_elements]
wid = app.request.GET.get("wid", "widget_last_problems_" + str(int(time.time())))
collapsed = app.request.GET.get("collapsed", "False") == "True"
options = {"nb_elements": {"value": nb_elements, "type": "int", "label": "Max number of elements to show"}}
title = "Last IT problems"
return {
"app": app,
"pbs": pbs,
"user": user,
"page": "problems",
"wid": wid,
"collapsed": collapsed,
"options": options,
"base_url": "/widget/last_problems",
"title": title,
}
开发者ID:radu-gheorghe,项目名称:shinken,代码行数:35,代码来源:problems.py
示例5: get_page
def get_page(username):
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/user/login")
return
#uname = user.get('username')
view_user = app.get_user_by_name(username)
cur = app.db.packs.find({'user': username, 'state': 'ok'})
validated_packs = [p for p in cur]
# Only show pending and refused packs if YOU are the user
pending_packs = []
refused_packs = []
if user == view_user:
cur = app.db.packs.find({'user': username, 'state': 'pending'})
pending_packs = [p for p in cur]
cur = app.db.packs.find({'user': username, 'state': 'refused'})
refused_packs = [p for p in cur]
return {'app': app, 'user': user, 'view_user': view_user, 'validated_packs': validated_packs, 'pending_packs': pending_packs,
'refused_packs': refused_packs}
开发者ID:6jo6jo,项目名称:shinken,代码行数:26,代码来源:user.py
示例6: get_page
def get_page():
# First we look for the user sid
# so we bail out if it's a false one
# sid = app.request.get_cookie("sid")
user = app.get_user_auth()
if not user:
redirect("/user/login")
# return {'app' : app, 'pbs' : [], 'valid_user' : False, 'user' : None, 'navi' : None}
#We want to limit the number of elements
start = int(app.request.GET.get('start', '0'))
end = int(app.request.GET.get('end', '30'))
search = app.request.GET.get('search', '')
pbs = app.datamgr.get_all_problems()
# Filter with the user interests
pbs = only_related_to(pbs, user)
# Ok, if need, appli the search filter
if search:
print "SEARCHING FOR", search
print "Before filtering", len(pbs)
# We compile the patern
pat = re.compile(search, re.IGNORECASE)
new_pbs = []
for p in pbs:
if pat.search(p.get_full_name()):
new_pbs.append(p)
continue
to_add = False
for imp in p.impacts:
if pat.search(imp.get_full_name()):
to_add = True
for src in p.source_problems:
if pat.search(src.get_full_name()):
to_add = True
if to_add:
new_pbs.append(p)
pbs = new_pbs
print "After filtering", len(pbs)
total = len(pbs)
# If we overflow, came back as normal
if start > total:
start = 0
end = 30
navi = app.helper.get_navi(total, start, step=30)
pbs = pbs[start:end]
# print "get all problems:", pbs
# for pb in pbs :
# print pb.get_name()
return {'app' : app, 'pbs' : pbs, 'valid_user' : True, 'user' : user, 'navi' : navi, 'search' : search, 'page' : 'problems'}
开发者ID:thelordhitman,项目名称:shinken,代码行数:60,代码来源:problems.py
示例7: get_graphs_widget
def get_graphs_widget():
user = app.get_user_auth()
if not user:
redirect("/user/login")
search = app.request.GET.get('search', '')
if not search:
search = 'localhost'
# Look for an host or a service?
elt = None
if not '/' in search:
elt = app.datamgr.get_host(search)
else:
parts = search.split('/', 1)
elt = app.datamgr.get_service(parts[0], parts[1])
wid = app.request.GET.get('wid', 'widget_graphs_'+str(int(time.time())))
collapsed = (app.request.GET.get('collapsed', 'False') == 'True')
options = {'search' : {'value' : search, 'type' : 'hst_srv', 'label' : 'Element name'},}
title = 'Element graphs for %s' % search
return {'app' : app, 'elt' : elt, 'user' : user,
'wid' : wid, 'collapsed' : collapsed, 'options' : options, 'base_url' : '/widget/graphs', 'title' : title,
}
开发者ID:Morkxy,项目名称:shinken,代码行数:29,代码来源:graphs.py
示例8: impacts
def impacts():
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/mobile/")
return
# We want to limit the number of elements
start = int(app.request.GET.get('start', '0'))
end = int(app.request.GET.get('end', '5'))
all_imp_impacts = app.datamgr.get_important_elements()
all_imp_impacts.sort(worse_first)
total = len(all_imp_impacts)
# If we overflow, came back as normal
if start > total:
start = 0
end = 5
navi = app.helper.get_navi(total, start, step=5)
all_imp_impacts = all_imp_impacts[start:end]
return {'app' : app, 'user' : user, 'navi' : navi, 'impacts' : all_imp_impacts}
开发者ID:Morkxy,项目名称:shinken,代码行数:27,代码来源:mobile.py
示例9: problems
def problems():
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/mobile/")
return
# We want to limit the number of elements
start = int(app.request.GET.get('start', '0'))
end = int(app.request.GET.get('end', '5'))
all_pbs = app.datamgr.get_all_problems()
# Now sort it!
all_pbs.sort(hst_srv_sort)
total = len(all_pbs)
# If we overflow, came back as normal
if start > total:
start = 0
end = 5
navi = app.helper.get_navi(total, start, step=5)
all_pbs = all_pbs[start:end]
return {'app' : app, 'user' : user, 'navi' : navi, 'problems' : all_pbs, 'menu_part' : '/problems'}
开发者ID:Morkxy,项目名称:shinken,代码行数:28,代码来源:mobile.py
示例10: get_page
def get_page():
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/user/login")
all_imp_impacts = app.datamgr.get_important_elements()
all_imp_impacts.sort(hst_srv_sort)
# all_imp_impacts.sort(hst_srv_sort)
# all_imp_impacts = app.datamgr.get_services()#important_elements()
impacts = all_imp_impacts
# for imp in all_imp_impacts:
# safe_print("FIND A BAD SERVICE IN IMPACTS", imp.get_dbg_name())
# d = {'name' : imp.get_full_name().encode('utf8', 'ignore'),
# "title": "My Image 3", "thumb": "/static/images/state_flapping.png", "zoom": "/static/images/state_flapping.png",
# "html" : get_div(imp)}
# impacts.append(d)
# Got in json format
# j_impacts = json.dumps(impacts)
# print "Return impact in json", j_impacts
all_pbs = app.datamgr.get_all_problems()
now = time.time()
# Get only the last 10min errors
all_pbs = [pb for pb in all_pbs if pb.last_state_change > now - 600]
# And sort it
all_pbs.sort(hst_srv_sort) # sort_by_last_state_change)
return {"app": app, "user": user, "impacts": impacts, "problems": all_pbs}
开发者ID:bs-github,项目名称:shinken,代码行数:33,代码来源:wall.py
示例11: eue_widget
def eue_widget():
user = app.get_user_auth()
if not user:
redirect("/user/login")
wid = app.request.GET.get('wid', 'widget_system_' + str(int(time.time())))
collapsed = (app.request.GET.get('collapsed', 'False') == 'True')
got_childs = (app.request.GET.get('got_childs', 'False') == 'True')
key = app.request.GET.get('key', 1)
options = {}
problems = {}
message,db = getdb('shinken')
if not db:
return {
'app': app, 'user': user, 'wid': wid,
'collapsed': collapsed, 'options': options,
'base_url': '/widget/eue', 'title': 'Eue problems',
'problems':problems
}
return {'app': app, 'user': user, 'wid': wid,
'collapsed': collapsed, 'options': options,
'base_url': '/widget/eue', 'title': 'Eue problems',
'problems':problems
}
开发者ID:chris81,项目名称:shinken,代码行数:31,代码来源:eue.py
示例12: get_page
def get_page():
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/user/login")
all_imp_impacts = app.datamgr.get_services()#important_elements()
#all_imp_impacts.sort(hst_srv_sort)
impacts = []
for imp in all_imp_impacts:
safe_print("FIND A BAD SERVICE IN IMPACTS", imp.get_dbg_name())
d = {'name' : imp.get_full_name().encode('utf8', 'ignore'),
"title": "My Image 3", "thumb": "/static/images/state_flapping.png", "zoom": "/static/images/state_flapping.png",
"html" : get_div(imp)}
impacts.append(d)
# Got in json format
#j_impacts = json.dumps(impacts)
# print "Return impact in json", j_impacts
return {'app' : app, 'user' : user, 'impacts' : impacts}
开发者ID:pydubreucq,项目名称:shinken,代码行数:25,代码来源:wall.py
示例13: system_widget
def system_widget():
user = app.get_user_auth()
if not user:
redirect("/user/login")
schedulers = app.datamgr.get_schedulers()
brokers = app.datamgr.get_brokers()
reactionners = app.datamgr.get_reactionners()
receivers = app.datamgr.get_receivers()
pollers = app.datamgr.get_pollers()
wid = app.request.GET.get('wid', 'widget_system_' + str(int(time.time())))
collapsed = (app.request.GET.get('collapsed', 'False') == 'True')
print "SYSTEM COLLAPSED?", collapsed, type(collapsed)
got_childs = (app.request.GET.get('got_childs', 'False') == 'True')
key = app.request.GET.get('key', 1)
options = {}
return {'app': app, 'user': user, 'wid': wid,
'collapsed': collapsed, 'options': options,
'base_url': '/widget/system', 'title': 'System Information',
'schedulers': schedulers,
'brokers': brokers, 'reactionners': reactionners,
'receivers': receivers, 'pollers': pollers,
}
开发者ID:BaniaHP,项目名称:shinken,代码行数:28,代码来源:system.py
示例14: elements_generic
def elements_generic(cls, show_tpls=False):
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/user/login")
# Get all entries from db
#t = getattr(app.db, cls.my_type+'s')
#cur = t.find({})
#elts = [cls(i) for i in cur]
print "GENERIC", cls.my_type
t = cls.my_type + 's'
key = keys[t]
#if cls.my_type == 'host':
# print "HOOK HOSTS"
elts = [cls(i) for i in app.datamgr.get_generics(t, key)]
print "GOT elements", elts
# Look for removing or keeping templates
if not show_tpls:
print "REMOVING TEMPLATES"
elts = [e for e in elts if not e.is_tpl()]
return {'app': app, 'user': user, 'elts': elts, 'elt_type': cls.my_type}
开发者ID:6jo6jo,项目名称:shinken,代码行数:26,代码来源:elements.py
示例15: checkauth
def checkauth():
user = app.get_user_auth()
if not user:
redirect("/user/login")
else:
return user
开发者ID:jstoja,项目名称:shinken,代码行数:7,代码来源:eue.py
示例16: get_last_errors_widget
def get_last_errors_widget():
user = app.get_user_auth()
if not user:
redirect("/user/login")
# We want to limit the number of elements, The user will be able to increase it
nb_elements = max(0, int(app.request.GET.get('nb_elements', '10')))
pbs = app.datamgr.get_problems_time_sorted()
# Filter with the user interests
pbs = only_related_to(pbs, user)
# Keep only nb_elements
pbs = pbs[:nb_elements]
wid = app.request.GET.get('wid', 'widget_last_problems_' + str(int(time.time())))
collapsed = (app.request.GET.get('collapsed', 'False') == 'True')
options = {'nb_elements': {'value': nb_elements, 'type': 'int', 'label': 'Max number of elements to show'},
}
title = 'Last IT problems'
return {'app': app, 'pbs': pbs, 'user': user, 'page': 'problems',
'wid': wid, 'collapsed': collapsed, 'options': options, 'base_url': '/widget/last_problems', 'title': title,
}
开发者ID:chris81,项目名称:shinken,代码行数:28,代码来源:problems.py
示例17: get_launch
def get_launch():
user = app.get_user_auth()
if not user:
redirect("/user/login")
print "Got forms in /newhosts/launch page"
names = app.request.forms.get('names', '')
use_nmap = to_bool(app.request.forms.get('use_nmap', '0'))
use_vmware = to_bool(app.request.forms.get('use_vmware', '0'))
print "Got in request form"
print names
print 'nmap?', use_nmap
print 'vmware?', use_vmware
# We are putting a ask ask in the database
i = random.randint(1, 65535)
scan_ask = {'_id': i, 'names': names, 'use_nmap': use_nmap, 'use_vmware': use_vmware, 'state': 'pending', 'creation': int(time.time())}
print "Saving", scan_ask, "in", app.db.scans
r = app.db.scans.save(scan_ask)
# We just want the id as string, not the object
print "We create the scan", i
app.ask_new_scan(i)
return {'app': app, 'user': user}
开发者ID:BaniaHP,项目名称:shinken,代码行数:26,代码来源:newhosts.py
示例18: post_validatehost
def post_validatehost():
user = app.get_user_auth()
if not user:
redirect("/user/login")
print "Got forms in /newhosts/validatehost call"
_id = app.request.forms.get('_id', 'unknown-host')
use = app.request.forms.get('use', '')
host_name = app.request.forms.get('host_name', None)
print "DUMP FORMS", app.request.forms.__dict__
print "Got in request form", _id, host_name, use
if not host_name:
print "BAD HOST NAME for post_validatehost bail out"
return None
host = {'_id': _id, 'host_name': host_name, 'use': use}
# If there is no such host in db.hosts, just add it.
r = app.db.hosts.find_one({'_id': _id})
print "Already got host?", r
if not r:
print "Saving", host, "in", app.db.hosts
r = app.db.hosts.save(host)
print "Insert result", r
# Set this host as added in the discovered_hosts as _discovery_state='added'
r = app.db.discovered_hosts.update({'_id': _id}, {'$set': {'_discovery_state': 'added'}})
print "result of update", r
return None
开发者ID:BaniaHP,项目名称:shinken,代码行数:31,代码来源:newhosts.py
示例19: show_service
def show_service(hname, desc):
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/user/login")
# return {'app': app, 'elt': None, 'valid_user': False, 'user': user}
# Ok we are in a detail page but the user ask for a specific search
search = app.request.GET.get('global_search', None)
if search:
new_h = app.datamgr.get_host(search)
if new_h:
redirect("/host/" + search)
# Get graph data. By default, show last 4 hours
now = int(time.time())
graphstart = int(app.request.GET.get('graphstart', str(now - 4*3600)))
graphend = int(app.request.GET.get('graphend', str(now)))
# Ok, we can lookup it :)
s = app.datamgr.get_service(hname, desc)
return {'app': app, 'elt': s, 'valid_user': True, 'user': user, 'graphstart': graphstart,
'graphend': graphend}
开发者ID:6jo6jo,项目名称:shinken,代码行数:27,代码来源:eltdetail.py
示例20: get_page
def get_page():
# First we look for the user sid
# so we bail out if it's a false one
user = app.get_user_auth()
if not user:
redirect("/user/login")
return
# We are looking for hosts that got valid GPS coordinates,
# and we just give them to the template to print them.
all_hosts = app.datamgr.get_hosts()
valid_hosts = []
for h in all_hosts:
_lat = h.customs.get('_LAT', None)
_long = h.customs.get('_LONG', None)
try:
print "Host", h.get_name(), _lat, _long, h.customs
except:
pass
if _lat and _long:
try:
_lat = float(_lat)
_long = float(_long)
# Maybe the customs are set, but with invalid float?
except ValueError:
continue
# Look for good range, lat/long must be between -180/180
if -180 <= _lat <= 180 and -180 <= _long <= 180:
print "GOOD VALUES FOR HOST", h.get_name()
valid_hosts.append(h)
# So now we can just send the valid hosts to the template
return {'app': app, 'user': user, 'hosts' : valid_hosts}
开发者ID:David-,项目名称:shinken,代码行数:34,代码来源:worldmap.py
注:本文中的shinken.webui.bottle.redirect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论