本文整理汇总了Python中termcolor.colored方法的典型用法代码示例。如果您正苦于以下问题:Python termcolor.colored方法的具体用法?Python termcolor.colored怎么用?Python termcolor.colored使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类termcolor
的用法示例。
在下文中一共展示了termcolor.colored方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def connect(self):
"""Call to set connection with remote client."""
try:
self.paramiko_session = paramiko.SSHClient()
self.paramiko_session.set_missing_host_key_policy(
paramiko.AutoAddPolicy())
self.paramiko_session.connect(
self.client.ip, username=self.client.user,
password=self.client.pass_, key_filename=self.client.key,
allow_agent=True, compress=self.client.compress)
except (paramiko.AuthenticationException,
paramiko.ssh_exception.NoValidConnectionsError) as e:
self.logger.error(e)
sys.exit(colored("> {}".format(e), 'red'))
except paramiko.SSHException as e:
self.logger.error(e)
sys.exit(colored("> {}".format(e), 'red'))
self.transfer = network.Network(
self.paramiko_session, self.client.ip, self.client.port)
self.transfer.open()
示例2: stdin
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def stdin(message, params, upper=False, lower=False):
"""ask for option/input from user"""
symbol = colored("[OPT]", "magenta")
currentime = colored("[{}]".format(time.strftime("%H:%M:%S")), "green")
option = raw_input("{} {} {}: ".format(symbol, currentime, message))
if upper:
option = option.upper()
elif lower:
option = option.lower()
while option not in params:
option = raw_input("{} {} {}: ".format(symbol, currentime, message))
if upper:
option = option.upper()
elif lower:
option = option.lower()
return option
示例3: _check_previous_installation
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def _check_previous_installation():
"""
Check if previous installation present
Creates empty documentation if none detected
:return:
"""
if not os.path.exists(docks_dir + '/mkdocs.yml'):
print(colored(
f'No documentation found in ({docks_dir}). Creating new one.', 'yellow'))
if not os.path.exists(docks_dir):
os.mkdir(docks_dir)
print(colored(f'Starting fresh installation', 'green'))
os.system(f'mkdocs new {docks_dir}/')
else:
print(
colored(f'Detected previous installation in ({docks_dir}).', 'green'))
示例4: format
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def format(self, record):
date = colored('[%(asctime)s @%(filename)s:%(lineno)d]', 'green')
msg = '%(message)s'
if record.levelno == logging.WARNING:
fmt = date + ' ' + colored('WRN', 'red', attrs=['blink']) + ' ' + msg
elif record.levelno == logging.ERROR or record.levelno == logging.CRITICAL:
fmt = date + ' ' + colored('ERR', 'red', attrs=['blink', 'underline']) + ' ' + msg
elif record.levelno == logging.DEBUG:
fmt = date + ' ' + colored('DBG', 'yellow', attrs=['blink']) + ' ' + msg
else:
fmt = date + ' ' + msg
if hasattr(self, '_style'):
# Python3 compatibility
self._style._fmt = fmt
self._fmt = fmt
return super(_MyFormatter, self).format(record)
示例5: printAvailableFormats
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def printAvailableFormats(banner):
print(colored(banner, 'green'))
print(" Supported Office formats:")
for fileType in MSTypes.MS_OFFICE_FORMATS:
print(" - %s: %s" % (fileType, MSTypes.EXTENSION_DICT[fileType]))
print(" Note: Ms Office file generation requires Windows OS with MS Office application installed.")
print("\n Supported VB formats:")
for fileType in MSTypes.VBSCRIPTS_FORMATS:
print(" - %s: %s" % (fileType, MSTypes.EXTENSION_DICT[fileType]))
print("\n Supported shortcuts/miscellaneous formats:")
for fileType in MSTypes.Shortcut_FORMATS:
print(" - %s: %s" % (fileType, MSTypes.EXTENSION_DICT[fileType]))
print("\n WARNING: These formats are only supported in MacroPack Pro:")
for fileType in MSTypes.ProMode_FORMATS:
print(" - %s: %s" % (fileType, MSTypes.EXTENSION_DICT[fileType]))
print("\n To create a payload for a certain format just add extension to payload.\n Ex. -G payload.hta ")
if MP_TYPE=="Pro":
printAvailableFormatsPro()
示例6: printCommunityUsage
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def printCommunityUsage(banner, currentApp, mpSession):
print(colored(banner, 'green'))
print(" Usage 1: echo <parameters> | %s -t <TEMPLATE> -G <OUTPUT_FILE> [options] " %currentApp)
print(" Usage 2: %s -f input_file_path -G <OUTPUT_FILE> [options] " % currentApp)
print(" Usage 3: more input_file_path | %s -G <OUTPUT_FILE> [options] " %currentApp)
details = getCommunityUsage(currentApp)
details +=" -h, --help Displays help and exit"
details += \
r"""
Notes:
Have a look at README.md file for more details and usage!
Home: www.github.com/sevagas && blog.sevagas.com
"""
print(details)
示例7: printProUsage
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def printProUsage(banner, currentApp, mpSession):
print(colored(banner, 'green'))
print(" Usage 1: echo <parameters> | %s -t <TEMPLATE> -G <OUTPUT_FILE> [options] " %currentApp)
print(" Usage 2: %s -f input_file_path -G <OUTPUT_FILE> [options] " % currentApp)
print(" Usage 3: more input_file_path | %s -G <OUTPUT_FILE> [options] " %currentApp)
details = """
%s
%s
%s
%s
%s
%s
""" % (getGenerationFunction(currentApp), getGenerationFunctionPro(), getAvBypassFunction(currentApp), getAvBypassFunctionPro(), getOtherFunction(currentApp), getOtherFunctionPro())
details +=" -h, --help Displays help and exit \n"
print(details)
示例8: CheckGetVuln
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def CheckGetVuln(url, vuln, html):
global currenttested
global reponsetime
if currenttested == "blind":
return CheckGetBlind(url, vuln, html)
validproof = CheckValidProof(html)
payloadedurl = url + vuln
while True:
starttime = time.time()
page = GetHTML(payloadedurl)
endtime = time.time()
if (currenttested != "timebase") or (reponsetime * 3 + 2 > endtime - starttime):
break
for ivalidproof in validproof:
if (ivalidproof in page) or (currenttested == "timebase" and (endtime - starttime) >= (reponsetime + 2)):
bar.printabove(colored("[GET] ", "green", attrs=["bold"]) + colored(url, "green") + colored(vuln, "red", attrs=["bold"]))
return payloadedurl
return False
示例9: CheckPostBlind
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def CheckPostBlind(url, blindlist, fields, html):
datatrue = {}
datafalse = {}
for field in fields:
datatrue.update({field:blindlist[0]})
for field in fields:
datafalse.update({field:blindlist[1]})
blindtrue = PostData(url, datatrue)
blindfalse = PostData(url, datafalse)
if (blindtrue == html) and (blindtrue != blindfalse):
printpayload = colored("{", "yellow")
icomma = 1
for field in fields:
printpayload = printpayload + colored(field + ":", "yellow") + colored(blindlist[1], "red", attrs=["bold"])
if icomma != len(fields):
printpayload = printpayload + colored(", ", "yellow")
icomma += 1
printpayload = printpayload + colored("}", "yellow")
bar.printabove(colored("[POST] ", "yellow", attrs=["bold"]) + colored(url, "yellow") + colored(" [PARAM] ", "yellow", attrs=["bold"]) + printpayload)
return [url, blindfalse]
else:
return False
示例10: formatException
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def formatException(exc_info):
tb_lines = traceback.format_exception(*exc_info)
tb_lines[0] = termcolor.colored(tb_lines[0], 'red', attrs=['bold'])
for line_no, line in enumerate(tb_lines[1:], 1):
search = re.search(r'File \"([^"]+)", line ([\d,]+), in', line)
if search:
new_line = line[:search.start(1)]
new_line += termcolor.colored(search.group(1), 'yellow', attrs=['underline'])
new_line += line[search.end(1):search.start(2)]
new_line += termcolor.colored(search.group(2), 'white', attrs=['bold'])
new_line += line[search.end(2):]
tb_lines[line_no] = new_line
line = tb_lines[-1]
if line.find(':'):
idx = line.find(':')
line = termcolor.colored(line[:idx], 'red', attrs=['bold']) + line[idx:]
if line.endswith(os.linesep):
line = line[:-len(os.linesep)]
tb_lines[-1] = line
return ''.join(tb_lines)
示例11: log_request
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def log_request(self, code='-', size='-'):
msg = self.requestline
code = str(code)
if termcolor:
color = termcolor.colored
if code[0] == '1': # 1xx - Informational
msg = color(msg, attrs=['bold'])
elif code[0] == '2': # 2xx - Success
msg = color(msg, color='white')
elif code == '304': # 304 - Resource Not Modified
msg = color(msg, color='cyan')
elif code[0] == '3': # 3xx - Redirection
msg = color(msg, color='green')
elif code == '404': # 404 - Resource Not Found
msg = color(msg, color='yellow')
elif code[0] == '4': # 4xx - Client Error
msg = color(msg, color='red', attrs=['bold'])
else: # 5xx, or any other response
msg = color(msg, color='magenta', attrs=['bold'])
self.log('info', '"%s" %s %s', msg, code, size)
示例12: colorize
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def colorize(status):
msg = {}
if os.getenv("APPR_COLORIZE_OUTPUT", "true") == "true":
msg = {
'ok': 'green',
'created': 'yellow',
'updated': 'cyan',
'replaced': 'yellow',
'absent': 'green',
'deleted': 'red',
'protected': 'magenta'}
color = msg.get(status, None)
if color:
return colored(status, color)
else:
return status
示例13: __download_lime__
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def __download_lime__(self):
"""Download LiME from GitHub"""
cprint("Downloading LiME", 'green')
try:
urllib.request.urlretrieve(
"https://github.com/504ensicsLabs/LiME/archive/" +
"v{}.zip".format(
self.lime_version), filename="./tools/lime_master.zip")
zip_lime = zipfile.ZipFile("./tools/lime_master.zip", 'r')
zip_lime.extractall(self.tools_dir)
zip_lime.close()
shutil.move(
'./tools/LiME-{}'.format(self.lime_version), './tools/LiME/')
except urllib.error.URLError:
sys.exit(colored(
"LiME failed to download. Check your internet connection" +
" or place manually", 'red'))
示例14: stdout
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def stdout(message, end="\n"):
"""print a message for user in console"""
symbol = colored("[MSG]", "yellow")
currentime = colored("[{}]".format(time.strftime("%H:%M:%S")), "green")
print("{} {} {}".format(symbol, currentime, message), end=end)
示例15: stderr
# 需要导入模块: import termcolor [as 别名]
# 或者: from termcolor import colored [as 别名]
def stderr(message, end="\n"):
"""print an error for user in console"""
symbol = colored("[ERR]", "red")
currentime = colored("[{}]".format(time.strftime("%H:%M:%S")), "green")
print("{} {} {}".format(symbol, currentime, message), end=end)