Commit 1d50eaae by devttys0

Added check for pyqtgraph and warning if not found during entropy scans

parent 5a6458c5
......@@ -113,6 +113,14 @@ class Entropy(Module):
self.block_size = None
def run(self):
# Sanity check and warning if pyqtgraph isn't found
if self.do_plot:
try:
import pyqtgraph as pg
except ImportError as e:
binwalk.core.common.warning("pyqtgraph not found, visual entropy graphing will be disabled")
self.do_plot = False
for fp in iter(self.next_file, None):
if self.display_results:
......@@ -124,12 +132,9 @@ class Entropy(Module):
self.footer()
if self.do_plot:
import pyqtgraph as pg
if not self.save_plot:
from pyqtgraph.Qt import QtGui
QtGui.QApplication.instance().exec_()
pg.exit()
def calculate_file_entropy(self, fp):
......@@ -229,9 +234,12 @@ class Entropy(Module):
return e
def plot_entropy(self, fname):
try:
import numpy as np
import pyqtgraph as pg
import pyqtgraph.exporters as exporters
except ImportError as e:
return
i = 0
x = []
......
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