mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-13 16:46:40 +02:00
app/client: add helper function to ignore NOT_FOUND, 404
Sometimes client code just wants to ignore 404 when deleting resources. So provide helper function for it. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
7ac93f4615
commit
73fa069e72
@ -18,6 +18,19 @@ import httplib
|
||||
import urlparse
|
||||
|
||||
|
||||
def ignore_http_not_found(func):
|
||||
"""
|
||||
Ignore http not found(404) with Ryu client library.
|
||||
Ryu client raises httplib.HTTPException with an error in args[0]
|
||||
"""
|
||||
try:
|
||||
func()
|
||||
except httplib.HTTPException as e:
|
||||
res = e.args[0]
|
||||
if res.status != httplib.NOT_FOUND:
|
||||
raise
|
||||
|
||||
|
||||
class RyuClientBase(object):
|
||||
def __init__(self, version, address):
|
||||
super(RyuClientBase, self).__init__()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user