예제 #1
0
 def give_options(self, option_input):
     """
     Displays the options for the users to select
     """
     try:
         if option_input == 1:
             card_type = Prompt.prompt_card_type()
             self.add_card(card_type)
         elif option_input == 2:
             id_input = Prompt.prompt_id()
             self.search_card(id_input)
         elif option_input == 3:
             id_input = Prompt.prompt_id()
             self.delete_card(id_input)
         elif option_input == 4:
             self.export_card()
         elif option_input == 5:
             self.check_cards()
         elif option_input == 6:
             print("See you next time")
             exit()
         else:
             raise ValueError
     except ValueError:
         print("Select from within the provided options!")
예제 #2
0
def main():
    """ Main execution thread """

    options = Options().load_options()
    prompt = Prompt(options)
    prompt.prompt = 'falconbot> '
    prompt.cmdloop('[+] Starting falconbot interface...')
def main():
    print(Banner("GUESS THE NUMBER APP").content)
    calibrator = Calibrator(random.randint(0, 100))
    prompt = Prompt()
    success = False
    while not success:
        calibration = calibrator.calibrate(prompt.input())
        print(calibration.message)
        success = calibration.is_equal
예제 #4
0
def main():
    """ Main execution thread """

    options = Options().load_options()
    connect_string = "host=" + options["host"] + " port=" + options[
        "port"] + " dbname=" + options["db"] + " user="******"username"] + " password="******"password"]
    prompt = Prompt(connect_string)
    prompt.prompt = 'schemabridge> '
    prompt.cmdloop('[+] Starting schemabridge interface...')
예제 #5
0
 def run(self):
     """
     Runs the program
     """
     Prompt.welcome()
     if Prompt.will_start():
         self._wallet = Wallet()
         print("\nSuccessfully created wallet")
         while True:
             option_input = Prompt.display_options()
             self.give_options(option_input)
예제 #6
0
def main() -> None:
    """Main function to run the app."""
    prompt = Prompt()
    prompt.greet()
    prompt.check_conditions()

    iterate_through_primary = prompt.iterate_through_primary()
    iterate_through_secondary = prompt.iterate_through_secondary()

    prompt.announce_start()

    clicker = Clicker(iterate_through_primary, iterate_through_secondary)
    clicker.run()
예제 #7
0
 def lookup_name_in_current_repos(self, program_name):
     #self.update_sys_list()
     lookup_command_text = 'sudo apt-cache search {0}'.format(program_name)
     lookup_command = BashCommand(lookup_command_text, r='output')
     full_list = lookup_command.run()
     select_start_to_hyphen = re.compile(r'^(\S*)\s-')
     program_list = []
     for l in full_list.split('\n'):
         m = select_start_to_hyphen.search(l)
         if m:
             program_list.append(m.groups()[0])
     print('candidates found in your local repos: ')
     Prompt.column_print(program_list)
     return program_name in program_list
예제 #8
0
 def handle_results(self, raise_on_error=True):
     if self.verbose >= 2:
         print(self.execution_stdout)
     if self.verbose >= 1:
         print(self.execution_stderr)
     try:
         assert self.return_code == 0
     except AssertionError:
         Prompt.write_to_prompt('!!!Something went wrong there!!!')
         if raise_on_error:
             raise
         else:
             return 1
     return 0
 def init_verify_clicked(self):
     if os.path.exists("user_face/user.jpg"):
         Prompt("已经录入人脸数据,请直接进行验证!", self).show()
         return
     self.face_ui.set_mode(0)
     self.hide()
     self.face_ui.show()
 def face_verify_clicked(self):
     if not os.path.exists("user_face/user.jpg"):
         Prompt("系统未录入人脸数据,请进行初始化系统!", self).show()
         return
     self.face_ui.set_mode(1)
     self.hide()
     self.face_ui.show()
 def run(self):
     """
     Runs the program
     """
     Prompt.welcome()
     file_path = Prompt.prompt_file_path()
     self.dictionary = Dictionary(file_path)
     will_continue = True
     while will_continue:
         user_input = self.prompt_word()
         definition = self.search(user_input)
         print(f"{definition}\n")
         will_save = Prompt.prompt_save()
         if will_save:
             FileHandler.write_lines(
                     "./data.txt", self.get_saved_key_pair())
             print("Saved Successfully")
