Esempio n. 1
0
    def no_hat_check():
        global NOHAT
        global ONEMU
        NOHAT = yesno(
            "No SenseHAT detected",
            "No SenseHat detected - Do you want to carry on anyway?")
        if NOHAT:
            if "arm" in os.uname().machine:
                ONEMU = yesno(
                    "Looks like a Pi",
                    "Do you want to try to run in the SenseHat emulator?")
                if ONEMU:
                    if not os.path.isfile("/usr/bin/sense_emu_gui"):
                        warn(
                            "Sorry",
                            "It doesn't look like the SenseHAT emulator is installed"
                        )
                        sys.exit()
            else:
                warn(
                    "No pi!",
                    "It doesn't look like the you're on a Raspberry Pi. You can still save animations and images."
                )

        else:
            sys.exit()
Esempio n. 2
0
    def check_bust(self):
        global stop

        # Check if house has went over 21 or 17
        if self.get_score() > 21:
            stop = True
            retry = yesno("House has went over 21!", "House has exceeded 21. You won! Would you like to play again?")
            if retry == True:
                resetGame()
            else:
                sys.exit("Thank you for playing!")

        elif self.get_score() > 17:
            stop = True
            if player.get_score() == self.get_score():
                retry = yesno("Tie!", "You and house have the same score. It is a tie! Would you like to play again?")
                if retry == True:
                    resetGame()
                else:
                    sys.exit("Thank you for playing!")

            if player.get_score() > self.get_score():
                retry = yesno("You win!", "You have a higher score than house. You win! Would you like to play again?")
                if retry == True:
                    resetGame()
                else:
                    sys.exit("Thank you for playing!")

            else:
                retry = yesno("You lose!", "House has a higher score than you. You lose! Would you like to play again?")
                if retry == True:
                    resetGame()
                else:
                    sys.exit("Thank you for playing!")
Esempio n. 3
0
def burn():
    """ Starts the buring process after getting confirmation
        from the user, first by umounting any partitions
        then launching dd_run as a seperate thread to avoid blocking the gui (and
        thereby preventing status updates from being shown)
    """

    global to_be_burned
    button_start.disable()
    instructions.disable()
    image_selecter.disable()
    help_button.disable()
    button_burn.disable()
    button_abort.enable()
    print("unmounting SD card")
    if not TEST_MODE:
        subprocess.Popen("sudo umount /dev/sda2", shell=True)
        subprocess.Popen("sudo umount /dev/sda1", shell=True)
    go_ahead = yesno(
        "Warning!",
        "This will erase everything on the SD card - are you sure?")
    if go_ahead == True:
        logger.info("Starting burn " + to_be_burned)
        t = threading.Thread(target=dd_run)
        t.start()

    else:
        logger.info("Chicken")
        button_start.enable()
Esempio n. 4
0
def wrap_button2():
    html_file = common.XMLToHTML(common.intenseScan('10.218.2.42'))
    webbrowser.open_new_tab('file://' + os.path.abspath(html_file))
    time.sleep(5)
    if not yesno("Keep HTML?",
                 "Do you want to save the HTML file for this scan?"):
        os.remove(html_file)
 def _reset_ip_list(self):
     """ Reset main window IP's to default. """
     default_config = app_config.CreateDefaultConfigSettings()
     if guizero.yesno(
             "Reset IP List to Default",
             "Are you sure you want to reset the IP list to Defaults?"):
         self.current_config.ip_list = default_config.ip_list
         self._set_ip_list()
Esempio n. 6
0
 def check_bust(self):
     # Check if player has gone over 21
     if self.get_score() > 21:
         retry = yesno("Over 21!", "You have exceeded 21. You have lost! Would you like to play again?")
         if retry == True:
             resetGame()
         else:
             sys.exit("Thank you for playing!")
def clear_FDB():
    clearDB = yesno("HEY!!!", "Are you sure?")
    if clearDB == True:
        clear()
        info("HEY!!", "Operation was successful")
    else:
        info("NOTE!!", "Going back to main window ")
        delete_menu_window.hide()
        app.show()
Esempio n. 8
0
def closeCutting():
    global currentTooth

    reallySure = yesno("Question", "Do you really want to finish cutting?")
    #only close if sure!
    if reallySure == True:
        cuttingWindow.hide()
        currentTooth = 1
        lblCurrentTooth.value = currentTooth
        GPIO.output(enablePin, GPIO.LOW)
