mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 10:12:38 +02:00
simplify ansi disabling on mac (removing type issues)
This commit is contained in:
parent
95ed34626d
commit
201bf5ec03
1 changed files with 5 additions and 20 deletions
|
@ -4,9 +4,10 @@ import platform
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Dict, NoReturn, Optional, TextIO
|
from typing import Dict, Optional
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
import colorama
|
||||||
from PySide2 import QtCore, QtWidgets
|
from PySide2 import QtCore, QtWidgets
|
||||||
|
|
||||||
from ..global_common import GlobalCommon
|
from ..global_common import GlobalCommon
|
||||||
|
@ -57,25 +58,9 @@ def gui_main(filename: Optional[str]) -> bool:
|
||||||
# Make sure /usr/local/bin is in the path
|
# Make sure /usr/local/bin is in the path
|
||||||
os.environ["PATH"] = "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
|
os.environ["PATH"] = "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
|
||||||
|
|
||||||
# Strip ANSI colors from stdout output, to prevent terminal colors from breaking
|
# Don't show ANSI colors from stdout output, to prevent terminal
|
||||||
# the macOS GUI app
|
# colors from breaking the macOS GUI app
|
||||||
from strip_ansi import strip_ansi
|
colorama.deinit()
|
||||||
|
|
||||||
class StdoutFilter:
|
|
||||||
def __init__(self, stream: TextIO) -> None:
|
|
||||||
self.stream = stream
|
|
||||||
|
|
||||||
def __getattr__(self, attr_name): # type: ignore [no-untyped-def]
|
|
||||||
return getattr(self.stream, attr_name)
|
|
||||||
|
|
||||||
def write(self, data: str) -> None:
|
|
||||||
self.stream.write(strip_ansi(data))
|
|
||||||
|
|
||||||
def flush(self) -> None:
|
|
||||||
self.stream.flush()
|
|
||||||
|
|
||||||
sys.stdout = StdoutFilter(sys.stdout)
|
|
||||||
sys.stderr = StdoutFilter(sys.stderr)
|
|
||||||
|
|
||||||
# Create the Qt app
|
# Create the Qt app
|
||||||
app_wrapper = ApplicationWrapper()
|
app_wrapper = ApplicationWrapper()
|
||||||
|
|
Loading…
Reference in a new issue