Commit f6ba3e94 authored by Nicolas Chevillot's avatar Nicolas Chevillot

Replace quit() with raise Exception

parent c4b5fced
...@@ -92,8 +92,7 @@ class Action(list): ...@@ -92,8 +92,7 @@ class Action(list):
self.config["syn_top"] = self.config["top_module"] self.config["syn_top"] = self.config["top_module"]
self.top_entity = self.config.get("syn_top") self.top_entity = self.config.get("syn_top")
else: else:
logging.error("Unknown requested action: %s", action) raise Exception("Unknown requested action: %s", action)
quit(1)
def new_module(self, parent, url, source, fetchto): def new_module(self, parent, url, source, fetchto):
"""Add new module to the pool. """Add new module to the pool.
......
...@@ -51,12 +51,11 @@ class ActionCore(Action): ...@@ -51,12 +51,11 @@ class ActionCore(Action):
"""Check if every module in the pool is fetched""" """Check if every module in the pool is fetched"""
if not len([m for m in self if not m.isfetched]) == 0: if not len([m for m in self if not m.isfetched]) == 0:
logging.error( raise Exception(
"Fetching should be done before continuing.\n" "Fetching should be done before continuing.\n"
"The following modules remains unfetched:\n" "The following modules remains unfetched:\n"
"%s", "%s",
"\n".join([str(m) for m in self if not m.isfetched])) "\n".join([str(m) for m in self if not m.isfetched]))
quit(1)
def makefile(self): def makefile(self):
"""Write the Makefile for the current design""" """Write the Makefile for the current design"""
self._check_all_fetched() self._check_all_fetched()
......
...@@ -44,8 +44,7 @@ class ActionTree(Action): ...@@ -44,8 +44,7 @@ class ActionTree(Action):
import networkx as nx import networkx as nx
from networkx.readwrite import json_graph from networkx.readwrite import json_graph
except ImportError as error_import: except ImportError as error_import:
logging.error(error_import) raise Exception(error_import)
quit(1)
if self.options.mode == 'dfs': if self.options.mode == 'dfs':
hierarchy = nx.dfs_tree(hierarchy, top_id) hierarchy = nx.dfs_tree(hierarchy, top_id)
elif self.options.mode == 'bfs': elif self.options.mode == 'bfs':
...@@ -61,8 +60,7 @@ class ActionTree(Action): ...@@ -61,8 +60,7 @@ class ActionTree(Action):
try: try:
import networkx as nx import networkx as nx
except ImportError as error_import: except ImportError as error_import:
logging.error(error_import) raise Exception(error_import)
quit(1)
unfetched_modules = False unfetched_modules = False
hierarchy = nx.DiGraph() hierarchy = nx.DiGraph()
...@@ -116,8 +114,7 @@ class ActionTree(Action): ...@@ -116,8 +114,7 @@ class ActionTree(Action):
top_level_entity) top_level_entity)
else: else:
logging.error('Unknown tree mode: %s', self.options.mode) raise Exception('Unknown tree mode: %s', self.options.mode)
quit(1)
if unfetched_modules: if unfetched_modules:
logging.warning("Some of the modules have not been fetched!") logging.warning("Some of the modules have not been fetched!")
......
...@@ -308,15 +308,13 @@ types:[<type 'int'>] ...@@ -308,15 +308,13 @@ types:[<type 'int'>]
for line in printed.split('\n'): for line in printed.split('\n'):
print("> " + line) print("> " + line)
except SyntaxError as error_syntax: except SyntaxError as error_syntax:
logging.error("Invalid syntax in the manifest file " + raise Exception("Invalid syntax in the manifest file " +
self.config_file + ":\n" + str(error_syntax)) self.config_file + ":\n" + str(error_syntax) +
logging.error(content) content)
quit(1)
except SystemExit as error_exit: except SystemExit as error_exit:
logging.error("Exit requested by the manifest file " + raise Exception("Exit requested by the manifest file " +
self.config_file + ":\n" + str(error_exit)) self.config_file + ":\n" + str(error_exit) +
logging.error(content) content)
quit(1)
except: except:
logging.error("Encountered unexpected error while parsing " + logging.error("Encountered unexpected error while parsing " +
self.config_file) self.config_file)
......
...@@ -276,11 +276,10 @@ class ManifestParser(ConfigParser): ...@@ -276,11 +276,10 @@ class ManifestParser(ConfigParser):
logging.debug("Looking for manifest in " + path) logging.debug("Looking for manifest in " + path)
dir_files = os.listdir(path) dir_files = os.listdir(path)
if "manifest.py" in dir_files and "Manifest.py" in dir_files: if "manifest.py" in dir_files and "Manifest.py" in dir_files:
logging.error( raise Exception(
"Both manifest.py and Manifest.py" + "Both manifest.py and Manifest.py" +
"found in the module directory: %s", "found in the module directory: %s",
path) path)
quit(1)
for filename in dir_files: for filename in dir_files:
if filename == "manifest.py" or filename == "Manifest.py": if filename == "manifest.py" or filename == "Manifest.py":
if not os.path.isdir(filename): if not os.path.isdir(filename):
...@@ -296,8 +295,7 @@ class ManifestParser(ConfigParser): ...@@ -296,8 +295,7 @@ class ManifestParser(ConfigParser):
return None return None
manifest = _search_for_manifest(path) manifest = _search_for_manifest(path)
if manifest is None: if manifest is None:
logging.error("No manifest found in path: %s", path) raise Exception("No manifest found in path: %s", path)
quit(1)
else: else:
logging.debug("Parse manifest in: %s", manifest) logging.debug("Parse manifest in: %s", manifest)
return self.add_config_file(manifest) return self.add_config_file(manifest)
......
...@@ -100,9 +100,8 @@ class ModuleContent(ModuleCore): ...@@ -100,9 +100,8 @@ class ModuleContent(ModuleCore):
local_mods = [] local_mods = []
for path in local_paths: for path in local_paths:
if path_mod.is_abs_path(path): if path_mod.is_abs_path(path):
logging.error("Found an absolute path (" + path + raise Exception("Found an absolute path (" + path +
") in a manifest(" + self.path + ")") ") in a manifest(" + self.path + ")")
quit(1)
path = path_mod.rel2abs(path, self.path) path = path_mod.rel2abs(path, self.path)
local_mods.append(self.pool.new_module(parent=self, local_mods.append(self.pool.new_module(parent=self,
url=path, url=path,
......
...@@ -75,10 +75,9 @@ class ModuleConfig(object): ...@@ -75,10 +75,9 @@ class ModuleConfig(object):
self.url, self.branch, self.revision = url, None, None self.url, self.branch, self.revision = url, None, None
if not os.path.exists(url): if not os.path.exists(url):
logging.error( raise Exception(
"Path to the local module doesn't exist:\n" + url "Path to the local module doesn't exist:\n" + url
+ "\nThis module was instantiated in: " + str(self.parent)) + "\nThis module was instantiated in: " + str(self.parent))
quit(1)
self.path = path_mod.relpath(url) self.path = path_mod.relpath(url)
self.isfetched = True self.isfetched = True
......
...@@ -166,10 +166,9 @@ PARSE START: %s ...@@ -166,10 +166,9 @@ PARSE START: %s
try: try:
opt_map = manifest_parser.parse(extra_context=extra_context) opt_map = manifest_parser.parse(extra_context=extra_context)
except NameError as name_error: except NameError as name_error:
logging.error( raise Exception(
"Error while parsing {0}:\n{1}: {2}.".format( "Error while parsing {0}:\n{1}: {2}.".format(
self.path, type(name_error), name_error)) self.path, type(name_error), name_error))
quit(1)
self.manifest_dict = opt_map self.manifest_dict = opt_map
else: else:
self.manifest_dict = {} self.manifest_dict = {}
......
...@@ -436,7 +436,6 @@ def create_source_file(path, module, library=None, ...@@ -436,7 +436,6 @@ def create_source_file(path, module, library=None,
elif extension in MICROSEMI_FILE_DICT: elif extension in MICROSEMI_FILE_DICT:
new_file = MICROSEMI_FILE_DICT[extension](path=path, module=module) new_file = MICROSEMI_FILE_DICT[extension](path=path, module=module)
else: else:
logging.error("Cannot create source file %s, " raise Exception("Cannot create source file %s, "
"unknown file extension %s", path, extension) "unknown file extension %s", path, extension)
quit(1)
return new_file return new_file
...@@ -139,10 +139,9 @@ $(TCL_CLOSE)''' ...@@ -139,10 +139,9 @@ $(TCL_CLOSE)'''
syn_family = FAMILY_NAMES.get( syn_family = FAMILY_NAMES.get(
self.manifest_dict["syn_device"][0:4].upper()) self.manifest_dict["syn_device"][0:4].upper())
if syn_family is None: if syn_family is None:
logging.error( raise Exception(
"syn_family is not defined in Manifest.py" "syn_family is not defined in Manifest.py"
" and can not be guessed!") " and can not be guessed!")
quit(-1)
self.manifest_dict["syn_family"] = syn_family self.manifest_dict["syn_family"] = syn_family
super(ToolISE, self)._makefile_syn_top() super(ToolISE, self)._makefile_syn_top()
......
...@@ -75,8 +75,7 @@ class ToolISim(ToolSim): ...@@ -75,8 +75,7 @@ class ToolISim(ToolSim):
xilinx_dir = str(os.path.join( xilinx_dir = str(os.path.join(
self.manifest_dict["sim_path"], "..", "..")) self.manifest_dict["sim_path"], "..", ".."))
else: else:
logging.error("Cannot calculate xilinx tools base directory") raise Exception("Cannot calculate xilinx tools base directory")
quit(1)
hdl_language = 'vhdl' # 'verilog' hdl_language = 'vhdl' # 'verilog'
if shell.check_windows(): if shell.check_windows():
os_prefix = 'nt' os_prefix = 'nt'
......
...@@ -24,9 +24,8 @@ def load_syn_tool(tool_name): ...@@ -24,9 +24,8 @@ def load_syn_tool(tool_name):
logging.debug("Synthesis tool to be used found: %s", tool_name) logging.debug("Synthesis tool to be used found: %s", tool_name)
return available_tools[tool_name]() return available_tools[tool_name]()
else: else:
logging.error("Unknown synthesis tool: %s", tool_name) raise Exception("Unknown synthesis tool: %s" + tool_name
logging.error(" Supported synthesis tools are %s", available_tools.keys()) + " Supported synthesis tools are %s" + available_tools.keys())
quit(1)
def load_sim_tool(tool_name): def load_sim_tool(tool_name):
...@@ -50,6 +49,5 @@ def load_sim_tool(tool_name): ...@@ -50,6 +49,5 @@ def load_sim_tool(tool_name):
logging.debug("Simulation tool to be used found: %s", tool_name) logging.debug("Simulation tool to be used found: %s", tool_name)
return available_tools[tool_name]() return available_tools[tool_name]()
else: else:
logging.error("Unknown simulation tool: %s", tool_name) raise Exception("Unknown simulation tool: %s" + tool_name
logging.error(" Supported simulation tools are %s", available_tools.keys()) + " Supported simulation tools are %s" + available_tools.keys())
quit(1)
...@@ -202,9 +202,8 @@ class ToolQuartus(ToolSyn): ...@@ -202,9 +202,8 @@ class ToolQuartus(ToolSyn):
'value': '$(TOP_MODULE)'})) 'value': '$(TOP_MODULE)'}))
for user_property in self.manifest_dict.get("syn_properties", []): for user_property in self.manifest_dict.get("syn_properties", []):
if not isinstance(user_property, dict): if not isinstance(user_property, dict):
logging.error("Quartus property should be defined as dict: " raise Exception("Quartus property should be defined as dict: "
+ str(user_property)) + str(user_property))
quit(1)
command_list.append(self._emit_property(self.SET_GLOBAL_ASSIGNMENT, command_list.append(self._emit_property(self.SET_GLOBAL_ASSIGNMENT,
user_property)) user_property))
for inc in self.manifest_dict.get("include_dirs", []): for inc in self.manifest_dict.get("include_dirs", []):
...@@ -221,10 +220,9 @@ class ToolQuartus(ToolSyn): ...@@ -221,10 +220,9 @@ class ToolQuartus(ToolSyn):
path = shell.tclpath(path_mod.compose( path = shell.tclpath(path_mod.compose(
self.manifest_dict["quartus_preflow"], os.getcwd())) self.manifest_dict["quartus_preflow"], os.getcwd()))
if not os.path.exists(path): if not os.path.exists(path):
logging.error("quartus_preflow file listed in " raise Exception("quartus_preflow file listed in "
+ os.getcwd() + " doesn't exist: " + os.getcwd() + " doesn't exist: "
+ path + ".\nExiting.") + path + ".\nExiting.")
quit(1)
preflow = '"' + 'quartus_sh:' + path + '"' preflow = '"' + 'quartus_sh:' + path + '"'
command_list.append(self._emit_property(self.SET_GLOBAL_ASSIGNMENT, command_list.append(self._emit_property(self.SET_GLOBAL_ASSIGNMENT,
{'name': 'PRE_FLOW_SCRIPT_FILE', {'name': 'PRE_FLOW_SCRIPT_FILE',
...@@ -234,10 +232,9 @@ class ToolQuartus(ToolSyn): ...@@ -234,10 +232,9 @@ class ToolQuartus(ToolSyn):
self.manifest_dict["quartus_postmodule"], self.manifest_dict["quartus_postmodule"],
os.getcwd())) os.getcwd()))
if not os.path.exists(path): if not os.path.exists(path):
logging.error("quartus_postmodule file listed in " raise Exception("quartus_postmodule file listed in "
+ os.getcwd() + " doesn't exist: " + os.getcwd() + " doesn't exist: "
+ path + ".\nExiting.") + path + ".\nExiting.")
quit(1)
postmodule = '"' + 'quartus_sh:' + path + '"' postmodule = '"' + 'quartus_sh:' + path + '"'
command_list.append(self._emit_property(self.SET_GLOBAL_ASSIGNMENT, command_list.append(self._emit_property(self.SET_GLOBAL_ASSIGNMENT,
{'name': 'POST_MODULE_SCRIPT_FILE', {'name': 'POST_MODULE_SCRIPT_FILE',
...@@ -246,10 +243,9 @@ class ToolQuartus(ToolSyn): ...@@ -246,10 +243,9 @@ class ToolQuartus(ToolSyn):
path = shell.tclpath(path_mod.compose( path = shell.tclpath(path_mod.compose(
self.manifest_dict["quartus_postflow"], os.getcwd())) self.manifest_dict["quartus_postflow"], os.getcwd()))
if not os.path.exists(path): if not os.path.exists(path):
logging.error("quartus_postflow file listed in " raise Exception("quartus_postflow file listed in "
+ os.getcwd() + " doesn't exist: " + os.getcwd() + " doesn't exist: "
+ path + ".\nExiting.") + path + ".\nExiting.")
quit(1)
postflow = '"' + 'quartus_sh:' + path + '"' postflow = '"' + 'quartus_sh:' + path + '"'
command_list.append(self._emit_property(self.SET_GLOBAL_ASSIGNMENT, command_list.append(self._emit_property(self.SET_GLOBAL_ASSIGNMENT,
{'name': 'POST_FLOW_SCRIPT_FILE', {'name': 'POST_FLOW_SCRIPT_FILE',
......
...@@ -135,8 +135,7 @@ class VerilogPreprocessor(object): ...@@ -135,8 +135,7 @@ class VerilogPreprocessor(object):
else: else:
params = [] params = []
if name in self.vpp_keywords: if name in self.vpp_keywords:
logging.error("Attempt to `define a reserved preprocessor keyword") raise Exception("Attempt to `define a reserved preprocessor keyword")
quit(1)
mdef = self.VLDefine(name, params, expansion) mdef = self.VLDefine(name, params, expansion)
self.vpp_macros.append(mdef) self.vpp_macros.append(mdef)
return mdef return mdef
......
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