How to use show_host method in tempest

Best Python code snippet using tempest_python

bi.py

Source:bi.py Github

copy

Full Screen

1#!/usr/bin/python2# -*- encoding: utf-8; py-indent-offset: 4 -*-3# +------------------------------------------------------------------+4# | ____ _ _ __ __ _ __ |5# | / ___| |__ ___ ___| | __ | \/ | |/ / |6# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |7# | | |___| | | | __/ (__| < | | | | . \ |8# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |9# | |10# | Copyright Mathias Kettner 2012 mk@mathias-kettner.de |11# +------------------------------------------------------------------+12#13# This file is part of Check_MK.14# The official homepage is at http://mathias-kettner.de/check_mk.15#16# check_mk is free software; you can redistribute it and/or modify it17# under the terms of the GNU General Public License as published by18# the Free Software Foundation in version 2. check_mk is distributed19# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-20# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A21# PARTICULAR PURPOSE. See the GNU General Public License for more de-22# ails. You should have received a copy of the GNU General Public23# License along with GNU Make; see the file COPYING. If not, write24# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,25# Boston, MA 02110-1301 USA.26import bi27# ____ _28# | _ \ __ _| |_ __ _ ___ ___ _ _ _ __ ___ ___ ___29# | | | |/ _` | __/ _` / __|/ _ \| | | | '__/ __/ _ \/ __|30# | |_| | (_| | || (_| \__ \ (_) | |_| | | | (_| __/\__ \31# |____/ \__,_|\__\__,_|___/\___/ \__,_|_| \___\___||___/32#33multisite_datasources["bi_aggregations"] = {34 "title" : _("BI Aggregations"),35 "table" : bi.table,36 "infos" : [ "aggr" ],37 "keys" : [],38 "idkeys" : [ 'aggr_name' ],39}40multisite_datasources["bi_host_aggregations"] = {41 "title" : _("BI Aggregations affected by one host"),42 "table" : bi.host_table,43 "infos" : [ "host", "aggr" ],44 "keys" : [],45 "idkeys" : [ 'aggr_name' ],46}47# Similar to host aggregations, but the name of the aggregation48# is used to join the host table rather then the affected host49multisite_datasources["bi_hostname_aggregations"] = {50 "title" : _("BI Hostname Aggregations"),51 "table" : bi.hostname_table,52 "infos" : [ "host", "aggr" ],53 "keys" : [],54 "idkeys" : [ 'aggr_name' ],55}56# ____ _ _57# | _ \ __ _(_)_ __ | |_ ___ _ __ ___58# | |_) / _` | | '_ \| __/ _ \ '__/ __|59# | __/ (_| | | | | | || __/ | \__ \60# |_| \__,_|_|_| |_|\__\___|_| |___/61#62def paint_aggr_state_short(state, assumed = False):63 if state == None:64 return "", ""65 else:66 name = nagios_short_state_names[state["state"]]67 classes = "state svcstate state%s" % state["state"]68 if assumed:69 classes += " assumed"70 return classes, name71multisite_painters["aggr_state"] = {72 "title" : _("Aggregated state"),73 "short" : _("State"),74 "columns" : [ "aggr_effective_state" ],75 "paint" : lambda row: paint_aggr_state_short(row["aggr_effective_state"], row["aggr_effective_state"] != row["aggr_state"])76}77multisite_painters["aggr_state_num"] = {78 "title" : _("Aggregated state (number)"),79 "short" : _("State"),80 "columns" : [ "aggr_effective_state" ],81 "paint" : lambda row: ("", str(row["aggr_effective_state"]['state']))82}83multisite_painters["aggr_real_state"] = {84 "title" : _("Aggregated real state (never assumed)"),85 "short" : _("R.State"),86 "columns" : [ "aggr_state" ],87 "paint" : lambda row: paint_aggr_state_short(row["aggr_state"])88}89multisite_painters["aggr_assumed_state"] = {90 "title" : _("Aggregated assumed state"),91 "short" : _("Assumed"),92 "columns" : [ "aggr_assumed_state" ],93 "paint" : lambda row: paint_aggr_state_short(row["aggr_assumed_state"])94}95multisite_painters["aggr_group"] = {96 "title" : _("Aggregation group"),97 "short" : _("Group"),98 "columns" : [ "aggr_group" ],99 "paint" : lambda row: ("", row["aggr_group"])100}101multisite_painters["aggr_name"] = {102 "title" : _("Aggregation name"),103 "short" : _("Aggregation"),104 "columns" : [ "aggr_name" ],105 "paint" : lambda row: ("", row["aggr_name"])106}107multisite_painters["aggr_output"] = {108 "title" : _("Aggregation status output"),109 "short" : _("Output"),110 "columns" : [ "aggr_output" ],111 "paint" : lambda row: ("", row["aggr_output"])112}113def paint_aggr_hosts(row, link_to_view):114 h = []115 for site, host in row["aggr_hosts"]:116 url = html.makeuri([("view_name", link_to_view), ("site", site), ("host", host)])117 h.append('<a href="%s">%s</a>' % (url, host))118 return "", " ".join(h)119multisite_painters["aggr_hosts"] = {120 "title" : _("Aggregation: affected hosts"),121 "short" : _("Hosts"),122 "columns" : [ "aggr_hosts" ],123 "paint" : lambda row: paint_aggr_hosts(row, "aggr_host"),124}125multisite_painters["aggr_hosts_services"] = {126 "title" : _("Aggregation: affected hosts (link to host page)"),127 "short" : _("Hosts"),128 "columns" : [ "aggr_hosts" ],129 "paint" : lambda row: paint_aggr_hosts(row, "host"),130}131multisite_painter_options["aggr_expand"] = {132 "title" : _("Initial expansion of aggregations"),133 "default" : "0",134 "values" : [ ("0", "collapsed"), ("1", "first level"), ("2", "two levels"), ("3", "three levels"), ("999", "complete")]135}136multisite_painter_options["aggr_onlyproblems"] = {137 "title" : _("Show only problems"),138 "default" : "0",139 "values" : [ ("0", "show all"), ("1", "show only problems")]140}141multisite_painter_options["aggr_treetype"] = {142 "title" : _("Type of tree layout"),143 "default" : "foldable",144 "values" : [ 145 ("foldable", _("foldable")), 146 ("boxes", _("boxes")),147 ("boxes-omit-root", _("boxes (omit root)")),148 ("bottom-up", _("bottom up")), 149 ("top-down", _("top down"))]150}151multisite_painter_options["aggr_wrap"] = {152 "title" : _("Handling of too long texts"),153 "default" : "wrap",154 "values" : [ ("wrap", "wrap"), ("nowrap", "don't wrap")]155}156def render_bi_state(state):157 return { bi.PENDING: _("PD"),158 bi.OK: _("OK"),159 bi.WARN: _("WA"),160 bi.CRIT: _("CR"),161 bi.UNKNOWN: _("UN"),162 bi.MISSING: _("MI"),163 bi.UNAVAIL: _("NA"),164 }.get(state, _("??"))165def render_assume_icon(site, host, service):166 if service:167 key = (site, host, service)168 else:169 key = (site, host)170 ass = bi.g_assumptions.get(key)171 # TODO: Non-Ascii-Characters do not work yet!172 mousecode = \173 u'onmouseover="this.style.cursor=\'pointer\';" ' \174 'onmouseout="this.style.cursor=\'auto\';" ' \175 'title="%s" ' \176 'onclick="toggle_assumption(this, \'%s\', \'%s\', \'%s\');" ' % \177 (_("Assume another state for this item (reload page to activate)"),178 # MIST: DAS HIER MUSS verfünftig für Javascript encodiert werden.179 # Das Ausgangsmaterial sind UTF-8 kodierte str-Objekte.180 site, host, service != None and service or '')181 current = str(ass).lower()182 return u'<img state="%s" class=assumption %s src="images/assume_%s.png">\n' % (current, mousecode, current)183def aggr_render_leaf(tree, show_host, bare = False):184 site, host = tree[2]["host"]185 service = tree[2].get("service")186 if bare:187 content = u""188 else:189 content = u"" + render_assume_icon(site, host, service)190 # Four cases:191 # (1) zbghora17 . Host status (show_host == True, service == None)192 # (2) zbghora17 . CPU load (show_host == True, service != None)193 # (3) Host Status (show_host == False, service == None)194 # (4) CPU load (show_host == False, service != None)195 if show_host or not service:196 host_url = html.makeuri([("view_name", "hoststatus"), ("site", site), ("host", host)])197 if service:198 service_url = html.makeuri([("view_name", "service"), ("site", site), ("host", host), ("service", service)])199 if show_host:200 content += '<a href="%s">%s</a><b class=bullet>&diams;</b>' % (host_url, host.replace(" ", "&nbsp;"))201 if tree[1] and tree[0] != tree[1]:202 addclass = ' class="state assumed"'203 else:204 addclass = ""205 if not service:206 content += '<a href="%s"%s>%s</a>' % (host_url, addclass, _("Host&nbsp;status"))207 else:208 content += '<a href="%s"%s>%s</a>' % (service_url, addclass, service.replace(" ", "&nbsp;"))209 if bare:210 return content211 else:212 return aggr_render_node(tree, content, None, show_host)213def aggr_render_node(tree, title, mousecode, show_host):214 # Check if we have an assumed state: comparing assumed state (tree[1]) with state (tree[0])215 if tree[1] and tree[0] != tree[1]:216 addclass = " " + _("assumed")217 effective_state = tree[1]218 else:219 addclass = ""220 effective_state = tree[0]221 h = '<span class="content state state%d%s">%s</span>\n' \222 % (effective_state["state"], addclass, render_bi_state(effective_state["state"]))223 if mousecode:224 h += '<img class=opentree %s>' % mousecode225 h += '<span class="content name">%s</span>' % title226 else:227 h += title228 output = format_plugin_output(effective_state["output"])229 if output:230 output = "<b class=bullet>&diams;</b>" + output231 else:232 output = ""233 h += '<span class="content output">%s</span>\n' % output234 return h235# Convert tree to tree contain only node in non-OK state236def filter_tree_only_problems(tree):237 state, assumed_state, node, subtrees = tree238 # remove subtrees in state OK239 new_subtrees = []240 for subtree in subtrees:241 effective_state = subtree[1] != None and subtree[1] or subtree[0]242 if effective_state["state"] != bi.OK:243 if len(subtree) == 3:244 new_subtrees.append(subtree)245 else:246 new_subtrees.append(filter_tree_only_problems(subtree))247 return state, assumed_state, node, new_subtrees248def paint_aggr_tree_foldable(row, boxes, omit_root=True):249 saved_expansion_level = bi.load_ex_level()250 treestate = weblib.get_tree_states('bi')251 expansion_level = int(get_painter_option("aggr_expand"))252 if expansion_level != saved_expansion_level:253 treestate = {}254 weblib.set_tree_states('bi', treestate)255 weblib.save_tree_states()256 mousecode = \257 'onmouseover="this.style.cursor=\'pointer\';" ' \258 'onmouseout="this.style.cursor=\'auto\';" ' \259 'onclick="bi_toggle_%s(this);" ' % (boxes and "box" or "subtree")260 def render_subtree(tree, path, show_host):261 is_leaf = len(tree) == 3262 path_id = "/".join(path)263 is_open = treestate.get(path_id)264 if is_open == None:265 is_open = len(path) <= expansion_level266 h = ""267 268 state = tree[0]269 # Variant: BI-Boxes270 if boxes:271 # Check if we have an assumed state: comparing assumed state (tree[1]) with state (tree[0])272 if tree[1] and tree[0] != tree[1]:273 addclass = " " + _("assumed")274 effective_state = tree[1]275 else:276 addclass = ""277 effective_state = tree[0]278 if is_leaf:279 leaf = "leaf"280 mc = ""281 else:282 leaf = "noleaf"283 mc = mousecode284 omit = omit_root and len(path) == 1285 if not omit:286 h += '<span id="%d:%s" %s class="bibox_box %s %s state state%s%s">' % (287 expansion_level, path_id, mc, leaf, is_open and "open" or "closed", effective_state["state"], addclass)288 if is_leaf:289 h += aggr_render_leaf(tree, show_host, bare = True) # .replace(" ", "&nbsp;")290 else:291 h += tree[2]["title"].replace(" ", "&nbsp;")292 h += '</span> '293 if not is_leaf:294 h += '<span class="bibox" style="%s">' % ((not is_open and not omit) and "display: none;" or "")295 parts = []296 for node in tree[3]:297 new_path = path + [node[2]["title"]]298 h += render_subtree(node, new_path, show_host)299 h += '</span>'300 return h301 # Variant: foldable trees302 else:303 if is_leaf: # leaf304 return aggr_render_leaf(tree, show_host, bare = boxes)305 h += '<span class=title>'306 is_empty = len(tree[3]) == 0307 if is_empty:308 style = ''309 mc = ''310 elif is_open:311 style = ''312 mc = mousecode + 'src="images/tree_black_90.png" '313 else:314 style = 'style="display: none" '315 mc = mousecode + 'src="images/tree_black_00.png" '316 h += aggr_render_node(tree, tree[2]["title"], mc, show_host)317 if not is_empty:318 h += '<ul id="%d:%s" %sclass="subtree">' % (expansion_level, path_id, style)319 for node in tree[3]:320 estate = node[1] != None and node[1] or node[0]321 if not node[2].get("hidden"):322 new_path = path + [node[2]["title"]]323 h += '<li>' + render_subtree(node, new_path, show_host) + '</li>\n'324 h += '</ul>'325 return h + '</span>\n'326 tree = row["aggr_treestate"]327 if get_painter_option("aggr_onlyproblems") == "1":328 tree = filter_tree_only_problems(tree)329 affected_hosts = row["aggr_hosts"]330 htmlcode = render_subtree(tree, [tree[2]["title"]], len(affected_hosts) > 1)331 return "aggrtree" + (boxes and "_box" or ""), htmlcode332def paint_aggr_tree_ltr(row, mirror):333 wrap = get_painter_option("aggr_wrap")334 if wrap == "wrap":335 td = '<td'336 else:337 td = '<td style="white-space: nowrap;"'338 def gen_table(tree, height, show_host):339 if len(tree) == 3:340 return gen_leaf(tree, height, show_host)341 else:342 return gen_node(tree, height, show_host)343 def gen_leaf(tree, height, show_host):344 return [(aggr_render_leaf(tree, show_host), height, [])]345 def gen_node(tree, height, show_host):346 leaves = []347 for node in tree[3]:348 if not node[2].get("hidden"):349 leaves += gen_table(node, height - 1, show_host)350 h = '<div class="aggr tree">' + aggr_render_node(tree, tree[2]["title"], '', show_host) + "</div>"351 if leaves:352 leaves[0][2].append((len(leaves), h))353 return leaves354 tree = row["aggr_treestate"]355 if get_painter_option("aggr_onlyproblems") == "1":356 tree = filter_tree_only_problems(tree)357 depth = bi.status_tree_depth(tree)358 leaves = gen_table(tree, depth, row["aggr_hosts"] > 1)359 h = '<table class="aggrtree">'360 odd = "odd"361 for code, colspan, parents in leaves:362 h += '<tr>\n'363 leaf_td = td + ' class="leaf %s"' % odd364 odd = odd == "odd" and "even" or "odd"365 if colspan > 1:366 leaf_td += ' colspan=%d' % colspan367 leaf_td += '>%s</td>\n' % code368 tds = [leaf_td]369 for rowspan, c in parents:370 tds.append(td + ' class=node rowspan=%d>%s</td>\n' % (rowspan, c))371 if mirror:372 tds.reverse()373 h += "".join(tds)374 h += '</tr>\n'375 h += '</table>'376 return "aggrtree", h377def paint_aggregated_tree_state(row):378 treetype = get_painter_option("aggr_treetype")379 if treetype == "foldable":380 return paint_aggr_tree_foldable(row, boxes = False, omit_root = False)381 elif treetype == "boxes":382 return paint_aggr_tree_foldable(row, boxes = True, omit_root = False)383 elif treetype == "boxes-omit-root":384 return paint_aggr_tree_foldable(row, boxes = True, omit_root = True)385 elif treetype == "bottom-up":386 return paint_aggr_tree_ltr(row, False)387 elif treetype == "top-down":388 return paint_aggr_tree_ltr(row, True)389multisite_painters["aggr_treestate"] = {390 "title" : _("Aggregation: complete tree"),391 "short" : _("Tree"),392 "columns" : [ "aggr_treestate", "aggr_hosts" ],393 "options" : [ "aggr_expand", "aggr_onlyproblems", "aggr_treetype", "aggr_wrap" ],394 "paint" : paint_aggregated_tree_state,395}396multisite_painters["aggr_treestate_boxed"] = {397 "title" : _("Aggregation: simplistic boxed layout"),398 "short" : _("Tree"),399 "columns" : [ "aggr_treestate", "aggr_hosts" ],400 "paint" : lambda row: paint_aggr_tree_foldable(row, boxes = True, omit_root = True),401}402# _____ _ _ _403# | ___(_) | |_ ___ _ __ ___404# | |_ | | | __/ _ \ '__/ __|405# | _| | | | || __/ | \__ \406# |_| |_|_|\__\___|_| |___/407#408class BIGroupFilter(Filter):409 def __init__(self):410 self.column = "aggr_group"411 Filter.__init__(self, self.column, _("Aggregation group"), "aggr", [self.column], [self.column])412 def variable_settings(self, row):413 return [ (self.htmlvars[0], row[self.column]) ]414 def display(self):415 htmlvar = self.htmlvars[0]416 html.select(htmlvar, [ ("", "") ] + [(g, g) for g in bi.aggregation_groups()])417 def selected_group(self):418 return html.var(self.htmlvars[0])419 def filter_table(self, rows):420 group = self.selected_group()421 if not group:422 return rows423 else:424 return [ row for row in rows if row[self.column] == group ]425 def heading_info(self, infoname):426 return html.var(self.htmlvars[0])427declare_filter( 90, BIGroupFilter())428class BITextFilter(Filter):429 def __init__(self, what):430 self.column = "aggr_" + what431 label = ''432 if what == 'name':433 label = _('Aggregation name')434 elif what == 'output':435 label = _('Aggregation output')436 Filter.__init__(self, self.column, label, "aggr", [self.column], [self.column])437 def variable_settings(self, row):438 return [ (self.htmlvars[0], row[self.column]) ]439 def display(self):440 html.text_input(self.htmlvars[0])441 def heading_info(self, infoname):442 return html.var(self.htmlvars[0])443 def filter_table(self, rows):444 val = html.var(self.htmlvars[0])445 if not val:446 return rows447 reg = re.compile(val.lower())448 return [ row for row in rows if reg.search(row[self.column].lower()) ]449declare_filter(120, BITextFilter("name"))450declare_filter(121, BITextFilter("output"))451class BIHostFilter(Filter):452 def __init__(self):453 self.column = "aggr_hosts"454 Filter.__init__(self, self.column, _("Affected hosts contain"), "aggr", ["site", "host"], [])455 def display(self):456 html.text_input(self.htmlvars[1])457 def heading_info(self, infoname):458 return html.var(self.htmlvars[1])459 def find_host(self, host, hostlist):460 for s, h in hostlist:461 if h == host:462 return True463 return False464 # Used for linking465 def variable_settings(self, row):466 return [ ("host", row["host_name"]), ("site", row["site"]) ]467 def filter_table(self, rows):468 val = html.var(self.htmlvars[1])469 if not val:470 return rows471 return [ row for row in rows if self.find_host(val, row["aggr_hosts"]) ]472declare_filter(130, BIHostFilter(), _("Filter for all aggregations that base on status information of that host. Exact match (no regular expression)"))473class BIServiceFilter(Filter):474 def __init__(self):475 Filter.__init__(self, "aggr_service", _("Affected by service"), "aggr", ["site", "host", "service"], [])476 def double_height(self):477 return True478 def display(self):479 html.write(_("Host") + ": ")480 html.text_input("host")481 html.write(_("Service") + ": ")482 html.text_input("service")483 def heading_info(self, infoname):484 return html.var_utf8("host") + " / " + html.var_utf8("service")485 def service_spec(self):486 return html.var_utf8("site"), html.var_utf8("host"), html.var_utf8("service")487 # Used for linking488 def variable_settings(self, row):489 return [ ("site", row["site"]), ("host", row["host_name"]), ("service", row["service_description"]) ]490declare_filter(131, BIServiceFilter(), _("Filter for all aggregations that are affected by one specific service on a specific host (no regular expression)"))491class BIStatusFilter(Filter):492 def __init__(self, what):493 title = (what.replace("_", " ") + " state").title()494 self.column = "aggr_" + what + "state"495 if what == "":496 self.code = 'r'497 else:498 self.code = what[0]499 self.prefix = "bi%ss" % self.code500 vars = [ self.prefix + str(x) for x in [ -1, 0, 1, 2, 3 ] ]501 if self.code == 'a':502 vars.append(self.prefix + "n")503 Filter.__init__(self, self.column, title, "aggr", vars, [])504 def filter(self, tablename):505 return ""506 def double_height(self):507 return self.column == "aggr_assumed_state"508 def display(self):509 if html.var("filled_in"):510 defval = ""511 else:512 defval = "on"513 for varend, text in [('0', 'OK'), ('1', 'WARN'), ('2', 'CRIT'), 514 ('3', 'UNKN'), ('-1', 'PENDING'), ('n', _('no assumed state set'))]:515 if self.code != 'a' and varend == 'n':516 continue # no unset for read and effective state517 if varend == 'n':518 html.write("<br>")519 var = self.prefix + varend520 html.checkbox(var, defval, label = text)521 def filter_table(self, rows):522 jeaders = []523 if html.var("filled_in"):524 defval = ""525 else:526 defval = "on"527 allowed_states = []528 for i in ['0','1','2','3','-1','n']:529 if html.var(self.prefix + i, defval) == "on":530 if i == 'n':531 s = None532 else:533 s = int(i)534 allowed_states.append(s)535 newrows = []536 for row in rows:537 if row[self.column] != None:538 s = row[self.column]["state"]539 else:540 s = None541 if s in allowed_states:542 newrows.append(row)543 return newrows544declare_filter(150, BIStatusFilter(""))545declare_filter(151, BIStatusFilter("effective_"))...

