def init(): # initialize colorama coloramaInit() # get the json intent file intents = json.loads(open("intent.json").read()) # create an instance for lemmatization lemmatizer = WordNetLemmatizer() # check if the model exists first directory_name = os.path.join("chat", "files") # get directory name if not os.path.isdir( os.path.abspath( os.path.join(os.path.dirname(__file__), directory_name))): # import dependencies from chat.save_to_file import words_classes_to_file from chat.training import train # words_classes_to_file() train() else: print(f"Training model already exist!") # get the pickle objects words, classes = get_files() # get model model_name = os.path.join(directory_name, "chatbot_model.model") model = load_model(model_name) return model, words, classes, intents, lemmatizer
def main(): showBanner(True) if len(sys.argv) < 2: print "[i] Trying to autodetect Chameleon-Mini" time.sleep(0.5) args = {'serial': locateDevice ( pyCham.DEVICE_ID ) } if args['serial'] is not None: print "[i] Chameleon-Mini found at " + Fore.GREEN + "%s" % args['serial'] + Fore.RESET time.sleep(1) else: parser = argparse.ArgumentParser() parser.add_argument('serial', metavar='tty', type=str , help='Serial port of Chameleon' ) args = vars(parser.parse_args()) if args['serial'] is None or not os.path.exists ( args['serial' ] ): print "[e] Error: Chameleon serial port not found. Rerun this script with -h parameter to view help." sys.exit(-1) coloramaInit() finish = False while finish is False: cham.setSerial ( args['serial'] ) if cham.openSerial() is None: print "[e] Error opening serial port" sys.exit(-2) finish = showMenu() cham.close() cham.close() return finish
def main(): setup_parameters() coloramaInit() app = QtWidgets.QApplication(sys.argv) script_dir = os.path.dirname(os.path.realpath(__file__)) app.setWindowIcon(QtGui.QIcon(script_dir + os.path.sep + 'logo.png')) # query_user_form = layouts_helper.show_query() # license_view_dialog = layouts_wrapper.LicenseWindow() # license_view_dialog.show() login_form = layouts_wrapper.LoginWindow() login_form.show() sys.exit(app.exec_())
def __init__(self): coloramaInit() clearScreen() self.__gameobjects=[] self.__colorArray=np.full([FRAMEHEIGHT,FRAMEWIDTH],(Fore.WHITE + Back.BLACK)) self.__arr=np.full([FRAMEHEIGHT, FRAMEWIDTH], (' ')) self.__arr[::,0]='|' self.__arr[::,-1]='|' self.__arr[0,::]='-' self.__arr[-1,::]='-' self._starttime=time.time() self.lasttime=time.time() self.lives=3 self._loopGame()
def __init__(self): coloramaInit() clearScreen() self.__gameobjects = [] self.__colorArray = np.full([FRAMEHEIGHT, FRAMEWIDTH], (Fore.WHITE + Back.BLACK)) self.__arr = np.full([FRAMEHEIGHT, FRAMEWIDTH], (' ')) self.__arr[::, 0] = '|' self.__arr[::, -1] = '|' self.__arr[0, ::] = '-' self.__arr[-1, ::] = '-' self._starttime = time.time() self.lasttime = time.time() self.lives = NOLIVES self.levels = 3 self.falltime = 0 self.gravity = 0 self.bossStrength = BOSSSTRENGTH self.defenseWalls = 2 self.bomb = 0 self._loopGame()
from colorama import Fore as color from colorama import Back as fondo from colorama import Style as estilo from colorama import init as coloramaInit coloramaInit(autoreset=True) class Error(Exception): def __init__(self, msj, emisor, *args): cadena = color.RED + msj + ": " + color.RESET + str(emisor) print(cadena) if args: self.argumentos = args print(color.YELLOW + "La aplicación dejo algunos mensajes para tí: ") for i in self.argumentos: print(" -" + i) input(color.RED + fondo.YELLOW + "Presione enter para continuar..." + fondo.RESET + color.RESET)
def main(self): self.timeout_timer = threading.Timer(4200.0, self.reset_query) coloramaInit() clear_screen(True) f = Figlet(font='banner3') print(f.renderText('CP IEEE')) print( Fore.YELLOW + "Cal Poly IEEE Student Branch User Lookup Database (CLI Version)") print( "---------------------------------------------------------------" + Style.RESET_ALL) print("## LOGIN ##\n") user_phone = input("Your Phone Number: ") user_phone_validated = re.match( r'^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$', user_phone) try: user_phone_validated = re.sub("\D", "", user_phone_validated.group(0)) except AttributeError: print(f'{Back.RED}INVALID PHONE NUMBER{Style.RESET_ALL}') time.sleep(1) self.main() user_password = getpass("Your Password: "******"(mobile={user_phone})") if len(get_user_data) == 0 or len(get_user_data) > 1: print("Phone number not found") time.sleep(2) self.main() user_login_string = get_user_data[0].entry_dn initialBind.unbind() self.ldap = ldapServer(server_url, search_base, user_login_string, user_password) self.query_permit = True self.timeout_timer.start() ldapBindResult = self.ldap.bind() if ldapBindResult != True: print(f"{Back.RED}ERROR{Style.RESET_ALL}") print("Description: " + ldapBindResult["description"]) sys.exit() query_parameter = "" while (self.query_permit == True): sys.stdout.write( Back.MAGENTA + Fore.WHITE + "Input either FIRST name, LAST name, or EMAIL (Type HELP for help message):" + Style.RESET_ALL + " ") search_parameter = sys.stdin.readline().strip() if self.query_permit == False: break elif search_parameter.upper() == "HELP": print(f"{Fore.YELLOW}SYSTEM HELP{Style.RESET_ALL}") print( f"{Back.CYAN}EXIT : {Style.RESET_ALL} Exit Application") print( f"{Back.CYAN}EXPORT : {Style.RESET_ALL} Export Query to HTML file" ) print(f"{Back.CYAN}CLEAR : {Style.RESET_ALL} Clear Screen") print( f"{Back.CYAN}LOGOUT : {Style.RESET_ALL} Logout Current User\n" ) elif search_parameter.upper() == "EXIT": raise SystemExit("User exited") elif search_parameter.upper() == "CLEAR": clear_screen(True) elif search_parameter.upper() == "LOGOUT": self.ldap.unbind() setup() elif search_parameter.upper() == "EXPORT": print(f"{Back.RED}{Fore.WHITE}KNOWN ISSUE") print( f"You may have to run this command twice to generate a proper HTML file. This is a known issue.{Style.RESET_ALL}" ) html = self.export_html(query_parameter) sys.stdout.write(Back.MAGENTA + Fore.WHITE + \ "Type the path for the output file (with file name). Press enter to accept default. Please note, you must use UNIX style:" + \ Style.RESET_ALL + " ") file_location = sys.stdin.readline().strip() if file_location == "": file = os.path.join(os.getcwd(), "export.html") else: file = file_location print( f"{Back.YELLOW}{Fore.BLACK}The file has been saved at: {file}.{Style.RESET_ALL}" ) fw = open(file, "w") fw.write(html) else: query_parameter = search_parameter self.search(search_parameter) self.ldap.unbind() clear_screen(True) self.main()
""" A customized logger for pyppl """ import logging import re import sys from copy import copy as pycopy from colorama import init as coloramaInit, Fore, Back, Style # Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET. # Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET. # Style: DIM, NORMAL, BRIGHT, RESET_ALL from .utils import Box from .exception import LoggerThemeError from .template import TemplateLiquid coloramaInit(autoreset=False) # the entire format LOGFMT = "[%(asctime)s%(message)s" # the themes # keys: # - no colon: match directory # - in: from the the list # - starts: startswith the string # - re: The regular expression to match # - has: with the string in flag THEMES = { 'greenOnBlack': Box([ ('DONE', Style.BRIGHT + Fore.GREEN),
# -*- coding: utf-8 -*- from colorama import init as coloramaInit from colorama import Fore, Style from genotype import Allele, Genotype coloramaInit() class Individual(): def __init__(self, genotype: Genotype, sex: bool = None): self._genotype = genotype self._sex=sex @property def genotype(self): return self._genotype @property def sex(self) -> bool: return self._sex class Parent(Individual): '''Parent in paternity test. Args: genotype (Genotype): Genotype. sex (bool): Biological sexes. 1 as male, 0 as female. if_alleged (bool): 1 as alleged, 0 as not alleged.