本文整理汇总了Python中colorama.Fore.RED属性的典型用法代码示例。如果您正苦于以下问题:Python Fore.RED属性的具体用法?Python Fore.RED怎么用?Python Fore.RED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类colorama.Fore
的用法示例。
在下文中一共展示了Fore.RED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_subreddits
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def print_subreddits(self, parser, reddit, search_for):
print("\nChecking if Subreddit(s) exist...")
subs, not_subs = self._find_subs(parser, reddit, search_for)
if subs:
print("\nThe following Subreddits were found and will be scraped:")
print("-" * 56)
print(*subs, sep = "\n")
if not_subs:
print("\nThe following Subreddits were not found and will be skipped:")
print("-" * 60)
print(*not_subs, sep = "\n")
if not subs:
print(Fore.RED + Style.BRIGHT + "\nNo Subreddits to scrape!")
print(Fore.RED + Style.BRIGHT + "\nExiting.\n")
quit()
return subs
示例2: confirm_subreddits
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def confirm_subreddits(subs, parser):
while True:
try:
confirm = input("\nConfirm selection? [Y/N] ").strip().lower()
if confirm == options[0]:
subs = [sub for sub in subs]
return subs
elif confirm not in options:
raise ValueError
else:
print(Fore.RED + Style.BRIGHT + "\nExiting.\n")
parser.exit()
except ValueError:
print("Not an option! Try again.")
### Scrape again?
示例3: list_submissions
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def list_submissions(reddit, post_list, parser):
print("\nChecking if post(s) exist...")
posts, not_posts = Validation.Validation.existence(s_t[2], post_list, parser, reddit, s_t)
if not_posts:
print(Fore.YELLOW + Style.BRIGHT +
"\nThe following posts were not found and will be skipped:")
print(Fore.YELLOW + Style.BRIGHT + "-" * 55)
print(*not_posts, sep = "\n")
if not posts:
print(Fore.RED + Style.BRIGHT + "\nNo submissions to scrape!")
print(Fore.RED + Style.BRIGHT + "\nExiting.\n")
quit()
return posts
示例4: list_redditors
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def list_redditors(parser, reddit, user_list):
print("\nChecking if Redditor(s) exist...")
users, not_users = Validation.Validation.existence(s_t[1], user_list, parser, reddit, s_t)
if not_users:
print(Fore.YELLOW + Style.BRIGHT +
"\nThe following Redditors were not found and will be skipped:")
print(Fore.YELLOW + Style.BRIGHT + "-" * 59)
print(*not_users, sep = "\n")
if not users:
print(Fore.RED + Style.BRIGHT + "\nNo Redditors to scrape!")
print(Fore.RED + Style.BRIGHT + "\nExiting.\n")
quit()
return users
示例5: master_timer
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def master_timer(function):
def wrapper(*args):
logging.info("INITIALIZING URS.")
logging.info("")
start = time.time()
try:
function(*args)
except KeyboardInterrupt:
print(Style.BRIGHT + Fore.RED + "\n\nURS ABORTED BY USER.\n")
logging.warning("")
logging.warning("URS ABORTED BY USER.\n")
quit()
logging.info("URS COMPLETED SCRAPES IN %.2f SECONDS.\n" % \
(time.time() - start))
return wrapper
示例6: get_roll
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def get_roll(player_name, roll_names):
try:
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? ")
if text is None or not text.strip():
print("You must enter response")
return None
selected_index = int(text) - 1
if selected_index < 0 or selected_index >= len(roll_names):
print(f"Sorry {player_name}, {text} is out of bounds!")
return None
return roll_names[selected_index]
except ValueError as ve:
print(Fore.RED + f"Could not convert to integer: {ve}" + Fore.WHITE)
return None
示例7: CreateGitHubRepo
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def CreateGitHubRepo():
global repoName
global private
global username
global password
GetCredentials()
try:
user = Github(username, password).get_user()
user.create_repo(repoName, private=private)
return True
except Exception as e:
repoName = ""
username = ""
password = ""
private = ""
print(Fore.RED + str(e) + Fore.WHITE)
return False
示例8: handle_one_request
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def handle_one_request(self):
"""Catch more exceptions than default
Intend to catch exceptions on local side
Exceptions on remote side should be handled in do_*()
"""
try:
BaseHTTPRequestHandler.handle_one_request(self)
return
except (ConnectionError, FileNotFoundError) as e:
logger.warning("%03d " % self.reqNum + Fore.RED + "%s %s", self.server_version, e)
except (ssl.SSLEOFError, ssl.SSLError) as e:
if hasattr(self, 'url'):
# Happens after the tunnel is established
logger.warning("%03d " % self.reqNum + Fore.YELLOW + '"%s" while operating on established local SSL tunnel for [%s]' % (e, self.url))
else:
logger.warning("%03d " % self.reqNum + Fore.YELLOW + '"%s" while trying to establish local SSL tunnel for [%s]' % (e, self.path))
self.close_connection = 1
示例9: read_meta
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def read_meta(path: str) -> Optional[PluginMeta]:
try:
with open(os.path.join(path, "maubot.yaml")) as meta_file:
try:
meta_dict = yaml.load(meta_file)
except YAMLError as e:
print(Fore.RED + "Failed to build plugin: Metadata file is not YAML")
print(Fore.RED + str(e) + Fore.RESET)
return None
except FileNotFoundError:
print(Fore.RED + "Failed to build plugin: Metadata file not found" + Fore.RESET)
return None
try:
meta = PluginMeta.deserialize(meta_dict)
except SerializerError as e:
print(Fore.RED + "Failed to build plugin: Metadata file is not valid")
print(Fore.RED + str(e) + Fore.RESET)
return None
return meta
示例10: login
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [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)
示例11: update_progress
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [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()
示例12: run_feed_server
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [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
示例13: create_json_feed
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def create_json_feed(meta, json_path):
#Creating JSON feed using scripts in cbfeeds/
data = generate_feed.create_feed(meta)
#print data
#Saving the data to file in json_feeds/
try:
print((Fore.YELLOW + '[*]' + Fore.RESET), end=' ')
print('Saving report to: %s' % json_path)
dump_data = open(json_path, 'w+').write(data)
except:
print((Fore.RED + '[-]' + Fore.RESET), end=' ')
print('Could not dump report to %s' % json_path)
exit(0)
return
示例14: execute
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def execute():
cfg = Configuration(".bitmaskctl")
print_json = '--json' in sys.argv
cli = BitmaskCLI(cfg)
cli.data = ['core', 'version']
args = None if '--noverbose' in sys.argv else ['--verbose']
if should_start(sys.argv):
timeout_fun = cli.start
else:
def status_timeout(args):
raise RuntimeError('bitmaskd is not running')
timeout_fun = status_timeout
try:
yield cli._send(
timeout=0.1, printer=_null_printer,
errb=lambda: timeout_fun(args))
except Exception, e:
print(Fore.RED + "ERROR: " + Fore.RESET +
"%s" % str(e))
yield reactor.stop()
示例15: update
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import RED [as 别名]
def update():
print_out(Fore.CYAN + "Just checking for updates, please wait...")
print_out(Fore.CYAN + "Updating CloudFlare subnet...")
if(args.tor == False):
headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'}
r = requests.get("https://www.cloudflare.com/ips-v4", headers=headers, cookies={'__cfduid': "d7c6a0ce9257406ea38be0156aa1ea7a21490639772"}, stream=True)
with open('data/cf-subnet.txt', 'wb') as fd:
for chunk in r.iter_content(4000):
fd.write(chunk)
else:
print_out(Fore.RED + Style.BRIGHT+"Unable to fetch CloudFlare subnet while TOR is active")
print_out(Fore.CYAN + "Updating Crimeflare database...")
r = requests.get("http://crimeflare.net:83/domains/ipout.zip", stream=True)
with open('data/ipout.zip', 'wb') as fd:
for chunk in r.iter_content(4000):
fd.write(chunk)
zip_ref = zipfile.ZipFile("data/ipout.zip", 'r')
zip_ref.extractall("data/")
zip_ref.close()
os.remove("data/ipout.zip")
# END FUNCTIONS