本文整理汇总了Python中yapc.log.output.dbg函数的典型用法代码示例。如果您正苦于以下问题:Python dbg函数的具体用法?Python dbg怎么用?Python dbg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, sock, msg):
"""Initialize
@param sock reference to socket
@param msg message
"""
ofcomm.message.__init__(self, sock, msg)
##Features struct
self.features = None
if (self.header.type == pyof.OFPT_FEATURES_REPLY):
self.features = pyof.ofp_switch_features()
r = self.features.unpack(msg)
while (len(r) >= pyof.OFP_PHY_PORT_BYTES):
p = pyof.ofp_phy_port()
r = p.unpack(r)
self.features.ports.append(p)
if (len(r) > 0):
output.warn("Features reply is of irregular length with "+\
str(len(r))+" bytes remaining.",
self.__class__.__name__)
output.dbg("Received switch features:\n"+\
self.features.show("\t"),
self.__class__.__name__)
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:25,代码来源:openflow.py
示例2: processevent
def processevent(self, event):
"""Process all the events registered for
Check for packet-in and :
create packet out with FLOOD action
send it (oops.. do check the buffer id to see if buffered)
@param event event to handle
"""
if (isinstance(event, ofevents.pktin)):
output.dbg("Receive an OpenFLow packet in :\n"+\
event.pktin.show(),
self.__class__.__name__)
flow = flows.exact_entry(event.match)
flow.set_buffer(event.pktin.buffer_id)
flow.add_output(pyof.OFPP_FLOOD)
if (event.pktin.buffer_id == flows.UNBUFFERED_ID):
##Not buffered
self.conn.send(event.sock, flow.get_packet_out().pack()+event.pkt)
output.vdbg("Flood unbuffered packet with match "+\
event.match.show().replace('\n',';'))
else:
##Buffered packet
self.conn.send(event.sock,flow.get_packet_out().pack())
output.vdbg("Flood buffered packet with match "+\
event.match.show().replace('\n',';'))
return True
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:31,代码来源:yapc-tutorial.py
示例3: processevent
def processevent(self, event):
"""Process events
@param event event
"""
if (isinstance(event, jsoncomm.message) and
event.message["type"] == "coin" and
event.message["command"] == "query"):
output.dbg("Received query "+str(event.message),
self.__class__.__name__)
q = query(event.message["name"],
event.message["selection"],
event.message["condition"])
self.server.post_event(q)
self.__q[q] = event.sock
elif (isinstance(event, queryresponse)):
reply = {}
reply["type"] = "coin"
reply["subtype"] = "query response"
reply["reply"] = event.response
self.jsonconnections.db[self.__q[event.query]].send(reply)
del self.__q[event.query]
return True
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:25,代码来源:information.py
示例4: add_interfaces
def add_interfaces(self, interfaces):
"""Add interfaces (plus mirror port)
@param interfaces list of interfaces
"""
for i in interfaces:
self.switch.add_if(i)
self.ifmgr.set_ipv4_addr(i, "0.0.0.0")
# Add mirror interface
self.mirror[i] = self.add_loif(i)
ieth = self.ifmgr.ethernet_addr(i)
self.ifmgr.set_eth_addr(self.mirror[i].client_intf, ieth)
np = self.switch.get_ports()
port1 = np[i]
port2 = np[self.mirror[i].switch_intf]
# Set perm DHCP rules for mirror
dreq = flows.udp_entry(portno=68, priority=ofutil.PRIORITY["LOW"])
dreq.set_in_port(port1)
dreq.add_output(port2, 65535)
self.default.add_perm(dreq)
drep = flows.udp_entry(portno=67, priority=ofutil.PRIORITY["LOW"])
drep.set_in_port(port2)
drep.add_output(port1, 65535)
self.default.add_perm(drep)
output.dbg(
"Set " + self.mirror[i].client_intf + " to " + self.ifmgr.ethernet_addr(i), self.__class__.__name__
)
开发者ID:yapkke,项目名称:yapc,代码行数:29,代码来源:nat.py
示例5: POST
def POST(self):
# unlike the usual scheme of things, the POST is actually called
# first here
i = web.input(return_to='/')
if i.get('action') == 'logout':
web.webopenid.logout()
return web.redirect(i.return_to)
i = web.input('openid', return_to='/')
going = owevent.going_to_auth(owglobal.session.datapath,
owglobal.session.host,
i['openid'])
owglobal.server.post_event(going)
output.dbg(str(owglobal.session.host)+\
" is going to "+going.server()+" to authenticate",
self.__class__.__name__)
n = web.webopenid._random_session()
web.webopenid.sessions[n] = {'webpy_return_to': i.return_to}
c = openid.consumer.consumer.Consumer(web.webopenid.sessions[n],
web.webopenid.store)
a = c.begin(i.openid)
f = a.redirectURL(web.ctx.home, web.ctx.home + web.ctx.fullpath)
web.setcookie('openid_session_id', n)
return web.redirect(f)
开发者ID:carriercomm,项目名称:OpenWiFi,代码行数:27,代码来源:webpage.py
示例6: POST
def POST(self):
uname = str(web.input()['userName'])
a = owevent.authenticated(owglobal.session.datapath,
owglobal.session.host,
"Facebook:"+uname)
owglobal.server.post_event(a)
output.dbg(str(owglobal.session.host)+\
" is authenticated with %s" % uname,
self.__class__.__name__)
return '''
<html><head><title>Open WiFi: Towards Access Everywhere...</title></head>
<body>
<center>
<h2>Welcome to OpenWiFi<sup>beta</sup>!</h2>
<h4>A Stanford Research Project</h4>
<table align=centerwidth=600 border=0>
<td><tr>Hi %s, hope you will enjoy OpenWiFi!
</td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td>
<a href="about">About OpenWiFi</a>  
<a href="tos">Terms of Service</a>.
</td></tr>
</table>
</center>
</body>
</html>
''' % uname
开发者ID:carriercomm,项目名称:OpenWiFi,代码行数:30,代码来源:facebookwebpage.py
示例7: cleanup
def cleanup(self):
"""Clean up
"""
output.dbg("Cleaning up database",
self.__class__.__name__)
self.flush()
self.close()
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:7,代码来源:sqlite.py
示例8: __process_switch_json
def __process_switch_json(self, event):
"""Process JSON messages for switch
@param event JSON message event for switch
"""
reply = {}
reply["type"] = "coin"
reply["subtype"] = "ovs"
if event.message["command"] == "add_if":
self.add_if(event.message["name"])
reply["executed"] = True
elif event.message["command"] == "del_if":
self.datapaths[COIN_DP_NAME].del_if(event.message["name"])
reply["executed"] = True
elif event.message["command"] == "get_interfaces":
dpidsl = mc.get(swstate.dp_features.DP_SOCK_LIST)
if dpidsl != None:
reply["interfaces"] = []
if len(dpidsl) > 1:
output.warn(str(len(dpidsl)) + " datapaths connected to COIN", self.__class__.__name__)
f = mc.get(dpidsl[0])
output.dbg("Updated switch features:\n" + f.show("\t"), self.__class__.__name__)
for p in f.ports:
reply["interfaces"].append(p.name)
else:
output.warn("No datapaths connected to COIN", self.__class__.__name__)
reply["error"] = "No datapath connected"
else:
reply["error"] = "Unknown command"
return reply
开发者ID:yapkke,项目名称:yapc,代码行数:32,代码来源:ovs.py
示例9: _processglobal
def _processglobal(self, event):
"""Process mode related JSON messages
@param event yapc.jsoncomm.message event
"""
reply = {}
reply["type"] = "coin"
if (event.message["command"] == "get_all_config"):
reply["subtype"] = "config"
reply["value"] = self.config
elif (event.message["command"] == "get_config"):
reply["subtype"] = "config"
reply["value"] = self.get_config(event.message["name"])
elif (event.message["command"] == "set_config"):
reply["subtype"] = "config"
reply["previous value"] = self.get_config(event.message["name"])
self.set_config(event.message["name"], event.message["value"])
reply["current value"] = str(self.get_config(event.message["name"]))
elif (event.message["command"] == "get_eth_interfaces"):
reply["subtype"] = "interfaces"
reply["interfaces"] = self.ifmgr.ethernet_ipv4_addresses()
else:
output.dbg("Receive message "+str(event.message),
self.__class__.__name__)
return None
return reply
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:28,代码来源:core.py
示例10: _handle_change
def _handle_change(self, flow_stats):
"""Handle flows to be changed based on flow stats reply
@param flow_stats flow_stats event
"""
self.check_timeout()
for f in flow_stats.flows:
for (new, old) in self.ip_change.items():
if f.match.nw_src == old[0]:
flow = flows.exact_entry(
f.match, priority=f.priority, idle_timeout=f.idle_timeout, hard_timeout=f.hard_timeout
)
flow.set_nw_src(new)
flow.add_nw_rewrite(True, old)
flow.actions.extend(f.actions)
self.get_conn().send(flow.get_flow_mod(pyof.OFPFC_MODIFY, f.cookie).pack())
output.dbg(str(f) + " has old source IP (flow rule is added)", self.__class__.__name__)
elif f.match.nw_dst == old[0]:
flow = flows.exact_entry(
f.match, priority=f.priority, idle_timeout=f.idle_timeout, hard_timeout=f.hard_timeout
)
flow.add_nw_rewrite(False, new)
flow.actions.extend(f.actions)
self.get_conn().send(flow.get_flow_mod(pyof.OFPFC_MODIFY, f.cookie).pack())
output.dbg(str(f) + " has old destination IP (flow rule is modified)", self.__class__.__name__)
开发者ID:yapkke,项目名称:yapc,代码行数:25,代码来源:bridge.py
示例11: __del__
def __del__(self):
"""Clean up all datapath
"""
output.dbg("Cleaning up datapaths",
self.__class__.__name__)
for name,dp in self.datapaths.items():
self.del_dp(name)
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:7,代码来源:ovs.py
示例12: cleanup
def cleanup(self):
"""Clean up interfaces
"""
output.dbg("Cleaning up veth interfaces",
self.__class__.__name__)
for v in self.veth:
v.__del__()
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:7,代码来源:netintf.py
示例13: random_select_intf
def random_select_intf(self, intfs):
"""Get which interface to send (random choice)
@return port no to send flow on and None if nothing to choose from
"""
c = random.choice(intfs.keys())
output.dbg("Port " + str(c) + " " + str(intfs[c]) + " randomly selected", self.__class__.__name__)
return c
开发者ID:yapkke,项目名称:yapc,代码行数:8,代码来源:nat.py
示例14: get_null_terminated_str
def get_null_terminated_str(s):
"""Get null terminated string
@param s referenence to string
"""
output.dbg(str(struct.unpack("B"*len(s), s)),
"parse utility")
return s[:s.find('\x00')]
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:8,代码来源:parse.py
示例15: add_dp
def add_dp(self, name):
"""Add datapath with name
@param name name of datapath
"""
output.dbg("Add datapath "+name,
self.__class__.__name__)
self.datapaths[name] = datapath(name)
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:8,代码来源:ovs.py
示例16: send
def send(self, msg):
"""Send dictionary as JSON message
"""
try:
self.sock.send(simplejson.dumps(msg))
output.dbg("Send message " + simplejson.dumps(msg), self.__class__.__name__)
except socket.error:
output.warn(str(self.sock) + " is broken, message is dropped!", self.__class__.__name__)
开发者ID:yapkke,项目名称:yapc,代码行数:8,代码来源:json.py
示例17: addconnection
def addconnection(self, sock, manager):
"""Add socket and manager
"""
if (sock not in self.__sockets):
self.__sockets.append(sock)
self.__sockDictionary[sock] = manager
output.dbg("Adding "+str(sock)+" to select list",
self.__class__.__name__)
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:8,代码来源:core.py
示例18: receive
def receive(self, sock, recvthread):
"""Receive new connection
"""
client, address = sock.accept()
if not comm.BLOCKING:
client.setblocking(0)
recvthread.addconnection(client, jsonsockmanager(client, self.scheduler))
self.scheduler.post_event(comm.event(client, comm.event.SOCK_OPEN))
output.dbg("Connection to " + str(address) + " added", self.__class__.__name__)
开发者ID:yapkke,项目名称:yapc,代码行数:9,代码来源:json.py
示例19: print_event_handlers
def print_event_handlers(self):
"""Output event and handlers for it
"""
for e,handles in self._processors.items():
output.dbg("Event "+e+" in order handled by:",
self.__class__.__name__)
for h in handles:
output.dbg("\t"+h.__class__.__name__,
self.__class__.__name__)
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:9,代码来源:core.py
示例20: removeconnection
def removeconnection(self, sock):
"""Remove socket
"""
if (sock in self.__sockDictionary):
del self.__sockDictionary[sock]
if (sock in self.__sockets):
self.__sockets.remove(sock)
output.dbg("Removing "+str(sock)+" to select list",
self.__class__.__name__)
开发者ID:sharifelshenawy,项目名称:yapc,代码行数:9,代码来源:core.py
注:本文中的yapc.log.output.dbg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论