예제 #12
0
 def key_clicked(self, number):
     self.save_password = self.save_password + str(number)
     self.show_passwd.setText(self.save_password)
     if len(self.save_password) == 6:
         if encryption(self.save_password) == ALApi.get_infor_data()[1]:
             Door.turn_on_door()
             self.hide()
             self.main.showFullScreen()
         else:
             Prompt("密码错误!", self).show()
         self.save_password = ""
         self.show_passwd.clear()
 def face_verify(self):
     known_face_encodings = [self.face_encoding]
     known_face_names = ["user"]
     process_this_frame = True
     ret, frame = Monitor.cap.read()
     small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
     rgb_small_frame = small_frame[:, :, ::-1]
     if process_this_frame:
         face_locations = face_recognition.face_locations(rgb_small_frame)
         face_encodings = face_recognition.face_encodings(
             rgb_small_frame, face_locations)
         for face_encoding in face_encodings:
             matches = face_recognition.compare_faces(known_face_encodings,
                                                      face_encoding,
                                                      tolerance=0.3)
             face_distances = face_recognition.face_distance(
                 known_face_encodings, face_encoding)
             best_match_index = np.argmin(face_distances)
             if matches[best_match_index]:
                 name = known_face_names[best_match_index]
                 if name == "user":
                     self.ui_prompt.setText("请保持不动!")
                     self.verify_num = self.verify_num + 1
             else:
                 self.ui_prompt.clear()
                 self.verify_num = 0
                 self.verify_count += 1
             if self.verify_count == 50:
                 Prompt("识别失败!", self).show()
                 self.verify_count = 0
                 self.error += 1
                 if self.error == 3:
                     self.error = 0
                     self.hide()
                     self.main.showFullScreen()
                     self.face_verify_timer.stop()
     frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
     image = QImage(frame.data, frame.shape[1], frame.shape[0],
                    QImage.Format_RGB888)
     self.video_label.setPixmap(
         QPixmap.fromImage(image).scaled(self.video_label.width(),
                                         self.video_label.height()))
     if self.verify_num == 10:
         self.verify_num = 0
         Door.turn_on_door()
         self.face_verify_timer.stop()
         self.hide()
         self.main.showFullScreen()
         self.ui_prompt.clear()
예제 #14
0
from prompt import Prompt
from candidate_program import CandidateProgram, JsonLogger
import sys

if __name__ == "__main__":
    instructions_json = JsonLogger()
    instructions = instructions_json.open_and_read()

    prompt = Prompt()
    json_location_string = 'installing all prorgams from {0}'.format(instructions_json.location)
    prompt.greet(add=json_location_string)
    prompt.write_to_prompt('here\'s the list of what I found:')
    prompt.write_separator()
    prompt.column_print(list(instructions.keys()))
    prompt.write_separator()
    if not prompt.ask_confirmation('would you like to procede?'):
        prompt.write_to_prompt('Ok, bye!')
        sys.exit(0)
    for program, install_instruction in instructions.items():
        candidate = CandidateProgram(**install_instruction)
        candidate.add_repo_ppa()
        candidate.add_repo_key()
        candidate.add_repo_deb()
        candidate.install(v=1)
        
 def prompt_word():
     """
     Calls the word method of the Prompt class
     :return: a string
     """
     return Prompt.word()
예제 #16
0
from manager_lxc_utils import (_change_container_key, _container_state,
                               _create_container, _delete_container,
                               _launch_container, _restart_container,
                               _start_container, _stop_container)
from prompt import Prompt
from utils import (ContainerState, _check_container_name, _check_login,
                   _check_password, _generate_container_name, _images_detail,
                   _owning_containers_name, gen_keys)

if __name__ == '__main__':
    current_path = os.path.split(os.path.abspath(__file__))[0]
    config = configparser.ConfigParser()
    config.read(os.path.join(current_path, 'config.ini'))
    ip_start = config['DEFAULT'].get('ip_start')
    port_start = config['DEFAULT'].getint('port_start')
    default_image_fingerprint = config['DEFAULT'].get(
        'default_image_fingerprint')
    db_path = config['DEFAULT'].get('db_path')
    lxc_nvidia_profile = config['DEFAULT'].get('lxc_image_profile')
    nobody = config['DEFAULT'].get('nobody', 'nobody')
    client = pylxd.Client()
    prompt = Prompt(db_path,
                    client,
                    port_start,
                    ip_start,
                    default_image_fingerprint,
                    profiles=[lxc_nvidia_profile, 'default'],
                    nobody=nobody)
    prompt.cmdloop()
    exit()
예제 #17
0
import sys
import shutil, errno
import argparse
from csv_logger import Csv_Logger
from prompt import Prompt
from config import Config
from ticket_helper import Ticket_Helper
from sys_logger import Sys_Logger

#global config
config = Config()  #config class to provide config.json file data
prompt = Prompt()
logger = Sys_Logger()


def prompt_handler(message):
    prompt_result = prompt.confirm(message)

    if prompt_result == True:
        return True
    logger.log_print("Aborting operation....")
    exit()


def main():
    logger.log(
        "=============================== UPDATE BEGIN ==============================="
    )

    parser = argparse.ArgumentParser()
    parser.add_argument(
예제 #18
0
from candidate_program import CandidateProgram
from prompt import Prompt
import sys


def exit_installer(prompt=None):
    if prompt:
        prompt.greet_off()
    sys.exit(0)


if __name__ == "__main__":

    prompt = Prompt()
    prompt.greet()
    candidate = CandidateProgram()
    #    candidate.update_sys_list()
    candidate.aka_name = prompt.ask_name()
    if candidate.lookup_name_in_current_repos(candidate.aka_name):
        success_text = 'found a program in your current repos called exactly {0}'.format(
            candidate.aka_name)
        ask_text = '\nDo you want me to install that one?'
        if prompt.ask_confirmation(success_text + ask_text):
            candidate.name_in_repo = candidate.aka_name
            candidate.install()
            candidate.dump_success()
            exit_installer(prompt)
    if prompt.ask_confirmation('Do you want to install one from this list? '):
        candidate.name_in_repo = prompt.ask_text('Which one? ')
        candidate.install()
        candidate.dump_success()