示例#1
0
def modPrint(var,items):
    print("[ ",end="")
    if type(var.x)==list:
        e2=var.x
        print("( {}".format(items[e2[0]]),end="")
        for i3,e3 in enumerate(e2) :
            if i3==0:
                continue
            print("",col("AND","green"), "{}".format(items[e3]),end="")
        print(" ) ",end="")
    else:
        modPrint(var.x,items)
    sign=var.z.upper()
    print("",col(sign,color[sign]),"",end="")
    if type(var.y)==list:
        e2=var.y
        print("( {} ".format(items[e2[0]]),end="")
        for i3,e3 in enumerate(e2) :
            if i3==0:
                continue
            print("",col("AND","green"), "{}".format(items[e3]),end="")
        print(" ) ",end="")
    else:
        modPrint(var.y,items)
    print("] ",end="")
示例#2
0
 def check(self, funcName: str, state: bool, message: str):
     if state:
         if not self.basicFlag:
             print("[  " + col("PASS", "green") + "  ]" + " CASE " +
                   str(self.caseNumber) + ": " + "  " + funcName)
     else:
         if not self.basicFlag:
             print("[   " + col("FAIL", "red") + "   ]" + " CASE " +
                   str(self.caseNumber) + ": " + "  " + funcName)
         raise Exception(funcName + ": " + message)
     self.caseNumber += 1
     self.allCase += 1
示例#3
0
def ask_input_login(pre_msg="",
                    color=None,
                    username_label="USERNAME",
                    password_label="PASSWORD",
                    pin_label=None,
                    show_debug=False):
    """RETURN : dict - ask a user the login and save it"""
    print_color("\n" + pre_msg + " LOGIN:\n",
                color=color,
                show_debug=show_debug)
    username = input_color("\t{}:  ".format(str(username_label)),
                           color=color,
                           show_debug=show_debug)
    try:
        password = getpass.getpass(col("\t{}:  ".format(str(password)), color))
    except Exception:
        password = getpass.getpass("\t{}:  ".format(str(password_label)))
    try:
        if pin_label is None:
            login = {"username": username, "password": password}
        else:
            pin = input_color("\t{}:  ".format(str(pin_label)),
                              color=color,
                              show_debug=show_debug)
            login = {"username": username, "password": password, "pin": pin}
    except Exception as e:
        if show_debug:
            error_print("Cannot save login info", exception=e)
        login = {"username": None, "password": None}
    return login


# + + + + + USER INPUT + + + + +
# + + + + + Functions + + + + +
示例#4
0
def print_magenta(msg, show_debug=True):
    """VOID : print a text with 'print' but colored magenta"""
    try:
        print(col(str(msg), color=MAGENTA))
    except Exception as e:
        if show_debug:
            warning_print("Probably cannot recognize color", exception=e)
        print(str(msg))
示例#5
0
def print_green(msg, show_debug=True):
    """VOID : print a text with 'print' but colored green"""
    try:
        print(col(str(msg), color=GREEN))
    except Exception as e:
        if show_debug:
            warning_print("Probably cannot recognize color", exception=e)
        print(str(msg))
示例#6
0
 def start(self):
     for func in self.testsList:
         if not self.basicFlag:
             print()
             print("TEST " + str(self.testNumber) + " RUN... " +
                   func.__name__)
             print("-----------------------------------------------------")
         func()
         print("[  " + col("TEST", "green") + "  ]" + " " + \
         "TEST " + str(self.testNumber) +":   ALL CASE " + col("PASS", "green") + \
         " " + str(self.caseNumber-1) + "/" + str(self.caseNumber-1) + \
         ", all: " + str(self.allCase-1) + " | " + str(self.testNumber) + "  " + func.__name__)
         self.testNumber += 1
         self.caseNumber = 1
     print("[  " + col("ALL TESTS PASSED", "green") + "  ]" + " " + \
         "TESTS: " + str(self.testNumber-1) + "/" + str(self.testNumber-1) + \
         ", CASES: " + str(self.allCase-1) + "/" + str(self.allCase-1))
示例#7
0
文件: vgnmon.py 项目: chca42/vgnmon
	def get(self,station,time,line,to):
		for d in self.db:
			if (d.station == station) and (d.time == time) and (d.line == line) and (d.to == to):
				return d
		d = Depart(station,time,line,to)
		print(col("adding " + str(d),"green"))
		self.db.append(d)
		return d
