Commit 82cce9a0 by devttys0

Added Windows specific exceptions

parent cfa9fad7
......@@ -6,6 +6,7 @@ import re
import sys
import ast
import hashlib
import platform
import operator as op
from binwalk.core.compat import *
......@@ -16,6 +17,10 @@ if not __debug__:
else:
DEBUG = False
def MSWindows():
# Returns True if running in a Microsoft Windows OS
return (platform.system() == 'Windows')
def debug(msg):
'''
Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag.
......
......@@ -117,14 +117,15 @@ class Entropy(Module):
# 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
# 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.start()
p.join()
except IOError as e:
# Windows Python2.7 imp.find_module fails to find the binwalk module;
# this eventually leads to an Invalid Argument IOError in the multiprocessing
# module. This means that when run in Windows, pg.exit will cause binwalk
else:
# There seem to be all kinds of issues using the multiprocessing module in
# Windows, as done above.
#
# This means that when run in Windows, pg.exit will cause binwalk
# to exit.
self._run()
......
import os
import sys
import string
import platform
import binwalk.core.common as common
from binwalk.core.compat import *
from binwalk.core.module import Module, Option, Kwarg
......@@ -206,7 +205,7 @@ class HexDiff(Module):
self.HEADER = self.HEADER[0]
# 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
curses.setupterm()
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