Merge pull request #1607 from taosdata/change-pytest-code-to-support-python3

make print output be python2 and python3 compatible.
This commit is contained in:
slguan 2020-04-14 11:43:09 +08:00 committed by GitHub
commit 3b02cccebc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -15,6 +15,7 @@ import sys
import os
import time
import datetime
from distutils.log import warn as printf
class TDLog:
@ -22,27 +23,27 @@ class TDLog:
self.path = ""
def info(self, info):
print("%s %s" % (datetime.datetime.now(), info))
printf("%s %s" % (datetime.datetime.now(), info))
def sleep(self, sec):
print("%s sleep %d seconds" % (datetime.datetime.now(), sec))
printf("%s sleep %d seconds" % (datetime.datetime.now(), sec))
time.sleep(sec)
def debug(self, err):
print("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err))
printf("\033[1;36m%s %s\033[0m" % (datetime.datetime.now(), err))
def success(self, info):
print("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info))
printf("\033[1;32m%s %s\033[0m" % (datetime.datetime.now(), info))
def notice(self, err):
print("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err))
printf("\033[1;33m%s %s\033[0m" % (datetime.datetime.now(), err))
def exit(self, err):
print("\033[1;31m%s %s\033[0m" % (datetime.datetime.now(), err))
printf("\033[1;31m%s %s\033[0m" % (datetime.datetime.now(), err))
sys.exit(1)
def printNoPrefix(self, info):
print("\033[1;36m%s\033[0m" % (info))
def printfNoPrefix(self, info):
printf("\033[1;36m%s\033[0m" % (info))
tdLog = TDLog()