Python colorama.Fore.LIGHTRED_EX Examples
The following are 30
code examples of colorama.Fore.LIGHTRED_EX().
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: shell.py From unipacker with GNU General Public License v2.0 | 65 votes |
def do_yara(self, args): """Run YARA rules against the sample Usage: yara [<rules_path>] If no rules file is specified, the default 'malwrsig.yar' is being used. Those rules are then compiled and checked against the memory dump of the current emulator state (see 'dump' for further details on this representation)""" if not args: if not self.rules: try: self.rules = yara.compile(filepath=f"{os.path.dirname(unipacker.__file__)}/malwrsig.yar") print("Default rules file used: malwrsig.yar") except: print(f"{Fore.LIGHTRED_EX}Error: malwrsig.yar not found!{Fore.RESET}") else: self.rules = yara.compile(filepath=args) self.sample.unpacker.dump(self.engine.uc, self.engine.apicall_handler, self.sample) matches = self.rules.match("unpacked.exe") print(", ".join(map(str, matches)))
Example #2
Source File: cmd2.py From WebPocket with GNU General Public License v3.0 | 7 votes |
def perror(self, err: Union[str, Exception], traceback_war: bool=True, err_color: str=Fore.LIGHTRED_EX, war_color: str=Fore.LIGHTYELLOW_EX) -> None: """ Print error message to sys.stderr and if debug is true, print an exception Traceback if one exists. :param err: an Exception or error message to print out :param traceback_war: (optional) if True, print a message to let user know they can enable debug :param err_color: (optional) color escape to output error with :param war_color: (optional) color escape to output warning with """ if self.debug: import traceback traceback.print_exc() if isinstance(err, Exception): err_msg = "EXCEPTION of type '{}' occurred with message: '{}'\n".format(type(err).__name__, err) else: err_msg = "{}\n".format(err) err_msg = err_color + err_msg + Fore.RESET self.decolorized_write(sys.stderr, err_msg) if traceback_war and not self.debug: war = "To enable full traceback, run the following command: 'set debug true'\n" war = war_color + war + Fore.RESET self.decolorized_write(sys.stderr, war)
Example #3
Source File: prepend.py From ytmdl with MIT License | 6 votes |
def PREPEND(state): """PREPEND is used to print ==> in front of the lines. They are colorised according to their status. If everything is good then green else red. """ # State 1 is for ok # State 2 is for notok print(Style.BRIGHT, end='') if state == 1: print(Fore.LIGHTGREEN_EX, end='') elif state == 2: print(Fore.LIGHTRED_EX, end='') else: pass print(' ==> ', end='') print(Style.RESET_ALL, end='')
Example #4
Source File: test_unpacker.py From unipacker with GNU General Public License v2.0 | 6 votes |
def test_integrity(self): curr_path = os.getcwd() if "Tests" in curr_path: os.chdir(curr_path.split("Tests")[0]) for rt, dir, _ in os.walk(os.getcwd() + "/Sample/"): for d in dir: for rt2, dir2, f2 in os.walk(rt + d): for f in f2: test_path = os.path.join(rt2, f) relative_test_path = test_path.split(f"Sample{os.path.sep}")[1] if relative_test_path not in self.hashes: print( f"{Fore.LIGHTRED_EX}Warning: Unknown file {relative_test_path} found in sample directory{Fore.RESET}") continue self.assertTrue(calc_md5(test_path).hexdigest() == self.hashes[relative_test_path], f"Tested file: {relative_test_path}. Expected: {self.hashes[relative_test_path]}, got: {calc_md5(test_path).hexdigest()}") print(f"Tested:{relative_test_path}, MD5: {calc_md5(test_path).hexdigest()}")
Example #5
Source File: OxygenX-0.4.py From OxygenX with MIT License | 6 votes |
def labymod(self, uuid, combo, user): cape = False if OxygenX.Cape.labymod: link = f'http://capes.labymod.net/capes/{uuid[:8]}-{uuid[8:12]}-{uuid[12:16]}-{uuid[16:20]}-{uuid[20:]}' try: laby = get(url=link).text if not str(laby).__contains__('Not Found'): cape = True except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Error Labymod:\n{e}{Fore.WHITE}') if cape: Counter.labymod += 1 open(f'{self.folder}/LabymodCape.txt', 'a', encoding='u8').write( f'{combo} | Username: {user}\n') return cape
Example #6
Source File: OxygenX-0.4.py From OxygenX with MIT License | 6 votes |
def hivemc(self, uuid, combo): rank = False if OxygenX.Rank.hivemc_rank: try: response = get(url=f'https://www.hivemc.com/player/{uuid}').text match = self.rankhv.search(response).group(1) if match != 'Regular': rank = match except AttributeError: rank = False except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Error HiveMC:\n{e}{Fore.WHITE}') if rank: open(f'{self.folder}/HiveRanked.txt', 'a', encoding='u8').write( f'{combo} | Rank: {str(rank)}\n') Counter.hivemcrank += 1 return rank
Example #7
Source File: OxygenX-0.4.py From OxygenX with MIT License | 6 votes |
def veltpvp(self, username, combo): rank = False if OxygenX.Rank.veltpvp_rank: try: link = get(url=f'https://www.veltpvp.com/u/{username}', headers=self.mailheaders).text if '<h1>Not Found</h1><p>The requested URL' not in link: rank = self.veltrank.search(link).group(1) if rank == 'Standard' or rank == 'Default': rank = False else: rank = rank except AttributeError: rank = False except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Error Veltpvp:\n{e}{Fore.WHITE}') if rank: open(f'{self.folder}/VeltRanked.txt', 'a', encoding='u8').write(f'{combo} | Rank: {rank}\n') Counter.veltrank += 1 return rank
Example #8
Source File: argparse_completer.py From WebPocket with GNU General Public License v3.0 | 6 votes |
def error(self, message: str) -> None: """Custom error override. Allows application to control the error being displayed by argparse""" if len(self._custom_error_message) > 0: message = self._custom_error_message self._custom_error_message = '' lines = message.split('\n') linum = 0 formatted_message = '' for line in lines: if linum == 0: formatted_message = 'Error: ' + line else: formatted_message += '\n ' + line linum += 1 sys.stderr.write(Fore.LIGHTRED_EX + '{}\n\n'.format(formatted_message) + Fore.RESET) # sys.stderr.write('{}\n\n'.format(formatted_message)) self.print_help() sys.exit(1)
Example #9
Source File: OxygenX-0.4.py From OxygenX with MIT License | 6 votes |
def lunar(self, uuid, combo): both = [False, False] if OxygenX.Rank.lunar_rank: try: check = get(url=f'http://www.lunar.gg/u/{uuid}', headers=self.mailheaders).text if '404: Page Not Found' not in check: if '>Banned<' in check: both[1] = True both[0] = self.lunarr.search(check).group(1) if both[0] == 'Default': both[0] = False else: both[0] = both[0] except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Error Lunar: \n{e}{Fore.WHITE}') if both[0]: open(f'{self.folder}/LunarRanked.txt', 'a', encoding='u8').write(f'{combo} | Rank: {both[0]}\n') Counter.lunarrank += 1 return both
Example #10
Source File: clean_folder.py From Scripting-and-Web-Scraping with MIT License | 6 votes |
def source_path(dir_name): for root in os.walk("/home"): if dir_name == root[0].split('/')[-1]: all_paths.append(root[0]) for i in range(len(all_paths)): print() print("{}. {}".format(i+1,all_paths[i])) if len(all_paths) == 0: print(Fore.LIGHTRED_EX + 'No directory found') exit() choice = int(input('\nEnter the option number: ')) if choice < 1 or choice > len(all_paths): print(Fore.LIGHTRED_EX +'Wrong choice entered') exit() else: path = all_paths[choice-1] return path
Example #11
Source File: OxygenX-0.4.py From OxygenX with MIT License | 6 votes |
def mailaccess(self, email, password): mailaccesz = False if OxygenX.emailaccess: try: link = f'http://aj-https.my.com/cgi-bin/auth?timezone=GMT%2B2&reqmode=fg&ajax_call=1&udid=16cbef29939532331560e4eafea6b95790a743e9&device_type=Tablet&mp=iOS¤t=MyCom&mmp=mail&os=iOS&md5_signature=6ae1accb78a8b268728443cba650708e&os_version=9.2&model=iPad%202%3B%28WiFi%29&simple=1&Login={email}&ver=4.2.0.12436&DeviceID=D3E34155-21B4-49C6-ABCD-FD48BB02560D&country=GB&language=fr_FR&LoginType=Direct&Lang=fr_FR&Password={password}&device_vendor=Apple&mob_json=1&DeviceInfo=%7B%22Timezone%22%3A%22GMT%2B2%22%2C%22OS%22%3A%22iOS%209.2%22%2C?%22AppVersion%22%3A%224.2.0.12436%22%2C%22DeviceName%22%3A%22iPad%22%2C%22Device?%22%3A%22Apple%20iPad%202%3B%28WiFi%29%22%7D&device_name=iPad&' ans = get(url=link, headers=self.mailheaders).text except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Error Mail Access: \n{e}{Fore.WHITE}') ans = 'bad' if 'Ok=1' in ans: mailaccesz = True if mailaccesz: Counter.emailaccess += 1 open(f'{self.folder}/EmailAccess.txt', 'a', encoding='u8').write(f'{email}:{password}\n') return mailaccesz
Example #12
Source File: shell.py From unipacker with GNU General Public License v2.0 | 6 votes |
def do_aaa(self, args): """Analyze absolutely all: Show a collection of stats about the current sample""" print(f"{Fore.LIGHTRED_EX}File analysis:{Fore.RESET}") print_cols([ ("YARA:", ", ".join(map(str, self.sample.yara_matches))), ("Chosen unpacker:", self.sample.unpacker.__class__.__name__), ("Allowed sections:", ', '.join(self.sample.unpacker.allowed_sections)), ("End of unpacking stub:", f"0x{self.sample.unpacker.endaddr:02x}" if self.sample.unpacker.endaddr != sys.maxsize else "unknown"), ("Section hopping detection:", "active" if self.sample.unpacker.section_hopping_control else "inactive"), ("Write+Exec detection:", "active" if self.sample.unpacker.write_execute_control else "inactive") ]) print(f"\n{Fore.LIGHTRED_EX}PE stats:{Fore.RESET}") print_cols([ ("Declared virtual memory size:", f"0x{self.sample.virtualmemorysize:02x}", "", ""), ("Actual loaded image size:", f"0x{len(self.sample.loaded_image):02x}", "", ""), ("Image base address:", f"0x{self.sample.BASE_ADDR:02x}", "", ""), ("Mapped stack space:", f"0x{self.engine.STACK_ADDR:02x}", "-", f"0x{self.engine.STACK_ADDR + self.engine.STACK_SIZE:02x}"), ("Mapped hook space:", f"0x{self.engine.HOOK_ADDR:02x}", "-", f"0x{self.engine.HOOK_ADDR + 0x1000:02x}") ]) self.do_i("i") print(f"\n{Fore.LIGHTRED_EX}Register status:{Fore.RESET}") self.do_i("r")
Example #13
Source File: shell.py From unipacker with GNU General Public License v2.0 | 6 votes |
def sample_loop(self, samples=None): known_samples = self.init_banner_and_history() if not samples: sample_path = self.get_path_from_user(known_samples) samples = Sample.get_samples(sample_path) for self.sample in samples: print(f"\nNext up: {self.sample}") with open(".unpacker_history", "w") as f: f.writelines( "\n".join(sorted(set([f"{self.sample.unpacker.name};{self.sample.path}"] + known_samples[:-1])))) self.init_engine() with open(f"{os.path.dirname(unipacker.__file__)}/fortunes") as f: fortunes = f.read().splitlines() print(f"\n{Fore.LIGHTRED_EX}{choice(fortunes)}{Fore.RESET}\n") self.cmdloop() if self.clear_queue: break
Example #14
Source File: shell.py From unipacker with GNU General Public License v2.0 | 6 votes |
def print_imports(self, args): lines_static = [] lines_dynamic = [] for addr, name in self.engine.apicall_handler.hooks.items(): try: module = self.engine.apicall_handler.module_for_function[name] except KeyError: module = "?" if name in self.sample.imports: lines_static += [(f"0x{addr:02x}", name, module)] else: lines_dynamic += [(f"0x{addr:02x}", name, module)] print(f"\n{Fore.LIGHTRED_EX}Static imports:{Fore.RESET}") print_cols(lines_static) print(f"\n{Fore.LIGHTRED_EX}Dynamic imports:{Fore.RESET}") print_cols(lines_dynamic)
Example #15
Source File: shell.py From unipacker with GNU General Public License v2.0 | 5 votes |
def do_eof(self, args): """Exit un{i}packer by pressing ^D""" if self.started: self.shell_event.clear() self.engine.stop() self.shell_event.wait() with open(f"{os.path.dirname(unipacker.__file__)}/fortunes") as f: fortunes = f.read().splitlines() print(f"\n{Fore.LIGHTRED_EX}{choice(fortunes)}{Fore.RESET}") self.exit_code = 0 return super().do_eof(args)
Example #16
Source File: diff.py From ward with MIT License | 5 votes |
def bright_red(s: str) -> str: return f"{Fore.LIGHTRED_EX}{s}{Style.RESET_ALL}"
Example #17
Source File: color.py From domained with GNU General Public License v3.0 | 5 votes |
def warning(msg): colored(msg, fore=Fore.LIGHTRED_EX)
Example #18
Source File: OxygenX-0.4.py From OxygenX with MIT License | 5 votes |
def liquidbounce(self): try: lbc = get( url=f'https://raw.githubusercontent.com/CCBlueX/FileCloud/master/LiquidBounce/cape/service.json').text return lbc except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Error LiquidBounce:\n{e}{Fore.WHITE}') return False
Example #19
Source File: OxygenX-0.4.py From OxygenX with MIT License | 5 votes |
def optifine(self, user, combo): cape = False if OxygenX.Cape.optifine: try: optifine = get(url=f'http://s.optifine.net/capes/{user}.png').text if not str(optifine).__contains__('Not found'): cape = True except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Error Optifine:\n{e}{Fore.WHITE}') if cape: Counter.optifine += 1 open(f'{self.folder}/OptifineCape.txt', 'a', encoding='u8').write( f'{combo} | Username: {user}\n') return cape
Example #20
Source File: OxygenX-0.4.py From OxygenX with MIT License | 5 votes |
def mojang(self, uuid, combo, user): cape = False if OxygenX.Cape.minecon: try: mine = get(url=f'https://api.ashcon.app/mojang/v2/user/{uuid}').text if mine.__contains__('"cape"'): cape = True except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Error MojangCape:\n{e}{Fore.WHITE}') if cape: Counter.mojang += 1 open(f'{self.folder}/MineconCape.txt', 'a', encoding='u8').write( f'{combo} | Username: {user}\n') return cape
Example #21
Source File: rpsgame.py From python-for-absolute-beginners-course with MIT License | 5 votes |
def get_roll(player_name, roll_names): if os.environ.get('PYCHARM_HOSTED') == "1": print(Fore.LIGHTRED_EX + "Warning: Cannot use fancy prompt dialog in PyCharm.") print(Fore.LIGHTRED_EX + "Run this app outside of PyCharm to see it in action.") val = input(Fore.LIGHTYELLOW_EX + "What is your roll: ") print(Fore.WHITE) return val print(f"Available rolls: {', '.join(roll_names)}.") # word_comp = WordCompleter(roll_names) word_comp = PlayComplete() roll = prompt(f"{player_name}, what is your roll: ", completer=word_comp) if not roll or roll not in roll_names: print(f"Sorry {player_name}, {roll} not valid!") return None return roll # def get_roll(player_name, roll_names): # print("Available rolls:") # for index, r in enumerate(roll_names, start=1): # print(f"{index}. {r}") # # text = input(f"{player_name}, what is your roll? ") # selected_index = int(text) - 1 # # if selected_index < 0 or selected_index >= len(rolls): # print(f"Sorry {player_name}, {text} is out of bounds!") # return None # # return roll_names[selected_index] #
Example #22
Source File: OxygenX-0.4.py From OxygenX with MIT License | 5 votes |
def hypixel(self, uuid, combo): both = [False, False, False, False] if self.hypr or self.hypl: try: answer = get(url=f'https://api.slothpixel.me/api/players/{uuid}').json() if 'Failed to get player uuid' not in str(answer): rank = str(answer['rank']) if rank.__contains__('_PLUS'): rank = rank.replace('_PLUS', '+') level = int(answer["level"]) nolog = str(answer['username']) if nolog == 'None': both[2] = True else: both[0] = str(rank) both[1] = int(round(level)) both[3] = str(datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta( milliseconds=int(answer['last_login']))).split(' ')[0] else: both[2] = True except Exception as e: if self.debug: self.printing.put(f'{Fore.LIGHTRED_EX}Slothpixel API Error: \n{e}{Fore.WHITE}') if not both[2]: if both[0] != 'None': Counter.hypixelrank += 1 open(f'{self.folder}/HypixelRanked.txt', 'a', encoding='u8').write( f'{combo} | Rank: {both[0]}\n') if both[1] >= OxygenX.Level.hypixel_level: Counter.hypixelhl += 1 open(f'{self.folder}/HypixelHighLevel.txt', 'a', encoding='u8').write( f'{combo} | Level: {str(both[1])}\n') else: Counter.nohypixel += 1 open(f'{self.folder}/NoHypixelLogin.txt', 'a', encoding='u8').write(f'{combo}\n') return both
Example #23
Source File: OxygenX-0.4.py From OxygenX with MIT License | 5 votes |
def refresh_api_link(self): while True: try: sleep(OxygenX.Proxy.refresh_api) self.proxylist = [x.strip() for x in get(url=OxygenX.Proxy.proxy_api).text.splitlines() if ':' in x] except Exception as e: if self.debug: print(f'{Fore.LIGHTRED_EX}Refreshing API link error: {e}') continue
Example #24
Source File: tools.py From transpyle with Apache License 2.0 | 5 votes |
def make_completed_process_report( result: subprocess.CompletedProcess, actual_call: t.Optional[str] = None, short: bool = False) -> str: """Create a human-readable summary of executed process.""" out = io.StringIO() args_str = result.args if isinstance(result.args, str) else ' '.join(result.args) if actual_call is None: out.write('execution of "{}"'.format(args_str)) else: out.write('call to {} (simulating: "{}")'.format(actual_call, args_str)) out.write(' {}{}{}'.format(Style.BRIGHT, 'succeeded' if result.returncode == 0 else 'failed', Style.NORMAL)) if result.returncode != 0: out.write(' (returncode={}{}{})'.format(Fore.LIGHTRED_EX, result.returncode, Style.RESET_ALL)) if short: return out.getvalue() out.write('\n') if result.stdout: out.write('{}stdout{}:\n'.format(Fore.CYAN, Fore.RESET)) out.write(result.stdout.rstrip()) out.write('\n') else: out.write('{}no stdout{}, '.format(Fore.CYAN, Fore.RESET)) if result.stderr: out.write('{}stderr{}:\n'.format(Fore.CYAN, Fore.RESET)) out.write(result.stderr.rstrip()) else: out.write('{}no stderr{}, '.format(Fore.CYAN, Fore.RESET)) # out.write('\n{}'.format(result)) return out.getvalue()
Example #25
Source File: iface_controller_template.py From PROTON with BSD 3-Clause "New" or "Revised" License | 5 votes |
def on_get(self, req, resp): """ This is recipient of REST GET request. Extract query params, use req.get_param(<queryParamId>) --- description: GET call for {{ iControllerName }} leveraging Ctrl_{{ controllerName }} of PROTON MIC responses: 200: description: <Add description relevant to GET. This will be picked by Swagger generator> schema: <Schema of Response> """ try: # If you have newer methods available under Controller, reference that below as per your convenience. print(Fore.BLUE + 'Request for route {} is being serviced by conventional db service of ' 'PROTON stack'.format(req) + Style.RESET_ALL) query_params_kwargs = dict(req.params.items()) response = self.controller_processor()['{{ controller.iControllerName }}']['{{ methodName }}'](self.TARGET_DB, query_params_kwargs) status = falcon.HTTP_200 except Exception as e: response = json.dumps({'message': 'Server has failed to service this request.', 'stackTrace': str(e)}) status = falcon.HTTP_500 print(Fore.LIGHTRED_EX + '[Ictrl_{{ controller.iControllerName }}]: GET is unsuccessful. ' 'InterfaceController has returned HTTP 500 to client. ' 'Exception Details: {}'.format(str(e)) + Style.RESET_ALL) finally: resp.body = response resp.status = status
Example #26
Source File: protonkill.py From PROTON with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): super(ProtonKill, self).__init__() self.protonkill_logger = self.get_logger(log_file_name='proton_kill_logs', log_file_path='{}/trace/proton_kill_logs.log'.format(self.ROOT_DIR)) self.parser = argparse.ArgumentParser() self.parser.add_argument('--micNameToKill') self.proton_args = self.parser.parse_args() if self.proton_args.micNameToKill is None: print(Fore.LIGHTRED_EX + '[Proton kill] - Please provide a valid MIC Name. A name that exists in PROTON ' 'stack! Use --micNameToKill option' + Style.RESET_ALL) else: self.destroy_mic_stack(self.proton_args.micNameToKill)
Example #27
Source File: headers.py From unipacker with GNU General Public License v2.0 | 5 votes |
def print_iat(uc, base_addr): imp = parse_memory_to_header(uc, base_addr, "IMPORTS") print(f"{Fore.LIGHTYELLOW_EX}IMPORT ADDRESS TABLE:{Fore.RESET}") for i in imp: indent = '\t' if i.Name == 0: return print(f"{indent} Name: {Fore.LIGHTRED_EX}{get_string(base_addr + i.Name, uc)}{Fore.RESET}") print(f"{indent} Characteristics (Hint/Name): {Fore.LIGHTRED_EX}{hex(i.Characteristics)}{Fore.RESET}") print(f"{indent} TimeDateStamp: {Fore.LIGHTRED_EX}{hex(i.TimeDateStamp)}{Fore.RESET}") print(f"{indent} ForwarderChain: {Fore.LIGHTRED_EX}{hex(i.ForwarderChain)}{Fore.RESET}") print(f"{indent} FirstThunk: {Fore.LIGHTRED_EX}{hex(i.FirstThunk)}{Fore.RESET}") indent = '\t\t' if i.Characteristics == 0: print(f"{indent} Hint/Name Array is not set") else: curr_pos = 0 imp_array_element = struct.unpack("<I", uc.mem_read(base_addr + i.Characteristics, 4))[0] if (imp_array_element >> 20) == 0x1 and ((imp_array_element & 0xFFEFFFFF) >> 14) == 0x1: print(f"{indent}No resolving of imports as hookaddr values are set") continue while imp_array_element != 0: if imp_array_element >> 0x1f == 1: print(f"{indent} Import by Ordinal: " f"{Fore.LIGHTRED_EX}{hex(imp_array_element - 0x80000000)}{Fore.RESET}") else: print(f"{indent} Import by Name: " f"{Fore.LIGHTRED_EX}{get_string(base_addr + imp_array_element + 0x2, uc)}{Fore.RESET}") curr_pos += 0x4 imp_array_element = struct.unpack("<I", uc.mem_read(base_addr + i.Characteristics + curr_pos, 4))[0] print()
Example #28
Source File: rpsgame.py From python-for-absolute-beginners-course with MIT License | 5 votes |
def main(): try: print(Fore.WHITE) log("App starting up...") show_header() load_rolls() show_leaderboard() player1, player2 = get_players() log(f"{player1} has logged in.") play_game(player1, player2) log("Game over.") except json.decoder.JSONDecodeError as je: print() print(Fore.LIGHTRED_EX + "ERROR: The file rolls.json is invalid JSON." + Fore.WHITE) print(Fore.LIGHTRED_EX + f"ERROR: {je}" + Fore.WHITE) except FileNotFoundError as fe: print() print(Fore.LIGHTRED_EX + "ERROR: Rolls file not found" + Fore.WHITE) print(Fore.LIGHTRED_EX + f"ERROR: {fe}" + Fore.WHITE) except KeyboardInterrupt: print() print(Fore.LIGHTCYAN_EX + "You gotta run? Ok, cya next time!" + Fore.WHITE) except Exception as x: print(Fore.LIGHTRED_EX + f"Unknown error: {x}" + Fore.WHITE)
Example #29
Source File: logger.py From brutemap with GNU General Public License v3.0 | 5 votes |
def colorize(self, msg): """ Mewarnai pesan """ color = self.color_map[self.record.levelno] reset = Style.RESET_ALL levelname = reset + color + self.record.levelname + reset if self.record.levelname == "CRITICAL": color = self.color_map[logging.ERROR] name = Fore.LIGHTBLUE_EX + self.record.name + reset message = self.record.message # XXX: kenapa cara dibawah ini tidak bekerja? # # match = re.findall(r"['\"]+(.*?)['\"]+", message) # if match: # match.reverse() # for m in match: # message = message.replace(m, color + m + reset, 1) match = re.search(r"=> (?P<account>.*?(?:| \: .*?)) \((?P<status>[A-Z]+)\)", message) if match: account = match.group("account") status = match.group("status") if status == "NO": color_status = Fore.LIGHTRED_EX else: color_status = Fore.LIGHTGREEN_EX newmsg = message.replace(account, color_status + account + reset) newmsg = newmsg.replace(status, color_status + status + reset) msg = msg.replace(message, newmsg) asctime = re.findall(r"\[(.+?)\]", msg)[0] msg = msg.replace(asctime, Fore.LIGHTMAGENTA_EX + asctime + reset, 1) msg = msg.replace(self.record.name, name, 1) msg = msg.replace(self.record.levelname, levelname, 1) msg = msg + reset return msg
Example #30
Source File: file_organise.py From Jarvis with MIT License | 5 votes |
def source_path(self, jarvis, dir_name): all_paths = [] # Changing static path to get the home path from PATH variables. # The '/home' was causing script to exit with "file not found" error # on Darwin. home_dir = os.environ.get("HOME") user_name = os.environ.get("USER") home_path = home_dir.split(user_name)[0].rstrip('/') for root in os.walk(home_path): print( Fore.LIGHTBLUE_EX + "Searching in {}...".format( (root[0])[ :70]), end="\r") sys.stdout.flush() if dir_name == root[0].split('/')[-1]: all_paths.append(root[0]) for i, path_info in enumerate(all_paths): print() print("{}. {}".format(i + 1, path_info)) if len(all_paths) == 0: print(Fore.LIGHTRED_EX + 'No directory found') exit() choice = int(jarvis.input('\nEnter the option number: ')) if choice < 1 or choice > len(all_paths): path = '' print(Fore.LIGHTRED_EX + 'Wrong choice entered') exit() else: path = all_paths[choice - 1] return path