Full Screen

Full Screen

host_modify.py

Source:host_modify.py Github

copy

Full Screen

1# -*- coding: UTF-8 –*-.2import sys3def show_host():4 host_path="C:\Windows\System32\drivers\etc\hosts"5 host_file=open(host_path,"r")6 host_list=[]7 while 1:8 line = host_file.readline()9 if not line:10 break11 host_list.append(line)12 host_file.close()13 return host_list1415def host_write(host_list,ip,host_name):16 host_path="C:\Windows\System32\drivers\etc\hosts"17 host_file=open(host_path,"w")18 write=019 content=""20 for line in range(len(host_list)):21 if(host_list[line][0]!="#" and (host_name==host_list[line].split(' ')[1])):22 host_list[line]=ip+' '+host_name+'\n'23 write=124 if(write==0):25 host_list.append(ip+' '+host_name+'\n')26 for line in host_list:27 content+=line28 host_file.write(content)29 host_file.close()3031def host_remove(host_list,host_name):32 write=033 content=""34 for line in range(len(host_list)):35 if(host_list[line][0]!="#" and (host_name==host_list[line].split(' ')[1])):36 host_list[line]=''37 write=138 if(write==1):39 for line in host_list:40 content+=line41 host_path="C:\Windows\System32\drivers\etc\hosts"42 host_file=open(host_path,"w")43 host_file.write(content)44 host_file.close()45 else:46 print 'no host to remove.'474849if __name__=='__main__':50 operator=05152 if(len(sys.argv)==2):53 if(sys.argv[1]=='--show-host'):54 operator=155 host_list=show_host()56 for i in host_list:57 print i,58 #if(sys.argv[1]=='--set-backup'):59 #if(sys.argv[1]=='--get-backup')6061 if(len(sys.argv)==3):62 if(sys.argv[1]=='--remove'):63 operator=164 host_list=show_host()65 host_remove(host_list,sys.argv[2])66 67 if(len(sys.argv)==4):68 if(sys.argv[1]=='--add'):69 operator=170 host_list=show_host()71 host_write(host_list,sys.argv[2],sys.argv[3])7273 if(operator==0):74 print '--show-host'75 #print '--set-backup'76 #print '--get-backup'77 print '--add ip hostname' ...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1"""ebooking URL Configuration2The `urlpatterns` list routes URLs to views. For more information please see:3 https://docs.djangoproject.com/en/4.0/topics/http/urls/4Examples:5Function views6 1. Add an import: from my_app import views7 2. Add a URL to urlpatterns: path('', views.home, name='home')8Class-based views9 1. Add an import: from other_app.views import Home10 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')11Including another URLconf12 1. Import the include() function: from django.urls import include, path13 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))14"""15from django.contrib import admin16from django.urls import path17from ebooking import views18urlpatterns = [19 path('', views.home, name="home"),20 path('register', views.register, name="register"),21 path('admin', admin.site.urls),22 path('login', views.login, name="login"),23 path('logout', views.logout, name="logout"),24 path('list_rooms', views.list_rooms, name="list_rooms"),25 path('book_room', views.book_room, name="book_room"),26 path('update_room/<str:pk>/', views.update_room, name="update_room"),27 path('delete_room/<str:pk>/', views.delete_room, name="delete_room"),28 path('show_room/<str:pk>/', views.show_room, name="show_room"),29 path('show_host/<str:pk>/', views.show_host, name="show_host"),...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful