From 0e3ebafb2d79b1d5197f7823821ae2cd2aec17f1 Mon Sep 17 00:00:00 2001 From: thurask Date: Sat, 23 Sep 2017 16:17:57 -0400 Subject: [PATCH] make escape characters semi-work on windows --- tclcheck_all.py | 1 + tclcheck_allfull.py | 1 + tclcheck_allota.py | 1 + tcllib.py | 13 +++++++++++++ 4 files changed, 16 insertions(+) diff --git a/tclcheck_all.py b/tclcheck_all.py index 5d4addf..bfba6c5 100644 --- a/tclcheck_all.py +++ b/tclcheck_all.py @@ -6,6 +6,7 @@ import tcllib from requests.exceptions import RequestException, Timeout +tcllib.make_escapes_work() ANSI_UP_DEL = u"\u001b[F\u001b[K" fc = tcllib.FotaCheck() diff --git a/tclcheck_allfull.py b/tclcheck_allfull.py index 93619e2..5b9fc01 100644 --- a/tclcheck_allfull.py +++ b/tclcheck_allfull.py @@ -6,6 +6,7 @@ import tcllib from requests.exceptions import RequestException, Timeout +tcllib.make_escapes_work() ANSI_UP_DEL = u"\u001b[F\u001b[K" fc = tcllib.FotaCheck() diff --git a/tclcheck_allota.py b/tclcheck_allota.py index 5583671..70bd754 100644 --- a/tclcheck_allota.py +++ b/tclcheck_allota.py @@ -6,6 +6,7 @@ import tcllib from requests.exceptions import RequestException, Timeout +tcllib.make_escapes_work() ANSI_UP_DEL = u"\u001b[F\u001b[K" fc = tcllib.FotaCheck() diff --git a/tcllib.py b/tcllib.py index e08ea90..114d7bf 100644 --- a/tcllib.py +++ b/tcllib.py @@ -5,6 +5,7 @@ import base64 import binascii import hashlib +import platform import random import time import xml.dom.minidom @@ -17,6 +18,18 @@ except (ImportError, AttributeError): from xml.etree import ElementTree import requests + +def make_escapes_work(): + system = platform.system() + if system == "Windows": + try: + import colorama + except ImportError: + pass + else: + colorama.init() + + class FotaCheck: VDKEY = b"eJwdjwEOwDAIAr8kKFr//7HhmqXp8AIIDrYAgg8byiUXrwRJRXja+d6iNxu0AhUooDCN9rd6rDLxmGIakUVWo3IGCTRWqCAt6X4jGEIUAxgN0eYWnp+LkpHQAg/PsO90ELsy0Npm/n2HbtPndFgGEV31R9OmT4O4nrddjc3Qt6nWscx7e+WRHq5UnOudtjw5skuV09pFhvmqnOEIs4ljPeel1wfLYUF4\n" CKTP_CHECKAUTO = 1