mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
fix: possibly better fix for #7
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import locale
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
@@ -68,14 +69,18 @@ def run_process_checkret(args, check=True):
|
|||||||
logger.warning(f"Command '{e.cmd}' returned non-zero exit status {e.returncode}.")
|
logger.warning(f"Command '{e.cmd}' returned non-zero exit status {e.returncode}.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"An error occurred executing {e}")
|
logger.warning(f"An error occurred executing {e}")
|
||||||
|
|
||||||
|
# handle output with proper Windows encoding
|
||||||
|
# Use the preferred encoding for console output on Windows
|
||||||
|
encoding = locale.getpreferredencoding(False) or 'cp1252'
|
||||||
|
|
||||||
# handle output
|
# handle output
|
||||||
stdout_s = ""
|
stdout_s = ""
|
||||||
if ret.stdout != None:
|
if ret.stdout != None:
|
||||||
stdout_s = ret.stdout.decode('utf-8', errors='replace')
|
stdout_s = ret.stdout.decode(encoding, errors='replace')
|
||||||
stderr_s = ""
|
stderr_s = ""
|
||||||
if ret.stderr != None:
|
if ret.stderr != None:
|
||||||
stderr_s = ret.stderr.decode('utf-8', errors='replace')
|
stderr_s = ret.stderr.decode(encoding, errors='replace')
|
||||||
|
|
||||||
# log it
|
# log it
|
||||||
observer.add_cmd_output(">>> {}\n".format(" ".join(args)))
|
observer.add_cmd_output(">>> {}\n".format(" ".join(args)))
|
||||||
|
|||||||
Reference in New Issue
Block a user