Commit 82cce9a0 by devttys0

Added Windows specific exceptions

parent cfa9fad7
...@@ -6,6 +6,7 @@ import re ...@@ -6,6 +6,7 @@ import re
import sys import sys
import ast import ast
import hashlib import hashlib
import platform
import operator as op import operator as op
from binwalk.core.compat import * from binwalk.core.compat import *
...@@ -16,6 +17,10 @@ if not __debug__: ...@@ -16,6 +17,10 @@ if not __debug__:
else: else:
DEBUG = False DEBUG = False
def MSWindows():
# Returns True if running in a Microsoft Windows OS
return (platform.system() == 'Windows')
def debug(msg): def debug(msg):
''' '''
Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag. Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag.
......
...@@ -117,14 +117,15 @@ class Entropy(Module): ...@@ -117,14 +117,15 @@ class Entropy(Module):
# Need to invoke the pyqtgraph stuff via a separate process, as calling pg.exit # Need to invoke the pyqtgraph stuff via a separate process, as calling pg.exit
# is pretty much required. pg.exit calls os._exit though, and we don't want to # is pretty much required. pg.exit calls os._exit though, and we don't want to
# exit out of the main process (especially if being run via the API). # exit out of the main process (especially if being run via the API).
try: if not binwalk.core.common.MSWindows():
p = multiprocessing.Process(target=self._run) p = multiprocessing.Process(target=self._run)
p.start() p.start()
p.join() p.join()
except IOError as e: else:
# Windows Python2.7 imp.find_module fails to find the binwalk module; # There seem to be all kinds of issues using the multiprocessing module in
# this eventually leads to an Invalid Argument IOError in the multiprocessing # Windows, as done above.
# module. This means that when run in Windows, pg.exit will cause binwalk #
# This means that when run in Windows, pg.exit will cause binwalk
# to exit. # to exit.
self._run() self._run()
......
import os import os
import sys import sys
import string import string
import platform
import binwalk.core.common as common import binwalk.core.common as common
from binwalk.core.compat import * from binwalk.core.compat import *
from binwalk.core.module import Module, Option, Kwarg from binwalk.core.module import Module, Option, Kwarg
...@@ -206,7 +205,7 @@ class HexDiff(Module): ...@@ -206,7 +205,7 @@ class HexDiff(Module):
self.HEADER = self.HEADER[0] self.HEADER = self.HEADER[0]
# Set up the tty for colorization, if it is supported # Set up the tty for colorization, if it is supported
if hasattr(sys.stderr, 'isatty') and sys.stderr.isatty() and platform.system() != 'Windows': if hasattr(sys.stderr, 'isatty') and sys.stderr.isatty() and not common.MSWindows():
import curses import curses
curses.setupterm() curses.setupterm()
self.colorize = self._colorize self.colorize = self._colorize
......
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