twister: Initialise Colorama during module load

This commit adds a call to the Colorama initialisation function during
the module execution so that ANSI color sequences are properly
converted to the relevant Win32 API calls on the Windows.

Note that the init function needs to be called per module, hence it is
also called in the `twisterlib.py`.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2022-05-23 19:03:28 +09:00 committed by Marti Bolivar
commit aae454708d
2 changed files with 6 additions and 0 deletions

View file

@ -28,6 +28,7 @@ import xml.etree.ElementTree as ET
import logging import logging
from pathlib import Path from pathlib import Path
from distutils.spawn import find_executable from distutils.spawn import find_executable
import colorama
from colorama import Fore from colorama import Fore
import pickle import pickle
import platform import platform
@ -4714,3 +4715,5 @@ class HardwareMap:
table.append([platform, p.id, p.serial]) table.append([platform, p.id, p.serial])
print(tabulate(table, headers=header, tablefmt="github")) print(tabulate(table, headers=header, tablefmt="github"))
colorama.init()

View file

@ -173,6 +173,7 @@ import shutil
from collections import OrderedDict from collections import OrderedDict
import multiprocessing import multiprocessing
from itertools import islice from itertools import islice
import colorama
from colorama import Fore from colorama import Fore
from pathlib import Path from pathlib import Path
from multiprocessing.managers import BaseManager from multiprocessing.managers import BaseManager
@ -832,6 +833,8 @@ def setup_logging(outdir, log_file, verbose, timestamps):
def main(): def main():
start_time = time.time() start_time = time.time()
colorama.init()
options = parse_arguments() options = parse_arguments()
previous_results = None previous_results = None