Hi Derek,

Many thanks for the patch.  Do you mind sending me the patch zipped or
tarballed?  Sorry Gmail reformats things a little, so the
git-format-patch output is distorted.

Regards
KK

On 21 December 2010 23:38, Derek Cormier <derek.corm...@lab.ntt.co.jp> wrote:
> Hello,
>
> I would like to start contributing to the Nox code. This is my first time
> contributing to open source software, and I'm still new to git, so I don't
> know the exact process. I've seen some people post patch files, so I'll
> include a small change I made here.
>
> Recently the Error_event was made available in the python API, but core.py
> didn't have an easier member function to register errors (had to register
> using the Error_event.get_static_name() etc..). This isn't incredibly
> useful, but I just wanted to try contributing for the first time. Please let
> me know if I didn't do this right.
>
> Thanks!
> Derek
>
>
> From ea590df29ae342bb9029b90829fa1ddf3ff36d10 Mon Sep 17 00:00:00 2001
> From: Derek Cormier <cormier.de...@gmail.com>
> Date: Wed, 22 Dec 2010 16:18:33 +0900
> Subject: [PATCH] Allow python components to register for error events
> through a class method.
>
> ---
>  src/nox/lib/core.py |   10 ++++++++++
>  src/nox/lib/util.py |    9 +++++++++
>  2 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/src/nox/lib/core.py b/src/nox/lib/core.py
> index 3b994c6..70cdb48 100644
> --- a/src/nox/lib/core.py
> +++ b/src/nox/lib/core.py
> @@ -678,6 +678,16 @@ class Component:
>         self.register_handler(Switch_mgr_leave_event.static_get_name(),
>                               gen_switch_mgr_leave_cb(handler))
>
> +    def register_for_error(self, handler):
> +        """
> +        register a handler to be called on every error
> +        event handler will be called with the following args:
> +
> +        handler(type, code, data, xid)
> +        """
> +        self.register_handler(Error_event.static_get_name(),
> +                              gen_error_cb(handler))
> +
>     def unregister_handler(self, rule_id):
>         """
>         Unregister a handler for match.
> diff --git a/src/nox/lib/util.py b/src/nox/lib/util.py
> index a192826..aa4b807 100644
> --- a/src/nox/lib/util.py
> +++ b/src/nox/lib/util.py
> @@ -239,6 +239,15 @@ def gen_switch_mgr_leave_cb(handler):
>     f.cb = handler
>     return f
>
> +def gen_error_cb(handler):
> +    def f(event):
> +        ret = f.cb(event.type, event.code, event.data, event.xid)
> +        if ret == None:
> +            return CONTINUE
> +        return ret
> +    f.cb = handler
> +    return f
> +
>  def set_match(attrs):
>     m = openflow.ofp_match()
>     wildcards = 0
> --
> 1.7.0.4
>
>
>
> _______________________________________________
> nox-dev mailing list
> nox-dev@noxrepo.org
> http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org
>

_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org

Reply via email to