示例#8
0
def print_yellow(msg, show_debug=True):
    """VOID : print a text with 'print' but colored yellow"""
    try:
        print(col(str(msg), color=YELLOW))
    except Exception as e:
        if show_debug:
            warning_print("Probably cannot recognize color", exception=e)
        print(str(msg))
示例#9
0
def ask_password(password_label=None, color=None):
    """RETURN : The password string"""
    if password_label is None:
        password_label = " PASSWORD : "******"\t{}:  ".format(str(password)), color))
    except Exception:
        password = getpass.getpass("\t{}:  ".format(str(password_label)))
    return password
示例#10
0
def input_color(msg, color, parse_none=False, show_debug=True):
    """RETURN : ask a user input but with colored msg and return it"""
    try:
        user_input = input(col(msg, color))
    except Exception as e:
        user_input = input(msg)
        if show_debug:
            warning_print("Error, probably cannot recognize color",
                          exception=e)
    if parse_none:
        if user_input.lower() == 'none':
            user_input = None
    return user_input
示例#11
0
def welcome(color=WHITE, num_of_new_lines=0, num_of_tabs=0):
    """VOID : Print out a welcome message with a nice format"""
    # number of new lines before text
    if num_of_new_lines > 0:
        for _ in range(num_of_new_lines):
            print("\n")
    if num_of_tabs > 0:
        for _ in range(num_of_tabs):
            print("\t")
    # print welcome message
    if color is None:
        print("\n\n* * * * * * * * * * * * * * * * * *")
        print("*            WELCOME              *")
        print("* * * * * * * * * * * * * * * * * *\n")
    else:
        try:
            print(col("\n\n* * * * * * * * * * * * * * * * * *", color))
            print(col("*            WELCOME              *", color))
            print(col("* * * * * * * * * * * * * * * * * *\n", color))
        except Exception:
            print("\n\n* * * * * * * * * * * * * * * * * *")
            print("*            WELCOME              *")
            print("* * * * * * * * * * * * * * * * * *\n")
示例#12
0
 def log(mode="None",out="",noLog=False,file=fnameSet):
     try:
         from termcolor import colored as col
         from termcolor import cprint as cp
         import colorama
     except ImportError:
         print("\nMissing dependancy\n")
         raise missingContent
     from datetime import datetime
     colorama.init()
     
     type=""
     if out == "":#User used the function incorrectly
         raise incorrectUsage#User did an oof
     if mode == "None":
         raise incorrectUsage
     elif mode == 'e':
         type = "ERROR"
         if out != "":  cp("{}".format(type),"white",'on_red',attrs=['bold'],end=""); print(": {}".format(out)) # this shows up in the interactive prompt
     elif mode == 'w':
         type = "Warning"
         if out != "":   cp("{}".format(type),"yellow",attrs=['bold'],end=""); print(": {}".format(out)) # this shows up in the interactive prompt
     elif mode == 'n':
         type = "Notice"
         if out != "":   print("{}: {}".format(type,out)) # this shows up in the interactive prompt
     elif mode == 'i':
         type = "Info"
         if out != "":   cp("{}".format(type),"blue",attrs=['bold'],end=""); print(": {}".format(out)) # this shows up in the interactive prompt
     elif mode == 's':
         type = "SUCCESS"
         if out != "":   print("{}: {}".format(col(type,"green",attrs=['bold']),out)) # this shows up in the interactive prompt
     elif mode == 'z':
         type = "SPAM"
         if noLog == True:   raise incorrectUsage
     if noLog == False:
         try:
             f = open(file, 'a') #prints now go the the file
             f.write("\n{} - {}: {}".format(str(datetime.now().strftime('%Y-%m-%d %H:%M:%S')),type,out))   # nothing appears. it's written to log file instead
             f.close
         except FileNotFoundError:
             cp("consoleTools ERROR ","white",'on_red',attrs=['bold'],end=""); cp("Issue writing to log file - does not exist. Are you running from an IDE? (doesn't always work in an IDE)","red",'on_white',attrs=['bold'],end="\n")
             cp("Try specifying a log file when using the log tool if you are not running the script from the same directory as it is located.","red",'on_white',attrs=['bold'],end="\n")
         except FileExistsError:
             cp("consoleTools ERROR ","white",'on_red',attrs=['bold','blink'],end=""); cp("Issue writing to log file - file exists. Is the file open in the background/by another process (won't be able to write if so)","red",'on_white',attrs=['bold'],end="\n")
