Commit 2ff181e5 authored by Nicolas Chevillot's avatar Nicolas Chevillot

Replaced sys.exit with exception

parent f6ba3e94
...@@ -38,7 +38,7 @@ def set_logging_level(options): ...@@ -38,7 +38,7 @@ def set_logging_level(options):
"""Set the log level and config (A.K.A. log verbosity)""" """Set the log level and config (A.K.A. log verbosity)"""
numeric_level = getattr(logging, options.log.upper(), None) numeric_level = getattr(logging, options.log.upper(), None)
if not isinstance(numeric_level, int): if not isinstance(numeric_level, int):
sys.exit('Invalid log level: %s' % options.log) raise Exception('Invalid log level: %s' % options.log)
if not shell.check_windows() and options.logfile == None: if not shell.check_windows() and options.logfile == None:
logging.basicConfig( logging.basicConfig(
...@@ -117,11 +117,10 @@ class Action(list): ...@@ -117,11 +117,10 @@ class Action(list):
def _check_manifest_variable_is_set(self, name): def _check_manifest_variable_is_set(self, name):
"""Method to check if a specific manifest variable is set""" """Method to check if a specific manifest variable is set"""
if getattr(self.top_module, name) is None: if getattr(self.top_module, name) is None:
logging.error( raise Exception(
"Variable %s must be set in the manifest " "Variable %s must be set in the manifest "
"to perform current action (%s)", "to perform current action (%s)",
name, self.__class__.__name__) name, self.__class__.__name__)
sys.exit("\nExiting")
def _check_manifest_variable_value(self, name, value): def _check_manifest_variable_value(self, name, value):
"""Method to check if a manifest variable is set to a specific value""" """Method to check if a manifest variable is set to a specific value"""
...@@ -131,10 +130,9 @@ class Action(list): ...@@ -131,10 +130,9 @@ class Action(list):
variable_match = True variable_match = True
if variable_match is False: if variable_match is False:
logging.error( raise Exception(
"Variable %s must be set in the manifest and equal to '%s'.", "Variable %s must be set in the manifest and equal to '%s'.",
name, value) name, value)
sys.exit("Exiting")
def build_complete_file_set(self): def build_complete_file_set(self):
"""Build file set with all the files listed in the complete pool""" """Build file set with all the files listed in the complete pool"""
......
...@@ -83,8 +83,7 @@ class ActionCore(Action): ...@@ -83,8 +83,7 @@ class ActionCore(Action):
elif module.source is LOCAL: elif module.source is LOCAL:
result = self.local_backend.fetch(module) result = self.local_backend.fetch(module)
if result is False: if result is False:
logging.error("Unable to fetch module %s", str(module.url)) raise Exception("Unable to fetch module %s", str(module.url))
sys.exit("Exiting")
module.parse_manifest() module.parse_manifest()
new_modules.extend(module.local) new_modules.extend(module.local)
new_modules.extend(module.svn) new_modules.extend(module.svn)
......
...@@ -91,10 +91,9 @@ class ModuleConfig(object): ...@@ -91,10 +91,9 @@ class ModuleConfig(object):
return False return False
filepath = os.path.join(self.path, filepath) filepath = os.path.join(self.path, filepath)
if not os.path.exists(filepath): if not os.path.exists(filepath):
logging.error( raise Exception(
"Path specified in manifest in %s doesn't exist: %s", "Path specified in manifest in %s doesn't exist: %s",
self.path, filepath) self.path, filepath)
sys.exit("Exiting")
filepath = path_mod.rel2abs(filepath, self.path) filepath = path_mod.rel2abs(filepath, self.path)
if os.path.isdir(filepath): if os.path.isdir(filepath):
......
...@@ -14,11 +14,9 @@ from hdlmake.srcfile import VerilogFile, VHDLFile, SVFile ...@@ -14,11 +14,9 @@ from hdlmake.srcfile import VerilogFile, VHDLFile, SVFile
def _check_simulation_manifest(manifest_dict): def _check_simulation_manifest(manifest_dict):
"""Check if the simulation keys are provided by the top manifest""" """Check if the simulation keys are provided by the top manifest"""
if not manifest_dict["sim_top"]: if not manifest_dict["sim_top"]:
logging.error("sim_top variable must be set in the top manifest.") raise Exception("sim_top variable must be set in the top manifest.")
sys.exit("Exiting")
if not manifest_dict["sim_tool"]: if not manifest_dict["sim_tool"]:
logging.error("sim_tool variable must be set in the top manifest.") raise Exception("sim_tool variable must be set in the top manifest.")
sys.exit("Exiting")
class ToolSim(ToolMakefile): class ToolSim(ToolMakefile):
......
...@@ -14,21 +14,17 @@ from hdlmake.srcfile import VerilogFile, SVFile ...@@ -14,21 +14,17 @@ from hdlmake.srcfile import VerilogFile, SVFile
def _check_synthesis_manifest(manifest_dict): def _check_synthesis_manifest(manifest_dict):
"""Check the manifest contains all the keys for a synthesis project""" """Check the manifest contains all the keys for a synthesis project"""
if not manifest_dict["syn_tool"]: if not manifest_dict["syn_tool"]:
logging.error( raise Exception(
"syn_tool variable must be set in the top manifest.") "syn_tool variable must be set in the top manifest.")
sys.exit("Exiting")
if not manifest_dict["syn_device"]: if not manifest_dict["syn_device"]:
logging.error( raise Exception(
"syn_device variable must be set in the top manifest.") "syn_device variable must be set in the top manifest.")
sys.exit("Exiting")
if not manifest_dict["syn_grade"]: if not manifest_dict["syn_grade"]:
logging.error( raise Exception(
"syn_grade variable must be set in the top manifest.") "syn_grade variable must be set in the top manifest.")
sys.exit("Exiting")
if not manifest_dict["syn_package"]: if not manifest_dict["syn_package"]:
logging.error( raise Exception(
"syn_package variable must be set in the top manifest.") "syn_package variable must be set in the top manifest.")
sys.exit("Exiting")
if not manifest_dict["syn_top"]: if not manifest_dict["syn_top"]:
logging.error( logging.error(
"syn_top variable must be set in the top manifest.") "syn_top variable must be set in the top manifest.")
......
...@@ -135,9 +135,8 @@ class ToolQuartus(ToolSyn): ...@@ -135,9 +135,8 @@ class ToolQuartus(ToolSyn):
"Auto-guessed syn_family to be %s (%s => %s)", "Auto-guessed syn_family to be %s (%s => %s)",
family, device, key) family, device, key)
if family is None: if family is None:
logging.error("Could not auto-guess device family, please " raise Exception("Could not auto-guess device family, please "
"specify in Manifest.py using syn_family!") "specify in Manifest.py using syn_family!")
sys.exit("\nExiting")
return family return family
family_string = __get_family_string( family_string = __get_family_string(
......
...@@ -119,10 +119,9 @@ class VerilogPreprocessor(object): ...@@ -119,10 +119,9 @@ class VerilogPreprocessor(object):
probable_file = os.path.join(searchdir, filename) probable_file = os.path.join(searchdir, filename)
if os.path.isfile(probable_file): if os.path.isfile(probable_file):
return os.path.abspath(probable_file) return os.path.abspath(probable_file)
logging.error("Can't find %s for %s in any of the include " raise Exception("Can't find %s for %s in any of the include "
"directories: %s", filename, self.vlog_file.file_path, "directories: %s", filename, self.vlog_file.file_path,
', '.join(self.vlog_file.include_dirs)) ', '.join(self.vlog_file.include_dirs))
sys.exit("\nExiting")
def _parse_macro_def(self, macro): def _parse_macro_def(self, macro):
"""Parse the provided 'macro' and, if it's not a reserved keyword, """Parse the provided 'macro' and, if it's not a reserved keyword,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment