Python colorama.Fore.BLUE Examples
The following are 30
code examples of colorama.Fore.BLUE().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
colorama.Fore
, or try the search function
.
Example #1
Source File: workout.py From Jarvis with MIT License | 6 votes |
def workout(jarvis, s): """Provides a workout programm according to user's abilities Formula to generate a relevant program is taken from: https://www.gbpersonaltraining.com/how-to-perform-100-push-ups/""" s = jarvis.input( "Choose an exercise. Write 'push' for pushups, 'pull' for pullups and 'q' for quit\n", Fore.GREEN) if (s == "'q'" or s == "q"): quit(jarvis) elif (s == "'push'" or s == "push"): s = jarvis.input( "How many times can you push up? Please enter an integer!\n", Fore.GREEN) pushups(jarvis, s) elif (s == "'pull'" or s == "pull"): s = jarvis.input( "How many times can you pull up? Please enter an integer!\n", Fore.GREEN) pullups(jarvis, s) else: jarvis.say( "Incorrect input, please write either 'push' or 'pull'", Fore.BLUE) quit(jarvis)
Example #2
Source File: tempconv.py From Jarvis with MIT License | 6 votes |
def temp_convert(self, jarvis, s): """Assuming valid regex, handle the actual temperature conversion and output""" # convert the string into a float starting_temp = float(s[:-1]) # run conversions and create output string. if s[-1].lower() == 'f': new_temp = self.convert_f_to_c(starting_temp) output = "{}° F is {}° C".format(starting_temp, new_temp) else: new_temp = self.convert_c_to_f(starting_temp) output = "{}° C is {}° F".format(starting_temp, new_temp) # use print_say to display the output string jarvis.say(output, Fore.BLUE)
Example #3
Source File: print_ast.py From pyta with GNU General Public License v3.0 | 6 votes |
def walker(node, source_lines, indent=''): """Recursively visit the ast in a preorder traversal.""" node_name = str(node)[0:str(node).index('(')] value = None if hasattr(node, 'value'): if '(' in str(node.value): value = str(node.value)[0:str(node.value).index('(')] else: value = node.value name = node.name if hasattr(node, 'name') else None print('{}{} {} (name: {}, value: {})'.format( indent, CHAR_TUBE, node_name, name, value)) lines = [line for line in node.as_string().split('\n')] for line in lines: print(indent + FILL + '>>>' + Fore.BLUE + line + Fore.RESET) for child in node.get_children(): walker(child, source_lines, indent + FILL + CHAR_PIPE)
Example #4
Source File: football.py From Jarvis with MIT License | 6 votes |
def matches(self, jarvis, compId): """ Fetches today's matches in given competition and prints the match info """ print() jarvis.spinner_start('Fetching ') r = fetch("/matches?competitions={}".format(compId)) if r is None: jarvis.spinner_stop("Error in fetching data - try again later.", Fore.YELLOW) return jarvis.spinner_stop('') if r["count"] == 0: jarvis.say("No matches found for today.", Fore.BLUE) return else: # Print each match info for match in r["matches"]: matchInfo = self.formatMatchInfo(match) length = len(matchInfo) jarvis.say(matchInfo[0], Fore.BLUE) for i in range(1, length): print(matchInfo[i]) print()
Example #5
Source File: systemOptions.py From Jarvis with MIT License | 6 votes |
def check_ram__WINDOWS(jarvis, s): """ checks your system's RAM stats. -- Examples: check ram """ import psutil mem = psutil.virtual_memory() def format(size): mb, _ = divmod(size, 1024 * 1024) gb, mb = divmod(mb, 1024) return "%s GB %s MB" % (gb, mb) jarvis.say("Total RAM: %s" % (format(mem.total)), Fore.BLUE) if mem.percent > 80: color = Fore.RED elif mem.percent > 60: color = Fore.YELLOW else: color = Fore.GREEN jarvis.say("Available RAM: %s" % (format(mem.available)), color) jarvis.say("RAM used: %s%%" % (mem.percent), color)
Example #6
Source File: CmdInterpreter.py From Jarvis with MIT License | 6 votes |
def _init_plugin_info(self): plugin_status_formatter = { "disabled": len(self._plugin_manager.get_disabled()), "enabled": self._plugin_manager.get_number_plugins_loaded(), "red": Fore.RED, "blue": Fore.BLUE, "reset": Fore.RESET } plugin_status = "{red}{enabled} {blue}plugins loaded" if plugin_status_formatter['disabled'] > 0: plugin_status += " {red}{disabled} {blue}plugins disabled. More information: {red}status\n" plugin_status += Fore.RESET self.first_reaction_text += plugin_status.format( **plugin_status_formatter)
Example #7
Source File: evaluator.py From Jarvis with MIT License | 6 votes |
def calc(jarvis, s, calculator=sympy.sympify, formatter=None, do_evalf=True): s = format_expression(s) try: result = calculator(s) except sympy.SympifyError: jarvis.say("Error: Something is wrong with your expression", Fore.RED) return except NotImplementedError: jarvis.say("Sorry, cannot solve", Fore.RED) return if formatter is not None: result = formatter(result) if do_evalf: result = result.evalf() jarvis.say(str(result), Fore.BLUE)
Example #8
Source File: func.py From fastlane with MIT License | 6 votes |
def __show_diff(expected, actual): seqm = difflib.SequenceMatcher(None, expected, actual) output = [Style.RESET_ALL] for opcode, a0, a1, b0, b1 in seqm.get_opcodes(): if opcode == "equal": output.append(seqm.a[a0:a1]) elif opcode == "insert": output.append(Fore.GREEN + seqm.b[b0:b1] + Style.RESET_ALL) elif opcode == "delete": output.append(Fore.RED + seqm.a[a0:a1] + Style.RESET_ALL) elif opcode == "replace": output.append(Fore.BLUE + seqm.b[b0:b1] + Style.RESET_ALL) else: raise RuntimeError("unexpected opcode") return "".join(output)
Example #9
Source File: log.py From utx with MIT License | 5 votes |
def _print(msg): _logger.debug(Fore.BLUE + "PRINT " + str(msg) + Style.RESET_ALL)
Example #10
Source File: func.py From fastlane with MIT License | 5 votes |
def __validate(topic, execution, **arguments): errors = [] for key, value in arguments.items(): val = execution[key] if isinstance(val, (bytes, str)): val = val.strip() if val != value: if isinstance(val, (bytes, str)): diff = __show_diff(value, val) errors.append( f"{key} field:\n\tExpected: {value}{Style.RESET_ALL}\n\t" f"Actual: {val}\n\tDiff: {diff}\n\t" f"(diff: {Fore.RED}remove{Style.RESET_ALL} " f"{Fore.GREEN}add{Style.RESET_ALL} " f"{Fore.BLUE}replace{Style.RESET_ALL})" ) else: errors.append( f"{key} field:\n\tExpected: {value}{Style.RESET_ALL}\n\tActual: {val}" ) if errors: error_msg = "\n".join(errors) raise AssertionError( f"Execution did not match expectations!\n{Style.RESET_ALL}" f"URL: {topic}\n\n{error_msg}" )
Example #11
Source File: openpyn.py From openpyn-nordvpn with GNU General Public License v3.0 | 5 votes |
def update_config_files() -> None: root.verify_root_access("Root access needed to write files in " + "'" + __basefilepath__ + "files/" + "'") try: zip_archive = __basefilepath__ + "ovpn.zip" if os.path.exists(zip_archive): print(Fore.BLUE + "Previous update file already exists, deleting..." + Style.RESET_ALL) os.remove(zip_archive) subprocess.check_call( ["sudo", "wget", "https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip", "-P", __basefilepath__]) except subprocess.CalledProcessError: logger.error("Exception occurred while wgetting zip, is the internet working? \ is nordcdn.com blocked by your ISP or Country?, If so use Privoxy \ [https://github.com/jotyGill/openpyn-nordvpn/issues/109]") sys.exit() try: subprocess.check_call( ["sudo", "unzip", "-q", "-u", "-o", __basefilepath__ + "ovpn", "-d", __basefilepath__ + "files/"], stderr=subprocess.DEVNULL) subprocess.check_call( ["sudo", "rm", __basefilepath__ + "ovpn.zip"]) except subprocess.CalledProcessError: try: subprocess.check_call( ["sudo", "rm", "-rf", __basefilepath__ + "files/ovpn_udp"]) subprocess.check_call( ["sudo", "rm", "-rf", __basefilepath__ + "files/ovpn_tcp"]) subprocess.check_call( ["sudo", "unzip", __basefilepath__ + "ovpn", "-d", __basefilepath__ + "files/"]) subprocess.check_call( ["sudo", "rm", __basefilepath__ + "ovpn.zip"]) except subprocess.CalledProcessError: logger.error("Exception occured while unzipping ovpn.zip, is unzip installed?") sys.exit() # Lists information about servers under the given criteria.
Example #12
Source File: __main__.py From openpyn-nordvpn with GNU General Public License v3.0 | 5 votes |
def update_config_files() -> None: root.verify_root_access("Root access needed to write files in " + "'" + __basefilepath__ + "files/" + "'") try: zip_archive = __basefilepath__ + "ovpn.zip" if os.path.exists(zip_archive): print(Fore.BLUE + "Previous update file already exists, deleting..." + Style.RESET_ALL) os.remove(zip_archive) subprocess.check_call( ["sudo", "wget", "https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip", "-P", __basefilepath__]) except subprocess.CalledProcessError: logger.error("Exception occurred while wgetting zip, is the internet working? \ is nordcdn.com blocked by your ISP or Country?, If so use Privoxy \ [https://github.com/jotyGill/openpyn-nordvpn/issues/109]") sys.exit() try: subprocess.check_call( ["sudo", "unzip", "-q", "-u", "-o", __basefilepath__ + "ovpn", "-d", __basefilepath__ + "files/"], stderr=subprocess.DEVNULL) subprocess.check_call( ["sudo", "rm", __basefilepath__ + "ovpn.zip"]) except subprocess.CalledProcessError: try: subprocess.check_call( ["sudo", "rm", "-rf", __basefilepath__ + "files/ovpn_udp"]) subprocess.check_call( ["sudo", "rm", "-rf", __basefilepath__ + "files/ovpn_tcp"]) subprocess.check_call( ["sudo", "unzip", __basefilepath__ + "ovpn", "-d", __basefilepath__ + "files/"]) subprocess.check_call( ["sudo", "rm", __basefilepath__ + "ovpn.zip"]) except subprocess.CalledProcessError: logger.error("Exception occured while unzipping ovpn.zip, is unzip installed?") sys.exit() # Lists information about servers under the given criteria.
Example #13
Source File: __main__.py From openpyn-nordvpn with GNU General Public License v3.0 | 5 votes |
def choose_best_servers(best_servers: List, stats: bool) -> List: best_servers_names = [] # populate bestServerList for i in best_servers: best_servers_names.append(i[0][0]) if stats: print("Top " + Fore.GREEN + str(len(best_servers)) + Fore.BLUE + " Servers with Best Ping Are: \ " + Fore.GREEN + str(best_servers_names) + Fore.BLUE) print(Style.RESET_ALL) return best_servers_names
Example #14
Source File: colors.py From CIRTKit with MIT License | 5 votes |
def blue(text, readline=False): return Fore.BLUE + str(text) + Fore.RESET
Example #15
Source File: perftest.py From casepro with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_view(self, user, subdomain, view_name, query_string, num_requests): url = reverse(view_name) + query_string client = DjangoClient() client.force_login(user) statuses = [] request_times = [] db_times = [] query_counts = [] for r in range(num_requests): reset_queries() start_time = time.time() response = client.get(url, HTTP_HOST="%s.localhost" % subdomain) statuses.append(response.status_code) request_times.append(time.time() - start_time) db_times.append(sum([float(q["time"]) for q in connection.queries])) query_counts.append(len(connection.queries)) last_status = statuses[-1] avg_request_time = sum(request_times) / len(request_times) avg_db_time = sum(db_times) / len(db_times) last_query_count = query_counts[-1] self.log( " - %s %s %s secs (db=%s secs, queries=%s)" % ( colored(url, Fore.BLUE), colored(last_status, Fore.GREEN if 200 <= last_status < 300 else Fore.RED), colorcoded(avg_request_time, REQUEST_TIME_LIMITS), colorcoded(avg_db_time, DB_TIME_LIMITS), colorcoded(last_query_count, NUM_QUERY_LIMITS), ) ) return avg_request_time
Example #16
Source File: display.py From SQL-scanner with MIT License | 5 votes |
def banner(self): self.clear() banner = choice(banners) color = choice([Fore.GREEN, Fore.YELLOW, Fore.RED, Fore.MAGENTA, Fore.BLUE, Fore.CYAN]) print(color) print(banner.format('{0}V.{1}{2}'.format(Fore.WHITE, version, Fore.RESET)))
Example #17
Source File: base.py From raw-packet with MIT License | 5 votes |
def __init__(self, admin_only: bool = True, available_platforms: List[str] = ['Linux', 'Darwin', 'Windows']) -> None: """ Init """ # Check user is admin/root if admin_only: self.check_user() # Check platform self.check_platform(available_platforms=available_platforms) # If current platform is Windows get network interfaces settings if self.get_platform().startswith('Windows'): self._windows_adapters = get_adapters() init(convert=True) self.cINFO: str = Style.BRIGHT + Fore.BLUE self.cERROR: str = Style.BRIGHT + Fore.RED self.cSUCCESS: str = Style.BRIGHT + Fore.GREEN self.cWARNING: str = Style.BRIGHT + Fore.YELLOW self.cEND: str = Style.RESET_ALL self.c_info: str = self.cINFO + '[*]' + self.cEND + ' ' self.c_error: str = self.cERROR + '[-]' + self.cEND + ' ' self.c_success: str = self.cSUCCESS + '[+]' + self.cEND + ' ' self.c_warning: str = self.cWARNING + '[!]' + self.cEND + ' ' self.lowercase_letters: str = 'abcdefghijklmnopqrstuvwxyz' self.uppercase_letters: str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' self.digits: str = '0123456789' # endregion # region Output functions
Example #18
Source File: config.py From scrapple with MIT License | 5 votes |
def traverse_next(page, nextx, results, tabular_data_headers=[], verbosity=0): """ Recursive generator to traverse through the next attribute and \ crawl through the links to be followed. :param page: The current page being parsed :param next: The next attribute of the current scraping dict :param results: The current extracted content, stored in a dict :return: The extracted content, through a generator """ for link in page.extract_links(selector=nextx['follow_link']): if verbosity > 0: print('\n') print(Back.YELLOW + Fore.BLUE + "Loading page ", link.url + Back.RESET + Fore.RESET, end='') r = results.copy() for attribute in nextx['scraping'].get('data'): if attribute['field'] != "": if verbosity > 1: print("\nExtracting", attribute['field'], "attribute", sep=' ', end='') r[attribute['field']] = link.extract_content(**attribute) if not nextx['scraping'].get('table'): result_list = [r] else: tables = nextx['scraping'].get('table', []) for table in tables: table.update({ 'result': r, 'verbosity': verbosity }) table_headers, result_list = link.extract_tabular(**table) tabular_data_headers.extend(table_headers) if not nextx['scraping'].get('next'): for r in result_list: yield (tabular_data_headers, r) else: for nextx2 in nextx['scraping'].get('next'): for tdh, result in traverse_next(link, nextx2, r, tabular_data_headers=tabular_data_headers, verbosity=verbosity): yield (tdh, result)
Example #19
Source File: log.py From git-aggregator with GNU Affero General Public License v3.0 | 5 votes |
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, '(%(levelname)s)', Style.RESET_ALL, ' ' ] asctime = [ '[', Fore.BLACK, Style.DIM, Style.BRIGHT, '%(asctime)s', Fore.RESET, Style.RESET_ALL, ']' ] name = [ ' ', Fore.WHITE, Style.DIM, Style.BRIGHT, '%(name)s', Fore.RESET, Style.RESET_ALL, ' ' ] threadName = [ ' ', Fore.BLUE, Style.DIM, Style.BRIGHT, '%(threadName)s ', Fore.RESET, Style.RESET_ALL, ' ' ] tpl = "".join(reset + levelname + asctime + name + threadName + reset) return tpl
Example #20
Source File: setup_old.py From pivy with ISC License | 5 votes |
def blue(text): return Fore.BLUE + text + Style.RESET_ALL
Example #21
Source File: setup.py From pivy with ISC License | 5 votes |
def blue(text): return Fore.BLUE + text + Style.RESET_ALL
Example #22
Source File: stl_combine.py From onshape-to-robot with MIT License | 5 votes |
def simplify_stl(stl_file, max_size=3): size_M = os.path.getsize(stl_file)/(1024*1024) if size_M > max_size: print(Fore.BLUE + '+ '+os.path.basename(stl_file) + (' is %.2f M, running mesh simplification' % size_M)) shutil.copyfile(stl_file, '/tmp/simplify.stl') reduce_faces('/tmp/simplify.stl', stl_file, max_size / size_M)
Example #23
Source File: webdigger.py From webdigger with GNU General Public License v3.0 | 5 votes |
def importwl(file, lst): #wordlist import function try: with open(file, 'r') as f: print (Fore.BLUE+"[+] Gathering required information.") for line in f: final = str(line.replace("\n","")) lst.append(final) except IOError: print (Fore.RED+"[!] ;( Uh Oh! Seems like database is not there.") again()
Example #24
Source File: history.py From Jarvis with MIT License | 5 votes |
def _print_result(self, jarvis, result): # first line of output contains date of fact jarvis.say('\nDate : {} of {}'.format( result['date'], result['year']), Fore.BLUE) # second line contains information jarvis.say('{} : {}'.format(result['type'], result['text']), Fore.BLUE) # next lines will be links to external sources jarvis.say('External links : ', Fore.BLUE) result['links'] = result['links'][:self.MAX_LINK] for i in range(len(result['links'])): jarvis.say(' {}). {}'.format( i + 1, result['links'][i]['link']), Fore.BLUE)
Example #25
Source File: voice.py From Jarvis with MIT License | 5 votes |
def talk_slower(jarvis, s): """Make Jarvis' speech engine talk slower. """ if jarvis.is_voice_enabled(): jarvis.change_speech_rate(-40) else: jarvis.say("Type 'enable sound' to allow Jarvis to talk out loud.", Fore.BLUE)
Example #26
Source File: voice.py From Jarvis with MIT License | 5 votes |
def talk_faster(jarvis, s): """Make Jarvis' speech engine talk faster. """ if jarvis.is_voice_enabled(): jarvis.change_speech_rate(40) else: jarvis.say("Type 'enable sound' to allow Jarvis to talk out loud.", Fore.BLUE)
Example #27
Source File: voice.py From Jarvis with MIT License | 5 votes |
def enable_sound(jarvis, s): """Let Jarvis use his voice.""" jarvis.speech = jarvis.enable_voice() jarvis.say(Fore.BLUE + "Jarvis uses Googles speech engine.\nDo you consent with data " + "collection when Jarvis talks out loud? If yes, type:" + Fore.RED + " gtts") jarvis.say(Fore.BLUE + "If not, Jarvis will talk using the built-in speech engine. " + " If you wish to disable GTTS, type: " + Fore.RED + "disable gtts")
Example #28
Source File: website_status.py From Jarvis with MIT License | 5 votes |
def check_website_status(jarvis, s): prompt = "Please enter a website URL: " while True: # asks for URL to check # adds in https or http if necessary url_request = str(jarvis.input(prompt)) if url_request.startswith('https://'): pass elif url_request.startswith('http://'): pass else: url_request = 'https://' + url_request try: # tries to make a request to the URL that was input # uses defined headers that are not a "bot" headers = {} headers['User-Agent'] = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 \ (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36") req = urllib.request.Request(url_request, headers=headers) page = urllib.request.urlopen(req) code = str(page.getcode()) jarvis.say('The website ' + url_request + ' has returned a ' + code + ' code', Fore.BLUE) break except Exception as e: # if there is an error it will ask if you want to try again jarvis.say(str(e), Fore.RED) jarvis.say("Make sure you are entering a valid URL") try_again = jarvis.input("Do you want to try again (y/n): ") try_again = try_again.lower() if try_again == 'y': continue else: break
Example #29
Source File: systemOptions.py From Jarvis with MIT License | 5 votes |
def Os__LINUX(jarvis, s): """Displays information about your operating system""" jarvis.say('[!] Operating System Information', Fore.BLUE) jarvis.say('[*] ' + sys(), Fore.GREEN) jarvis.say('[*] ' + release(), Fore.GREEN) jarvis.say('[*] ' + distro.name(), Fore.GREEN) for _ in architecture(): jarvis.say('[*] ' + _, Fore.GREEN)
Example #30
Source File: systemOptions.py From Jarvis with MIT License | 5 votes |
def Os__MAC(jarvis, s): """Displays information about your operating system""" jarvis.say( Style.BRIGHT + '[!] Operating System Information' + Style.RESET_ALL, Fore.BLUE) jarvis.say('[*] Kernel: ' + sys(), Fore.GREEN) jarvis.say('[*] Kernel Release Version: ' + release(), Fore.GREEN) jarvis.say('[*] macOS System version: ' + mac_ver()[0], Fore.GREEN) for _ in architecture(): if _ != '': jarvis.say('[*] ' + _, Fore.GREEN)