summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2020-10-22 16:58:11 +0000
committerKyleMiles <krm504@nyu.edu>2020-10-27 18:41:20 +0000
commit9f8e4a9b7a73d3c32a2f565cab2cbfe0a52ae410 (patch)
tree378b4b586012c840d39f5c952940be6d3ff444c2 /python
parentb35b069e2b2952e9258c7d9c410486175cdc0eef (diff)
Fix #2047; open_view/get_view_of_file_with_options return a raw view if header parsing or getting load options fail
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index a53cbf35..5356b8c7 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -760,7 +760,7 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)):
@classmethod
def get_view_of_file(cls, filename, update_analysis=True, progress_func=None):
"""
- ``get_view_of_file`` opens and returns the first available :py:class:`BinaryView`, excluding a Raw :py:class:`BinaryViewType` unless no other view matches
+ ``get_view_of_file`` opens and returns the first available :py:class:`BinaryView`, excluding a Raw :py:class:`BinaryViewType` unless no other view is available
:param str filename: path to filename or bndb to open
:param bool update_analysis: whether or not to run :func:`update_analysis_and_wait` after opening a :py:class:`BinaryView`, defaults to ``True``
@@ -859,6 +859,9 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)):
load_settings = view.get_load_settings(bvt.name)
if load_settings is None:
load_settings = bvt.get_load_settings_for_data(view)
+ if load_settings is None:
+ log.log_error(f"Could not get load settings for binary view of type `{bvt.name}`")
+ return view
load_settings.set_resource_id(bvt.name)
view.set_load_settings(bvt.name, load_settings)
@@ -878,7 +881,9 @@ class BinaryViewType(with_metaclass(_BinaryViewTypeMetaclass, object)):
else:
bv = bvt.create(view)
- if bv is not None and update_analysis:
+ if bv is None:
+ return view
+ elif update_analysis:
bv.update_analysis_and_wait()
return bv