示例#13
0
def label_print(msg,
                num_of_new_lines=0,
                num_of_tabs=0,
                color=None,
                label="LABEL: ",
                timestamp=True,
                exception=None):
    """VOID : Print out a labeled message with a nice format"""
    # number of new lines before text
    if timestamp:
        label = '[' + str(datetime.now()) + '] ' + label

    if num_of_new_lines > 0:
        for _ in range(num_of_new_lines):
            print("\n")
    if num_of_tabs > 0:
        for _ in range(num_of_tabs):
            print("\t")
    # print labeled message
    msg = str(msg)
    # traceback?
    if exception is not None:
        msg += ", EXCEPTION -> {}, TRACEBACK -> {}".format(
            str(exception), str(traceback.format_exc()))
    if color is None:
        if msg is None:
            print(None)
        else:
            print(label + msg)
    else:
        try:
            if msg is None:
                print(None)
            else:
                print(col(label + msg, color))
        except Exception as e:
            if msg is None:
                print(None)
            else:
                print(label + msg)
示例#14
0
from pyfiglet import figlet_format as figform
from termcolor import colored as col

valid_colors = ("red", "green", "yellow", "blue", "magenta", "cyan", "white")

phrase = input("What message do you want to print? ")
shade = input("What color? ")

if shade not in valid_colors:
    shade = "blue"

text = col(figform(phrase), color=shade)
print(text)
示例#15
0
文件: vuln.py 项目: jarvis5797/Vulnix
def ip_grabber():
    global victim_ip
    print(col("Ip_found : \n"+os.popen("arp -a | grep vulnix").read() , 'yellow'))
    victim_ip=input(col('Enter your vm_ip : ' , 'blue'))
示例#16
0
文件: vuln.py 项目: jarvis5797/Vulnix
def scanner(victim_ip):
    try:
        print(col(os.popen("nmap "+victim_ip+" | grep open").read() , 'yellow'))
    except:
        print(col("Seems as host is down at "+victim_ip , 'red'))
示例#17
0
文件: vgnmon.py 项目: chca42/vgnmon
	def updateDelay(self,time,delay):
		if (len(self.delays) > 0) and (self.delays[-1][1] == delay):
			return
		self.delays.append((time,delay))
		print(col("updated: " + str(self),"yellow"))
示例#18
0
文件: vuln.py 项目: jarvis5797/Vulnix
#! /bin/bash
from termcolor import colored as col
import sys
import subprocess
import time
import os
try:
    print(col(os.popen("figlet Vulnix").read(), 'green'))
except:
    print(col("Installing Requirements..." , 'red'))
def ip_grabber():
    global victim_ip
    print(col("Ip_found : \n"+os.popen("arp -a | grep vulnix").read() , 'yellow'))
    victim_ip=input(col('Enter your vm_ip : ' , 'blue'))
ip_grabber()
def scanner(victim_ip):
    try:
        print(col(os.popen("nmap "+victim_ip+" | grep open").read() , 'yellow'))
    except:
        print(col("Seems as host is down at "+victim_ip , 'red'))
scanner(victim_ip)
示例#19
0
import requests
from pyfiglet import figlet_format as figform
from termcolor import colored as col
from random import randint

valid_colors = ("red", "green", "yellow", "blue", "magenta", "cyan", "white")
url = "https://icanhazdadjoke.com/search"

print(" ")
header = "Dad Joke (De)-Generator"
shade = valid_colors[randint(0, 6)]
text = col(figform(header), color=shade)
print(text)

fromUser = input("Ready for a dad joke? What topic would you want? ")

response = requests.get(url,
                        headers={"Accept": "application/json"},
                        params={
                            "term": fromUser,
                            "limit": 1
                        })

data = response.json()

if data["total_jokes"] > 1:
    print("I've got " + str(data["total_jokes"]) + " jokes about " + fromUser +
          ". Here's one: ")
    print(data["results"][0]["joke"])
    print(" ")
    print(" ")