mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 11:03:47 +03:00
Minor just in case patch
This commit is contained in:
parent
0c8c4fa0d9
commit
e9745cc0be
26
thirdparty/ansistrm/ansistrm.py
vendored
26
thirdparty/ansistrm/ansistrm.py
vendored
|
@ -4,9 +4,22 @@
|
|||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from lib.core.convert import stdoutencode
|
||||
|
||||
if subprocess.mswindows:
|
||||
import ctypes
|
||||
import ctypes.wintypes
|
||||
|
||||
# Reference: https://gist.github.com/vsajip/758430
|
||||
# https://github.com/ipython/ipython/issues/4252
|
||||
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms686047%28v=vs.85%29.aspx
|
||||
ctypes.windll.kernel32.SetConsoleTextAttribute.argtypes = [ctypes.wintypes.HANDLE, ctypes.wintypes.WORD]
|
||||
ctypes.windll.kernel32.SetConsoleTextAttribute.restype = ctypes.wintypes.BOOL
|
||||
|
||||
|
||||
class ColorizingStreamHandler(logging.StreamHandler):
|
||||
# color names to indices
|
||||
color_map = {
|
||||
|
@ -21,15 +34,6 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
|||
}
|
||||
|
||||
# levels to (background, foreground, bold/intense)
|
||||
if os.name == 'nt':
|
||||
level_map = {
|
||||
logging.DEBUG: (None, 'blue', False),
|
||||
logging.INFO: (None, 'green', False),
|
||||
logging.WARNING: (None, 'yellow', False),
|
||||
logging.ERROR: (None, 'red', False),
|
||||
logging.CRITICAL: ('red', 'white', False)
|
||||
}
|
||||
else:
|
||||
level_map = {
|
||||
logging.DEBUG: (None, 'blue', False),
|
||||
logging.INFO: (None, 'green', False),
|
||||
|
@ -67,7 +71,7 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
|||
except:
|
||||
self.handleError(record)
|
||||
|
||||
if os.name != 'nt':
|
||||
if not subprocess.mswindows:
|
||||
def output_colorized(self, message):
|
||||
self.stream.write(message)
|
||||
else:
|
||||
|
@ -85,8 +89,6 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
|||
}
|
||||
|
||||
def output_colorized(self, message):
|
||||
import ctypes
|
||||
|
||||
parts = self.ansi_esc.split(message)
|
||||
write = self.stream.write
|
||||
h = None
|
||||
|
|
Loading…
Reference in New Issue
Block a user