I have linux server where I am running python script on server console my script colors are not displaying. Same script is working on Putty sessions.
I have checked echo $TERM in putty it is "xterm" and server console it is "linux".
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
import os
import subprocess
from subprocess import check_output
from subprocess import call
import sys
import time
from shutil import copyfile
import commands
print OKGREEN + "Testing Green" + ENDC
I have also tried below setting up "os.system('export TERM="xterm"')" in python script but not working
Could some one help me to fix this issue.
Version: 2.7
Note: In same server console vim is displaying with colors
It works fine for me with this code.
jay@Jay-Linux:~$ /usr/bin/python -V Python 2.7.15rc1
#!/usr/bin/env python
#Jay
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
print bcolors.OKBLUE + 'OK', bcolors.ENDC
print bcolors.HEADER + 'This is header', bcolors.ENDC
print bcolors.FAIL + 'Failed.', bcolors.ENDC
print bcolors.OKGREEN + 'OK Green', bcolors.ENDC
print bcolors.WARNING + 'Warning', bcolors.ENDC
print bcolors.FAIL + 'Failed', bcolors.ENDC
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.