本文整理汇总了Python中colorama.Back.CYAN属性的典型用法代码示例。如果您正苦于以下问题:Python Back.CYAN属性的具体用法?Python Back.CYAN怎么用?Python Back.CYAN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类colorama.Back
的用法示例。
在下文中一共展示了Back.CYAN属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_highlighted
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def print_highlighted(line, hl_color=Back.WHITE):
"""
Print a highlighted line
"""
# Tags
colorer = re.compile('(HARMLESS|SIGNED|MS_SOFTWARE_CATALOGUE)', re.VERBOSE)
line = colorer.sub(Fore.BLACK + Back.GREEN + r'\1' + Style.RESET_ALL + ' ', line)
colorer = re.compile('(SIG_REVOKED)', re.VERBOSE)
line = colorer.sub(Fore.BLACK + Back.RED + r'\1' + Style.RESET_ALL + ' ', line)
colorer = re.compile('(SIG_EXPIRED)', re.VERBOSE)
line = colorer.sub(Fore.BLACK + Back.YELLOW + r'\1' + Style.RESET_ALL + ' ', line)
# Extras
colorer = re.compile('(\[!\])', re.VERBOSE)
line = colorer.sub(Fore.BLACK + Back.CYAN + r'\1' + Style.RESET_ALL + ' ', line)
# Standard
colorer = re.compile('([A-Z_]{2,}:)\s', re.VERBOSE)
line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
print line
示例2: copy_nox_bin_files
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def copy_nox_bin_files():
adb_file_name = 'nox_adb.exe'
dll_file_name = 'AdbWinApi.dll'
path = NOX_BIN
try:
os.stat(os.path.join(path, adb_file_name))
os.stat(os.path.join(path, dll_file_name))
except FileNotFoundError:
try:
path = NOX_BIN_OTHER
os.stat(os.path.join(path, adb_file_name))
os.stat(os.path.join(path, dll_file_name))
except FileNotFoundError:
print(Fore.RED + """Cannot find the required nox files in either
{} or {}, help is requireed""".format(NOX_BIN_OTHER, NOX_BIN))
return
copyfile(os.path.join(path, adb_file_name), os.path.join('bin', 'adb.exe'))
copyfile(os.path.join(path, dll_file_name), os.path.join('bin', dll_file_name))
print(Back.GREEN + "Copied [{}] into bin folder".format(', '.join([adb_file_name, dll_file_name])) + Back.CYAN)
示例3: install_tesseract
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def install_tesseract():
is_installed, message = check_if_tesseract_installed()
if is_installed:
print(Back.GREEN + message + Back.CYAN)
return
try:
os.stat(TESSERACT_SETUP_FILE)
command_runner(TESSERACT_SETUP_FILE)
except FileNotFoundError:
setup_file = download_tesseract()
try:
print(Style.BRIGHT + Back.CYAN + 'Make sure to point the installer to the following directory: {}'.format(
os.path.join(os.getcwd(), 'bin', 'tess')))
command_runner(setup_file)
except FileNotFoundError:
print("Oooo something happened when I downloaded the file, rerun this script")
示例4: _back_color
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def _back_color(code):
if code == 0 or (isinstance(code, str) and code.lower() == "white"):
return Back.WHITE
if code == 1 or (isinstance(code, str) and code.lower() == "cyan"):
return Back.CYAN
if code == 2 or (isinstance(code, str) and code.lower() == "red"):
return Back.RED
return Back.WHITE
示例5: send
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def send(self, str, mode):
if str: print(Back.CYAN + str + Style.RESET_ALL)
if str and mode == 'hex':
print(Fore.CYAN + conv().hex(str, ':') + Style.RESET_ALL)
# show recv commands (debug mode)
示例6: _colorify
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def _colorify(self, data):
"""
Retun colored string.
:param str data: The string to colorify.
:return: A colored string.
:rtype: str
"""
if self.template in ["Generic", "Less"]:
# The template is in the list of template that need the coloration.
if (
self.data_to_print[1].lower() in PyFunceble.STATUS.list.up
or self.data_to_print[1].lower() in PyFunceble.STATUS.list.valid
or self.data_to_print[1].lower() in PyFunceble.STATUS.list.sane
):
# The status is in the list of up status.
# We print the data with a green background.
data = Fore.BLACK + Back.GREEN + data
elif (
self.data_to_print[1].lower() in PyFunceble.STATUS.list.down
or self.data_to_print[1].lower() in PyFunceble.STATUS.list.malicious
):
# The status is in the list of down status.
# We print the data with a red background.
data = Fore.BLACK + Back.RED + data
else:
# The status is not in the list of up and down status.
# We print the data with a cyan background.
data = Fore.BLACK + Back.CYAN + data
# We return the data.
return data
示例7: run_command
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def run_command(command, check_output=False):
if DEBUG:
print(Fore.WHITE + Back.YELLOW +
"Running `{}`".format(command) + Style.NORMAL + Back.CYAN)
if check_output:
return subprocess.check_output(command, shell=True)
return subprocess.call(command, shell=True)
示例8: check_required_packages
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def check_required_packages():
if SKIP_PIP_TEST:
return
installed_packages = pkg_resources.working_set
packages = {}
for package in installed_packages:
packages[package.project_name] = package.version
with open('requirements.txt') as f:
required = list(map(lambda x: x.split('=')[0].replace('>', ''), f.read().splitlines()))
required = filter(lambda x: not '#' in x, required)
all_installed = True
for x in required:
if x in ['scikit_image', 'scikit_learn', 'opencv_contrib_python']:
continue
if x not in packages:
print(Back.YELLOW + "Not in pip {}".format(x))
all_installed = False
try:
import sklearn
import skimage
import cv2
except ImportError as e:
print(Back.RED + "Import error for package")
print(Back.Red + e)
if not all_installed:
print(
Back.RED + Style.BRIGHT + "Not all packages required were found\ntry running `pip -r requirements.txt` again" + Back.CYAN)
else:
print(Back.GREEN + "All required packages found" + Back.CYAN)
# Commands to Run
示例9: main_install
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def main_install():
print(Back.CYAN + Style.BRIGHT + warning)
print(Back.CYAN + "Installing Required components to get this bot up and running")
for index, command in enumerate(commands):
print(Back.CYAN + "Component {}: {}{}".format(index, Fore.RED, command[0]) + Fore.WHITE)
command_runner(command[1])
示例10: printResult
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def printResult(info, count, total):
"""
prints the result block
:param info: all collected info
:param count: counter (number of samples checked)
:param total: total number of lines to check
:return:
"""
# Rating and Color
info["res_color"] = Back.CYAN
# If VT returned results
if "total" in info:
info["res_color"] = Back.GREEN
if info["positives"] > 0:
info["res_color"] = Back.YELLOW
if info["positives"] > 10:
info["res_color"] = Back.RED
# Head line
printSeparator(count, total, info['res_color'], info["rating"])
headline = "HASH: {0}".format(info["hash"])
if 'comment' in info and info['comment'] != '':
headline += " COMMENT: {0}".format(info['comment'])
if 'matching_rule' in info and info['matching_rule'] != '':
headline += " RULE: {0}".format(info['matching_rule'])
printHighlighted(headline)
# More VT info
if "total" in info:
# Result
info["result"] = "%s / %s" % (info["positives"], info["total"])
if info["virus"] != "-":
printHighlighted("VIRUS: {0}".format(info["virus"]))
printHighlighted("TYPE: {1} SIZE: {2} FILENAMES: {0}".format(removeNonAsciiDrop(info["filenames"]),
info['filetype'],
info['filesize']))
# Tags to show
tags = ""
if isinstance(info['tags'], list):
tags = " ".join(map(lambda x: x.upper(), info['tags']))
# Extra Info
printPeInfo(info)
printHighlighted("FIRST: {0} LAST: {1} SUBMISSIONS: {5} REPUTATION: {6}\nCOMMENTS: {2} USERS: {3} TAGS: {4}".format(
info["first_submitted"],
info["last_submitted"],
info["comments"],
', '.join(info["commenter"]),
tags,
info["times_submitted"],
info["reputation"]
), tag_color=True)
# Print the highlighted result line
printHighlighted("RESULT: %s" % (info["result"]), hl_color=info["res_color"])
示例11: test_colorify
# 需要导入模块: from colorama import Back [as 别名]
# 或者: from colorama.Back import CYAN [as 别名]
def test_colorify(self):
"""
Tests the method which colors a line depending of the status.
"""
# pylint: disable=protected-access
expected = False
actual = self.file_instance.exists()
self.assertEqual(expected, actual)
# Test with a template that is not designed for colorify
expected = self.to_print["basic_string"]
actual = Prints(None, "Hehehe", output_file=None, only_on_file=False)._colorify(
self.to_print["basic_string"]
)
self.assertEqual(expected, actual)
# Test with a template that is designed for colorify + Status is UP
expected = Fore.BLACK + Back.GREEN + self.to_print["basic_string"]
actual = Prints(
["This is a test", PyFunceble.STATUS.official.up],
"Generic",
output_file=None,
only_on_file=False,
)._colorify(self.to_print["basic_string"])
self.assertEqual(expected, actual)
# Test with a template that is designed for colorify + Status is DOWN
expected = Fore.BLACK + Back.RED + self.to_print["basic_string"]
actual = Prints(
["This is a test", PyFunceble.STATUS.official.down],
"Generic",
output_file=None,
only_on_file=False,
)._colorify(self.to_print["basic_string"])
self.assertEqual(expected, actual)
# Test with a template that is designed for colorify + Status is
# UNKNOWN or INVALID
expected = Fore.BLACK + Back.CYAN + self.to_print["basic_string"]
actual = Prints(
["This is a test", PyFunceble.STATUS.official.invalid],
"Generic",
output_file=None,
only_on_file=False,
)._colorify(self.to_print["basic_string"])
self.assertEqual(expected, actual)