summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2012-03-26 11:54:12 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-02-04 22:32:43 +0900
commit73fa069e72e185eddf0035c9032396c6737d3f98 (patch)
tree9fa427d4965f004ea8990c78dcc17dad9b09dc9c
parent7ac93f4615950e43819a9de259f14e073d4a4d4d (diff)
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>
-rw-r--r--ryu/app/client.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/ryu/app/client.py b/ryu/app/client.py
index d54fe44c..fcf12839 100644
--- a/ryu/app/client.py
+++ b/ryu/app/client.py
@@ -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__()