On Wed, 28 Aug 2013 12:45:12 +0900 (JST)
[email protected] (YAMAMOTO Takashi) wrote:
> i don't think the patch makes sense.
>
> the real problem is that your command ends up with importing
> two copies of switches module. you can avoid the problem by:
> ryu-manager --verbose --observe-links ryu.topology.switches
I guess that we had better to support passing a file name as a command
line option. Here is a workaround.
diff --git a/ryu/utils.py b/ryu/utils.py
index d5b4479..13415ea 100644
--- a/ryu/utils.py
+++ b/ryu/utils.py
@@ -20,6 +20,7 @@ import logging
import os
import sys
import re
+from oslo.config import cfg
LOG = logging.getLogger('ryu.utils')
@@ -32,7 +33,17 @@ def import_module(modname):
name = os.path.basename(modname)
if name.endswith('.py'):
name = name[:-3]
- __import__(name)
+ try:
+ __import__(name)
+ except cfg.ArgsAlreadyParsedError:
+ # ryu-manager needs to import modules calling
+ # register_cli_opts. Thus, passing a imported file as a
+ # command line option for ryu-manager results in double import
+ # (e.g. ryu.topology.switches). The following code is not
+ # perfect but better than nothing.
+ for key in sys.modules.keys():
+ if key.endswith(name):
+ return sys.modules[key]
return sys.modules[name]
return sys.modules[modname]
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel