Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
JAR_C_PATTERN3 = os.path.join(BASEDIR, "../../sonar-c-plugin/target/*RC[0-9].jar")
RELPATH_PLUGINS = "extensions/plugins"
didstartsonar = False
RED = ""
YELLOW = ""
GREEN = ""
RESET = ""
RESET_ALL = ""
BRIGHT = ""
try:
import colorama
colorama.init()
RED = colorama.Fore.RED
YELLOW = colorama.Fore.YELLOW
GREEN = colorama.Fore.GREEN
RESET = colorama.Fore.RESET
BRIGHT = colorama.Style.BRIGHT
RESET_ALL = colorama.Style.RESET_ALL
except ImportError:
pass
# -----------------------------------------------------------------------------
# HOOKS:
# -----------------------------------------------------------------------------
def before_all(context):
global didstartsonar
print(BRIGHT + "\nSetting up the test environment" + RESET_ALL)
if is_webui_up():
print('Something went wrong, check the logs. Aborting')
print(sys.exc_info()[0])
print(sys.exc_info()[1])
print(sys.exc_info()[2])
raise
if deploy_result['code'] == deployment_manager.DEPLOYMENT_OUTPUT_CODE_OK \
and deploy_result['deployed_files_count'] == deploy_result['requested_files_count']:
sys.stdout.write('\033[2K\r' + colorama.Fore.GREEN +
deployed_files.format(deploy_result['deployed_files_count'],
deploy_result['requested_files_count']) + colorama.Fore.RESET +
' | ' + connection_string)
sys.stdout.write('\n')
logger.info('Successfully deployed {0}'.format(connection_string))
elif deploy_result['code'] == deployment_manager.DEPLOYMENT_OUTPUT_CODE_NOT_ALL_DEPLOYED:
sys.stdout.write('\033[2K\r' + colorama.Fore.YELLOW +
deployed_files.format(deploy_result['deployed_files_count'],
deploy_result['requested_files_count']) + colorama.Fore.RESET +
' | ' + connection_string)
sys.stdout.write('\n')
logger.warning('Not all files were deployed {0}'.format(connection_string))
return deploy_result
if len(choice) == 0:
pass
else:
tech_data = choice
# Icon
icon = ''
print((Fore.YELLOW + '\n[*]' + Fore.RESET), end=' ')
iconic = input('Do you have an icon to upload? (Y/N)\n> ')
if iconic.lower() == 'y':
print((Fore.YELLOW + '\n[*]' + Fore.RESET), end=' ')
icon = input('Please provide the full path to the image here:\n> ')
elif iconic.lower() == 'n':
pass
else:
print((Fore.YELLOW + '\n[*]' + Fore.RESET), end=' ')
print('[*] Sorry, did not recognize that. You can add an icon later..')
# Parsing values into the feed dictionary
feed_meta = ['name', 'display_name', 'provider_url', 'summary', 'tech_data', 'icon', 'ioc_file', 'feed_link', 'report_name']
for i in feed_meta:
feed_dict[i] = str(locals()[i])
try:
json_data = dump(feed_dict, meta_file)
print((Fore.GREEN + '\n[+] Successfully wrote metadata to %s' % feedpath))
meta_file.close()
return json_data
except:
print((Fore.RED + '\n[-] Could not write JSON stream to file'))
def channel_str(num):
channels = ["", "Mono", "Stereo"]
if num < len(channels):
return channels[num]
else:
return ""
# log id3 tags
print("-" * 79)
print(Fore.YELLOW + "Setting artist: " + artist + Fore.RESET)
if album is not None:
print(Fore.YELLOW + "Setting album: " + album + Fore.RESET)
print(Fore.YELLOW + "Setting title: " + title + Fore.RESET)
print(Fore.YELLOW + "Setting track info: (" +
str(track.index) + ", " + str(num_tracks) + ")" + Fore.RESET)
print(Fore.YELLOW + "Setting disc info: (" + str(track.disc) +
", " + str(num_discs) + ")" + Fore.RESET)
print(Fore.YELLOW + "Setting release year: " +
str(track.album.year) + Fore.RESET)
if genres is not None and genres:
print(Fore.YELLOW + "Setting genres: " +
" / ".join(genres_ascii) + Fore.RESET)
if image is not None:
print(Fore.YELLOW + "Adding cover image" + Fore.RESET)
if args.comment is not None:
print(Fore.YELLOW + "Adding comment: " + comment + Fore.RESET)
if args.output_type == "flac":
bit_rate = ((audio.info.bits_per_sample * audio.info.sample_rate) *
audio.info.channels)
print("Time: " + format_time(audio.info.length) +
"\tFree Lossless Audio Codec" +
"\t[ " + bit_rate_str(bit_rate / 1000) + " @ " +
def colored(msg, color=None, style=None):
colors = {
"red": colorama.Fore.RED,
"green": colorama.Fore.GREEN,
"cyan": colorama.Fore.CYAN,
"yellow": colorama.Fore.YELLOW,
"magenta": colorama.Fore.MAGENTA,
None: "",
}
styles = {
"bright": colorama.Style.BRIGHT,
"dim": colorama.Style.DIM,
None: "",
}
pre = colors[color] + styles[style]
post = colorama.Style.RESET_ALL
return f"{pre}{msg}{post}"
presented as part of her PyCon 2010 talk.
It demonstrates many features of cmd2.
"""
import argparse
from colorama import Fore
import cmd2
from cmd2.constants import MULTILINE_TERMINATOR
COLORS = {
'black': Fore.BLACK,
'red': Fore.RED,
'green': Fore.GREEN,
'yellow': Fore.YELLOW,
'blue': Fore.BLUE,
'magenta': Fore.MAGENTA,
'cyan': Fore.CYAN,
'white': Fore.WHITE,
}
class Pirate(cmd2.Cmd):
"""A piratical example cmd2 application involving looting and drinking."""
def __init__(self):
"""Initialize the base class as well as this one"""
shortcuts = dict(cmd2.DEFAULT_SHORTCUTS)
shortcuts.update({'~': 'sing'})
super().__init__(multiline_commands=['sing'], terminators=[MULTILINE_TERMINATOR, '...'], shortcuts=shortcuts)
self.default_to_shell = True
pr = Profiler()
pr.loadDatabase(pathDatabase)
sizeOfDB = pr.size
nbProfilesBDD = pr.count
menu = """
__..--.._
..... .--~ ..... `. Time: [ %s | %s ]
.": "`-.. . .' ..-'" :". ` Author: [ Lulz3xploit ]
` `._ ` _.'`"( `-"'`._ ' _.' ' Version: [ %s ]
~~~ `. ~~~ Pays: [ %s | %s ]
.' Database: [ %s | %s Ko ]
/
( %s
^---'
""" % (Fore.YELLOW+str(today_date)+Fore.RESET, Fore.YELLOW+times()+Fore.RESET,
Fore.YELLOW+str(__version__)+Fore.RESET,
Fore.CYAN+monpays+Fore.RESET, codemonpays,
Fore.GREEN+str(nbProfilesBDD)+Fore.RESET, Fore.RED+str(sizeOfDB)+Fore.RESET,
random.choice(text)
)
print(lb_header())
print(menu)
vcspull.log
~~~~~~~~~~~
"""
from __future__ import absolute_import, print_function, unicode_literals
import logging
import time
from colorama import Fore, Style
LEVEL_COLORS = {
'DEBUG': Fore.BLUE, # Blue
'INFO': Fore.GREEN, # Green
'WARNING': Fore.YELLOW,
'ERROR': Fore.RED,
'CRITICAL': Fore.RED
}
def default_log_template(self, record):
"""Return the prefix for the log message. Template for Formatter.
:param: record: :py:class:`logging.LogRecord` object. this is passed in
from inside the :py:meth:`logging.Formatter.format` record.
"""
reset = [Style.RESET_ALL]
levelname = [
LEVEL_COLORS.get(record.levelname), Style.BRIGHT,