Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions contents/winrm-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
import common
from colored_formatter import ColoredFormatter

import locale
import codecs

sys.stdout.reconfigure(encoding='utf-8')
locale.setlocale(locale.LC_ALL, 'fr_FR.utf8')
Comment on lines +19 to +20

class SuppressFilter(logging.Filter):
def filter(self, record):
return 'wsman' not in record.getMessage()
Expand Down Expand Up @@ -298,30 +304,35 @@ def filter(self, record):
lastpos = 0
lasterrorpos = 0

output_charset = 'cp437'

Comment on lines +307 to +308
while True:
t.join(.1)

try:
if sys.stdout.tell() != lastpos:
sys.stdout.seek(lastpos)
read=sys.stdout.read()
read = sys.stdout.read()
if isinstance(read, str):
realstdout.write(read)
else:
realstdout.write(read.decode(output_charset))
try:
realstdout.write(read.decode(output_charset))
except UnicodeDecodeError:
realstdout.write(read.decode('cp437', errors='replace'))
except UnicodeDecodeError:
try:
realstdout.write(read.decode(DEFAULT_CHARSET))
realstdout.write(read.decode('cp437', errors='replace'))
except Exception as e:
Comment on lines 323 to 326
log.error(e)
except Exception as e:
log.error(e)

log.error(e)
lastpos = sys.stdout.tell()

if not t.is_alive():
break


sys.stdout.seek(0)
sys.stderr.seek(0)
sys.stdout = realstdout
Expand Down
Loading