當前位置: 首頁>>代碼示例>>Python>>正文


Python termcolor.colored方法代碼示例

本文整理匯總了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() 
開發者ID:kd8bny,項目名稱:LiMEaide,代碼行數:27,代碼來源:network.py

示例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 
開發者ID:the-robot,項目名稱:sqliv,代碼行數:24,代碼來源:std.py

示例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')) 
開發者ID:pozgo,項目名稱:docker-mkdocs,代碼行數:18,代碼來源:common.py

示例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) 
開發者ID:tensorpack,項目名稱:dataflow,代碼行數:18,代碼來源:logger.py

示例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() 
開發者ID:sevagas,項目名稱:macro_pack,代碼行數:21,代碼來源:help.py

示例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) 
開發者ID:sevagas,項目名稱:macro_pack,代碼行數:20,代碼來源:help.py

示例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) 
開發者ID:sevagas,項目名稱:macro_pack,代碼行數:21,代碼來源:help.py

示例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 
開發者ID:bambish,項目名稱:ScanQLi,代碼行數:24,代碼來源:function.py

示例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 
開發者ID:bambish,項目名稱:ScanQLi,代碼行數:27,代碼來源:function.py

示例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) 
開發者ID:rsmusllp,項目名稱:king-phisher,代碼行數:22,代碼來源:color.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:25,代碼來源:serving.py

示例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 
開發者ID:app-registry,項目名稱:appr,代碼行數:18,代碼來源:utils.py

示例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')) 
開發者ID:kd8bny,項目名稱:LiMEaide,代碼行數:20,代碼來源:config.py

示例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) 
開發者ID:the-robot,項目名稱:sqliv,代碼行數:8,代碼來源:std.py

示例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) 
開發者ID:the-robot,項目名稱:sqliv,代碼行數:8,代碼來源:std.py


注:本文中的termcolor.colored方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。