Commit 5860c32d by devttys0

Fixed graphing bugs

parent afc5ad77
...@@ -54,13 +54,15 @@ class Option(object): ...@@ -54,13 +54,15 @@ class Option(object):
if self.type and (self.type.__name__ == self.dtype): if self.type and (self.type.__name__ == self.dtype):
# Be sure to specify a base of 0 for int() so that the base is auto-detected # Be sure to specify a base of 0 for int() so that the base is auto-detected
if self.type == int: if self.type == int:
return self.type(value, 0) t = self.type(value, 0)
else: else:
return self.type(value) t = self.type(value)
elif default_value: elif default_value is not None:
return default_value t = default_value
else: else:
return value t = value
return t
class Kwarg(object): class Kwarg(object):
''' '''
...@@ -766,6 +768,7 @@ class Modules(object): ...@@ -766,6 +768,7 @@ class Modules(object):
except Exception as e: except Exception as e:
raise ModuleException("Invalid usage: %s" % str(e)) raise ModuleException("Invalid usage: %s" % str(e))
binwalk.core.common.debug("%s :: %s => %s" % (module.TITLE, str(argv), str(kwargs)))
return kwargs return kwargs
def kwargs(self, obj, kwargs): def kwargs(self, obj, kwargs):
......
...@@ -156,6 +156,7 @@ class Entropy(Module): ...@@ -156,6 +156,7 @@ class Entropy(Module):
def plot_entropy(self, fname): def plot_entropy(self, fname):
import numpy as np import numpy as np
import binwalk.pyqtgraph as pg import binwalk.pyqtgraph as pg
import binwalk.pyqtgraph.exporters as exporters
i = 0 i = 0
x = [] x = []
...@@ -195,7 +196,7 @@ class Entropy(Module): ...@@ -195,7 +196,7 @@ class Entropy(Module):
# TODO: legend is not displayed properly when saving plots to disk # TODO: legend is not displayed properly when saving plots to disk
if self.save_plot: if self.save_plot:
exporter = pg.exporters.ImageExporter.ImageExporter(plt.plotItem) exporter = exporters.ImageExporter.ImageExporter(plt.plotItem)
exporter.parameters()['width'] = self.FILE_WIDTH exporter.parameters()['width'] = self.FILE_WIDTH
exporter.export(binwalk.core.common.unique_file_name(os.path.basename(fname), self.FILE_FORMAT)) exporter.export(binwalk.core.common.unique_file_name(os.path.basename(fname), self.FILE_FORMAT))
else: else:
......
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