test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [dts 1/9] Optimize config load module with proper execption raised
Date: Thu, 18 Jun 2015 11:06:36 +0800	[thread overview]
Message-ID: <1434596804-16846-2-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1434596804-16846-1-git-send-email-yong.liu@intel.com>

From: Marvin Liu <yong.liu@intel.com>

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/config.py b/framework/config.py
index 7e2436a..5948edb 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -37,6 +37,8 @@ import re
 import ConfigParser  # config parse module
 import argparse      # prase arguments module
 
+from exception import ConfigParseException, VirtConfigParseException
+
 PORTCONF = "conf/ports.cfg"
 CRBCONF = "conf/crbs.cfg"
 VIRTCONF = "conf/virt_global.cfg"
@@ -50,7 +52,7 @@ class UserConf():
         if load_files == []:
             print "FAILED LOADING %s!!!" % config
             self.conf = None
-            raise
+            raise ConfigParseException(config)
 
     def get_sections(self):
         if self.conf is None:
@@ -91,9 +93,9 @@ class VirtConf(UserConf):
         self.virt_cfg = {}
         try:
             self.virt_conf = UserConf(self.config_file)
-        except Exception as e:
-            print "FAILED LOADING VIRT CONFIG!!!"
+        except ConfigParseException:
             self.virt_conf = None
+            raise VirtConfigParseException
 
     def load_virt_config(self, name):
         self.virt_cfgs = []
@@ -130,9 +132,9 @@ class PortConf(UserConf):
         self.pci_regex = "([\da-f]{2}:[\da-f]{2}.\d{1})$"
         try:
             self.port_conf = UserConf(self.config_file)
-        except Exception as e:
-            print "FAILED LOADING PORT CONFIG!!!"
+        except ConfigParseException:
             self.port_conf = None
+            raise PortConfigParseException
 
     def load_ports_config(self, crbIP):
         self.ports_cfg = {}
@@ -185,7 +187,10 @@ if __name__ == '__main__':
     args = parser.parse_args()
 
     # not existed configuration file
-    VirtConf('/tmp/not-existed.cfg')
+    try:
+        VirtConf('/tmp/not-existed.cfg')
+    except VirtConfigParseException:
+        print "Capture config parse failure"
 
     # example for basic use configuration file
     conf = UserConf(PORTCONF)
diff --git a/framework/exception.py b/framework/exception.py
index 6e112c8..facbeed 100644
--- a/framework/exception.py
+++ b/framework/exception.py
@@ -131,3 +131,9 @@ class VirtDutConnectException(Exception):
 class VirtDutInitException(Exception):
     def __init__(self, vm_dut):
         self.vm_dut = vm_dut
+
+class VirtDeviceCreateException(Exception):
+    pass
+
+class VirtVmOperationException(Exception):
+    pass
-- 
1.9.3

  reply	other threads:[~2015-06-18  3:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18  3:06 [dts] [dts 0/9] Support virtual scenarios Yong Liu
2015-06-18  3:06 ` Yong Liu [this message]
2015-06-18  3:06 ` [dts] [dts 2/9] Implement virtual scenario module Yong Liu
2015-06-18  3:06 ` [dts] [dts 3/9] Support virtual scenario in dts main process Yong Liu
2015-06-18  3:06 ` [dts] [dts 4/9] Optimize network topology discovery routine in virtual scenario Yong Liu
2015-06-18  3:06 ` [dts] [dts 5/9] Optimize set_target function for " Yong Liu
2015-06-18  3:06 ` [dts] [dts 6/9] Support auto_map and set_target flag in vm initialization Yong Liu
2015-06-18  3:06 ` [dts] [dts 7/9] Optimize VF devices creation and network devices pass-through function Yong Liu
2015-06-18  3:06 ` [dts] [dts 8/9] Optimize ssh_pexpect and virt_resource module Yong Liu
2015-06-18  3:06 ` [dts] [dts 9/9] Add three typical virtual scenario configuration files Yong Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434596804-16846-2-git-send-email-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).