Esempio n. 9
0
def run_program(tlength):

    runagain = True
    readings_okay = False
    voltavg = []
    mlvol = []

    while runagain:
        mlvol.append(int(input('How many ml do you have? ')))
        while not readings_okay:
            data = getdata(mlvol, tlength, dev)
            readings_okay = yesno("Reading check.",
                                  "Are you happy with the reading?")
        voltavg.append(data)
        readings_okay = False
        runagain = yesno("Run again check.",
                         "Would you like to run another trial?")
        plt.clf()

    plot_final(mlvol, voltavg)
Esempio n. 10
0
def delete_student():
    '''This function deletes the selected student.'''
    if student_listbox.value == None:
        delete_lbl.value = "No student selected"
        error("ERROR!", "No student selected.")
    else:
        #check if they really want to delete the student
        check_delete = yesno("ALERT",
                             "Are you sure you want to delete this student?")
        if check_delete == True:
            #get the index of the student we are deleting
            i = student_name.index(student_listbox.value)
            #delete from both the student_list and the student_list lists
            del (student_names[i])
            del (student_list[i])
Esempio n. 11
0
 def import_python():
     global framerate
     global current_frame_number
     current_frame_number = 1
     filename = filedialog.askopenfilename(initialdir=HOME,
                                           title="Select file",
                                           filetypes=(("python files",
                                                       "*.py"),
                                                      ("all files", "*.*")))
     if len(filename) != 0:
         with open(filename, "r") as import_file:
             line1 = import_file.readline()
             if line1 == "# m8tricks output file \n":
                 #print("This looks like an 8x8 Grid Editor file")
                 try:
                     for line in import_file:
                         if line.startswith("sh.set_pixels"):
                             grid = line[14:-2]
                             frames[
                                 current_frame_number] = ast.literal_eval(
                                     grid)
                             current_frame_number += 1
                     current_frame_number -= 1
                     load_frame()
                 except:
                     error("Import failed",
                           "Sorry, that file could not be imported")
             else:
                 not_our_file = yesno(
                     "Uh-oh",
                     "This doesn't look like a m8tricks file. Carry on trying to import it?"
                 )
                 if not_our_file == True:
                     try:
                         for line in import_file:
                             if line.startswith("sh.set_pixels"):
                                 grid = line[14:-2]
                                 frames[
                                     current_frame_number] = ast.literal_eval(
                                         grid)
                                 current_frame_number += 1
                         current_frame_number -= 1
                         load_frame()
                     except:
                         error("Import failed",
                               "Sorry, that file could not be imported")
Esempio n. 12
0
def main_program(dev):

    if not dev:
        whitelight = LED(21)
        whitelight.on()

    app = App(title="Chemistry Outreach Project v1.1")
    lighton = yesno("Initialisation check.", "Is the LED lit?")
    if not lighton:
        error("Initialisation error.",
              "Please check the connections and run the program again.")
        quit()
    app.destroy()

    tlength = int(
        input('How long would you like to run the simulations for (s)? '))
    run_program(tlength)

    if not dev:
        whitelight.off()
Esempio n. 13
0
def delete_student():
    ''' Deleting a selected student '''

    if student_listbox.value == None:
        delete_lbl.text_color = (230, 50, 10)
        delete_lbl.value = "Please select a student to delete"
        # error pop up message
        error("ERROR!:", "Please select a student to delete")
    else:
        # check if they really want to delete the selected student using a yes or no popup
        check_delete = yesno("ALERT!",
                             "Are you sure you want to delete this student?")
        if check_delete == True:
            # Get the index of the sutdent we are deleting (position in student_names)
            i = student_names.index(student_listbox.value)
            # delete the objects from student names and student list
            del (student_names[i])
            del (student_list[i])
            delete_lbl.text_color = (210, 45, 17)
            delete_lbl.value = "Student has been deleted"
            search()
Esempio n. 14
0
def abort():
    """ Kills a running dd process after offering a warning
        Reads the global pid variable and then finds the child processes
        (which get created because we run with sudo). Then kills them all
    """
    global pid
    check_abort = yesno(
        "Warning!",
        "Stopping this process may leave your SD card in an unusable state. Are you sure you want to stop burning your SD card?"
    )
    if check_abort:
        parent = psutil.Process(pid)
        for child in parent.children(recursive=True):
            k = subprocess.Popen(["sudo", "kill", "-9", str(child.pid)])
        k = subprocess.Popen(["sudo", "kill", "-9", str(pid)])
        button_start.enable()
        button_burn.disable()
        text_start.enable()
        button_abort.disable()
        help_button.enable()
        progress.value = ""
        status.set_all("black")
        logger.info("Burn aborted")