本文整理汇总了Python中colorama.Fore.GREEN属性的典型用法代码示例。如果您正苦于以下问题:Python Fore.GREEN属性的具体用法?Python Fore.GREEN怎么用?Python Fore.GREEN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类colorama.Fore
的用法示例。
在下文中一共展示了Fore.GREEN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def build(path: str, output: str, upload: bool, server: str) -> None:
meta = read_meta(path)
if not meta:
return
if output or not upload:
output = read_output_path(output, meta)
if not output:
return
else:
output = BytesIO()
os.chdir(path)
write_plugin(meta, output)
if isinstance(output, str):
print(f"{Fore.GREEN}Plugin built to {Fore.CYAN}{output}{Fore.GREEN}.{Fore.RESET}")
else:
output.seek(0)
if upload:
upload_plugin(output, server)
示例2: login
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def login(server, username, password, alias) -> None:
data = {
"username": username,
"password": password,
}
try:
with urlopen(f"{server}/_matrix/maubot/v1/auth/login",
data=json.dumps(data).encode("utf-8")) as resp_data:
resp = json.load(resp_data)
config["servers"][server] = resp["token"]
if not config["default_server"]:
print(Fore.CYAN, "Setting", server, "as the default server")
config["default_server"] = server
if alias:
config["aliases"][alias] = server
save_config()
print(Fore.GREEN + "Logged in successfully")
except HTTPError as e:
try:
err = json.load(e)
except json.JSONDecodeError:
err = {}
print(Fore.RED + err.get("error", str(e)) + Fore.RESET)
示例3: update_progress
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def update_progress(progress):
barLength = 20 # Modify this value to change the length of the progress bar
status = ""
if isinstance(progress, int):
progress = float(progress)
if not isinstance(progress, float):
progress = 0
status = "error: progress var must be float\r\n"
if progress < 0:
progress = 0
status = Fore.RED + "Halt!\r\n"
if progress >= .999:
progress = 1
status = Fore.GREEN + " Complete!\r\n"
block = int(round(barLength*progress))
text = "\r[*] Progress: [{0}] {1}% {2}".format("#"*block + "-"*(barLength-block), round(progress*100), status)
sys.stdout.write(text)
sys.stdout.flush()
示例4: run_feed_server
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def run_feed_server():
#stands up the feed server, points to the CB/json_feeds dir
chdir('data/json_feeds/')
port = 8000
handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", port), handler)
try:
print((Fore.GREEN + '\n[+]' + Fore.RESET), end=' ')
print(('Feed Server listening at http://%s:8000' % gethostname()))
httpd.serve_forever()
except:
print((Fore.RED + '\n[-]' + Fore.RESET), end=' ')
print("Server exited")
return
示例5: watch
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def watch(self, raw_args):
def tail(_file):
_file.seek(0, 2) # Go to the end of the file
while True:
line = _file.readline()
if not line:
time.sleep(0.1)
continue
yield line
_file = open(_log_path, 'r')
print(Fore.GREEN + '[bitmask] ' +
Fore.RESET + 'Watching log file %s' % _log_path)
for line in _file.readlines():
print line,
for line in tail(_file):
print line,
示例6: crimeflare
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def crimeflare(target):
print_out(Fore.CYAN + "Scanning crimeflare database...")
with open("data/ipout", "r") as ins:
crimeFoundArray = []
for line in ins:
lineExploded = line.split(" ")
if lineExploded[1] == args.target:
crimeFoundArray.append(lineExploded[2])
else:
continue
if (len(crimeFoundArray) != 0):
for foundIp in crimeFoundArray:
print_out(Style.BRIGHT + Fore.WHITE + "[FOUND:IP] " + Fore.GREEN + "" + foundIp.strip())
else:
print_out("Did not find anything.")
示例7: exe
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def exe(cmd, params):
"""This function runs after preprocessing of code. It actually executes commands with subprocess
:param cmd: command to be executed with subprocess
:param params: parameters passed before ` character, i.e. p`echo 1 which means print result of execution
:return: result of execution. It may be either Result or InteractiveResult
"""
global _colorama_intialized
if _is_colorama_enabled() and not _colorama_intialized:
_colorama_intialized = True
colorama.init()
if config.PRINT_ALL_COMMANDS:
if _is_colorama_enabled():
_print_stdout(Fore.GREEN + '>>> ' + cmd + Style.RESET_ALL)
else:
_print_stdout('>>> ' + cmd)
if _is_param_set(params, _PARAM_INTERACTIVE):
return _create_interactive_result(cmd, params)
else:
return _create_result(cmd, params)
示例8: print_color
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def print_color(mtype, message=''):
"""@todo: Docstring for print_text.
:mtype: set if message is 'ok', 'updated', '+', 'fail' or 'sub'
:type mtype: str
:message: the message to be shown to the user
:type message: str
"""
init(autoreset=False)
if (mtype == 'ok'):
print(Fore.GREEN + 'OK' + Fore.RESET + message)
elif (mtype == '+'):
print('[+] ' + message + '...'),
elif (mtype == 'fail'):
print(Fore.RED + "\n[!]" + message)
elif (mtype == 'sub'):
print((' -> ' + message).ljust(65, '.')),
elif (mtype == 'subsub'):
print("\n -> " + message + '...'),
elif (mtype == 'up'):
print(Fore.CYAN + 'UPDATED')
示例9: print_results
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def print_results(self,results):
try:
if results['status'] == 'Pass':
print ("Status: " + Fore.GREEN + 'Pass' + Fore.RESET)
elif results['status'] == 'Fail':
print ("Status: " + Fore.RED + 'Fail' + Fore.RESET)
except KeyError:
pass
except TypeError:
pass
print "Description: " + results['descr']
try:
res = str(results['output'])
print "Output: "
print(Style.DIM + res + Style.RESET_ALL)
except KeyError:
pass
print "\n"
示例10: print_line
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def print_line(message, level=1, category = None, title = None, status=False):
sts = get_status(category, status)
if sts == 'applied':
color = Fore.GREEN
pre = '[+] '
elif sts == 'touse':
color = Fore.YELLOW
pre = '[+] '
elif sts == 'toremove':
color = Fore.RED
pre = '[-] '
else:
color = ''
pre = ''
if title:
print(' '*4*level + Style.BRIGHT + title + ': ' + Style.RESET_ALL + message)
else:
print(' '*4*level + color + Style.BRIGHT + pre + Fore.RESET + message)
示例11: controller_creatr
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def controller_creatr(filename):
"""Name of the controller file to be created"""
path = os.path.abspath('.') + '/controller'
if not os.path.exists(path):
os.makedirs(path)
# if os.path.isfile(path + )
file_name = str(filename + '.py')
if os.path.isfile(path + "/" + file_name):
click.echo(Fore.WHITE + Back.RED + "ERROR: Controller file exists")
return
controller_file = open(os.path.abspath('.') + '/controller/' + file_name, 'w+')
compose = "from bast import Controller\n\nclass " + filename + "(Controller):\n pass"
controller_file.write(compose)
controller_file.close()
click.echo(Fore.GREEN + "Controller " + filename + " created successfully")
示例12: make_key
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def make_key(path):
env_path = os.path.join(path, '.env')
key = b64encode(os.urandom(32)).decode('utf-8')
with open(env_path, 'r') as file:
env_data = file.readlines()
for line_number, line in enumerate(env_data):
if line.startswith('APP_KEY='):
env_data[line_number] = 'APP_KEY={0}\n'.format(key)
break
with open(env_path, 'w') as file:
file.writelines(env_data)
click.echo(Fore.GREEN + "Key Generated successfully: " + key)
示例13: create_model
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def create_model(model_file, migration):
filename = snake_case(model_file) + ".py"
directory_path = os.path.abspath('.') + '/models/'
if not os.path.exists(directory_path):
os.makedirs(directory_path)
path = os.path.abspath('.') + '/models/' + filename
file_open = open(path, 'w+')
compose = 'from bast import Models\n\nclass %s(Models):\n __table__ = \'%s\'' \
% (model_file, snake_case(model_file))
file_open.write(compose)
file_open.close()
if migration:
migrate = CreateMigration()
migrate.create_file(name=snake_case(model_file), table=snake_case(model_file), create=True)
click.echo(Fore.GREEN + '%s has been created at /models' % filename)
示例14: get_stock_id
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def get_stock_id(self, jarvis, name):
''' Get the list of stock IDs given a company name or part of the company name '''
url = 'https://financialmodelingprep.com/api/v3/company/stock/list'
resp = requests.get(url)
if(resp.status_code == 200):
data = resp.json()
found = False
# Add try block. Somtimes the endpoint does not work or has unexcepted behaviour
try:
for stock in data['symbolsList']:
if(re.match(name.lower(), stock['name'].lower())):
found = True
jarvis.say(stock['symbol'] + "\t\t" + stock['name'], Fore.GREEN)
if not found:
jarvis.say("The given name could not be found\n", Fore.RED)
except KeyError:
jarvis.say("The endpoint is not working at the moment. Try again later", Fore.RED)
else:
jarvis.say("Cannot find the name at this time. Try again later\n", Fore.RED)
示例15: get_profile
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import GREEN [as 别名]
def get_profile(self, jarvis, symbol):
''' Given a stock symbol get the company profile '''
url = 'https://financialmodelingprep.com/api/v3/company/profile/' + symbol
resp = requests.get(url)
if(resp.status_code == 200):
data = resp.json()
if(not data):
jarvis.say("Cannot find details for " + symbol, Fore.RED)
else:
jarvis.say(" Symbol : " + data['symbol'], Fore.GREEN)
jarvis.say(" Company : " + data['profile']['companyName'], Fore.GREEN)
jarvis.say(" Industry : " + data['profile']['industry'], Fore.GREEN)
jarvis.say(" Sector : " + data['profile']['sector'], Fore.GREEN)
jarvis.say(" Website : " + data['profile']['website'], Fore.GREEN)
jarvis.say(" Exchange : " + data['profile']['exchange'], Fore.GREEN)
jarvis.say(" Description : " + data['profile']['description'], Fore.GREEN)
else:
jarvis.say("Cannot find details for " + symbol, Fore.RED)