mirror of
				https://github.com/sqlmapproject/sqlmap.git
				synced 2025-10-31 07:57:47 +03:00 
			
		
		
		
	Minor just in case patch
This commit is contained in:
		
							parent
							
								
									0c8c4fa0d9
								
							
						
					
					
						commit
						e9745cc0be
					
				
							
								
								
									
										40
									
								
								thirdparty/ansistrm/ansistrm.py
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										40
									
								
								thirdparty/ansistrm/ansistrm.py
									
									
									
									
										vendored
									
									
								
							|  | @ -4,9 +4,22 @@ | ||||||
| import logging | import logging | ||||||
| import os | import os | ||||||
| import re | import re | ||||||
|  | import subprocess | ||||||
|  | import sys | ||||||
| 
 | 
 | ||||||
| from lib.core.convert import stdoutencode | 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): | class ColorizingStreamHandler(logging.StreamHandler): | ||||||
|     # color names to indices |     # color names to indices | ||||||
|     color_map = { |     color_map = { | ||||||
|  | @ -21,22 +34,13 @@ class ColorizingStreamHandler(logging.StreamHandler): | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     # levels to (background, foreground, bold/intense) |     # levels to (background, foreground, bold/intense) | ||||||
|     if os.name == 'nt': |     level_map = { | ||||||
|         level_map = { |         logging.DEBUG: (None, 'blue', False), | ||||||
|             logging.DEBUG: (None, 'blue', False), |         logging.INFO: (None, 'green', False), | ||||||
|             logging.INFO: (None, 'green', False), |         logging.WARNING: (None, 'yellow', False), | ||||||
|             logging.WARNING: (None, 'yellow', False), |         logging.ERROR: (None, 'red', False), | ||||||
|             logging.ERROR: (None, 'red', False), |         logging.CRITICAL: ('red', 'white', False) | ||||||
|             logging.CRITICAL: ('red', 'white', False) |     } | ||||||
|         } |  | ||||||
|     else: |  | ||||||
|         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) |  | ||||||
|         } |  | ||||||
|     csi = '\x1b[' |     csi = '\x1b[' | ||||||
|     reset = '\x1b[0m' |     reset = '\x1b[0m' | ||||||
|     disable_coloring = False |     disable_coloring = False | ||||||
|  | @ -67,7 +71,7 @@ class ColorizingStreamHandler(logging.StreamHandler): | ||||||
|         except: |         except: | ||||||
|             self.handleError(record) |             self.handleError(record) | ||||||
| 
 | 
 | ||||||
|     if os.name != 'nt': |     if not subprocess.mswindows: | ||||||
|         def output_colorized(self, message): |         def output_colorized(self, message): | ||||||
|             self.stream.write(message) |             self.stream.write(message) | ||||||
|     else: |     else: | ||||||
|  | @ -85,8 +89,6 @@ class ColorizingStreamHandler(logging.StreamHandler): | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         def output_colorized(self, message): |         def output_colorized(self, message): | ||||||
|             import ctypes |  | ||||||
| 
 |  | ||||||
|             parts = self.ansi_esc.split(message) |             parts = self.ansi_esc.split(message) | ||||||
|             write = self.stream.write |             write = self.stream.write | ||||||
|             h = None |             h = None | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user