Skip to content

Update winrm-exec.py#97

Open
GrymnDolen wants to merge 1 commit intorundeck-plugins:masterfrom
GrymnDolen:patch-1
Open

Update winrm-exec.py#97
GrymnDolen wants to merge 1 commit intorundeck-plugins:masterfrom
GrymnDolen:patch-1

Conversation

@GrymnDolen
Copy link

  1. Set the encoding configuration for sys.stdout to UTF-8 for handling special characters correctly.
    
  2. Configured the locale to 'fr_FR.utf8' for special character support like "é" and "ê."
    
  3. Renamed variables to adhere to Python naming conventions.
    
  4. Modified the output encoding to 'cp437' for compatibility with the Windows CMD console.
    
  5. Adjusted the decoding of command output in the while loop to use 'cp437' encoding.
    

@fdevans fdevans requested a review from Copilot March 18, 2026 21:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts winrm-exec.py stdout/locale configuration and modifies how command output is decoded/written, aiming to improve special-character handling and Windows console compatibility.

Changes:

  • Adds locale and stdout encoding configuration at import time.
  • Introduces a hard-coded cp437 decoding path when streaming command output.
  • Minor refactor/formatting in the output read loop (variable spacing, extra error handling).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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

sys.stdout.reconfigure(encoding='utf-8')
locale.setlocale(locale.LC_ALL, 'fr_FR.utf8')
from colored_formatter import ColoredFormatter

import locale
import codecs
Comment on lines +307 to +308
output_charset = 'cp437'

Comment on lines 323 to 326
except UnicodeDecodeError:
try:
realstdout.write(read.decode(DEFAULT_CHARSET))
realstdout.write(read.decode('cp437', errors='replace'))
except Exception as e:
except Exception as e:
log.error(e)

log.error(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants