def _continue(self):
     # self.screen.ingrediants = self.screen.food.read_ingredients(self.screen.ingrediants)
     self.screen.recipes = self.screen.food.search_recipes_online(self.screen.ingrediants, self.screen.use_pantry, self.number_of_recipies)
     last_scene = self.screen._scenes[-1]
     self.screen._scenes = self.screen._scenes[:-1]
     self.screen._scenes += create_recipie_frames(self.screen)
     self.screen._scenes.append(last_scene)
     raise NextScene("recipe0")
Ejemplo n.º 2
0
 def _update(self, frame_no):
     self.update_called = True
     self._count -= 1
     if self._count <= 0:
         if self._stop:
             raise StopApplication("End of test")
         else:
             raise NextScene(self._next_scene)
Ejemplo n.º 3
0
 def _checkout_commit(self):
     try:
         self._model.checkout_commit()
         # self._open_commits_view()
     except GitCommandError as e:
         print(e)
         self._model.last_error = e
         raise NextScene("Error")
Ejemplo n.º 4
0
Archivo: views.py Proyecto: Eeems/ample
def open_view(name):
    if not hasattr(scenes, 'views'):
        return None

    if name not in scenes.views:
        raise ValueError('View %s does not exist' % (name))

    raise NextScene(name)
Ejemplo n.º 5
0
    def _on_select(self):
        if self._data_context.threads is None:
            return

        self.save()
        index = self._thread_list.value
        self._data_context.set_thread(self._threads[index])
        raise NextScene("Thread")
Ejemplo n.º 6
0
 def _cancel(self):
     global current_selected_value
     current_selected_value = 0
     current_selected_amount = 0
     current_selected_action = ""
     self.label._text = "{} module {} {}?"
     self.save()
     raise NextScene("dashboard")
Ejemplo n.º 7
0
 def _next(self):
     self.save()
     data.cursor.execute('delete from settings')
     data.cursor.execute("insert into settings values("
                         "'{consumer_key}','{consumer_secret}',"
                         "'{token}','{token_secret}')".format(**self.data))
     data.data.commit()
     raise NextScene("Subs")
Ejemplo n.º 8
0
 def __checkout(self):
     self.save()
     try:
         self._model.checkout_branch(self.data["branches"])
     except GitCommandError as e:
         self._model.last_error = e
         raise NextScene("Error")
     self._model.current_id = self.data["branches"]
     self._reload_list()
Ejemplo n.º 9
0
 def _login(self: Login) -> None:
     self.save()
     if not self.data['username'] or not self.data['password']:
         self._keyerror_handler()
     res = self._model.login(self.data['username'], self.data['password'])
     if self.data['username'] and self.data['password']:
         if res['result']:
             raise NextScene("ChatsList")
         self._user_not_found_handler(res['msg'])
Ejemplo n.º 10
0
 def _start_chat(self: StartChatView) -> None:
     self.save()
     if not self.data['username']:
         self._keyerror_handler()
     print(self.data['username'])
     res = self._model.start_chat(self.data['username'])
     if res['result']:
         raise NextScene("ChatsList")
     self._user_not_found_handler(res['msg'])
Ejemplo n.º 11
0
    def process_event(self, event):
        if isinstance(event, KeyboardEvent):
            key = event.key_code
            if key == ord('s') or key == 32:
                self._add()
            elif key == ord('e'):
                self._match_split()
            elif key == ord('x'):
                self._export()
            elif key == ord('m') or key == -2:
                raise NextScene("Main Menu")
            elif key == -3:
                raise NextScene("CategorySelect")

            else:
                super(SplitListView, self).process_event(event)
        else:
            super(SplitListView, self).process_event(event)
Ejemplo n.º 12
0
 def _registration(self: RegistrationView) -> None:
     self.save()
     if not self.data['username'] or not self.data['password']:
         self._keyerror_handler()
     res = self._model.register(self.data['username'], self.data['password'])
     if self.data['username'] and self.data['password']:
         if res['result']:
             raise NextScene("ChatsList")
         self._registration_error_handler(res['msg'])
Ejemplo n.º 13
0
    def _login(self):
        username = self._text_name.value
        pwd = self._text_pwd.value
        _my, err = Game.Login(username, pwd)
        if err is not None:
            self._scene.add_effect(
                PopUpDialog(self._screen, err.__str__(), ["OK"]))
            return

        raise NextScene("Game")
Ejemplo n.º 14
0
 def _send(self):
     self.save()
     pow = self.data['pow']
     if not pow.isdigit():
         pow = None
     else:
         pow = int(pow)
     send.sendemail(USER, self.data['recip'], '', self.data['subject'],
                    self.data['body'], pow, SMTP_EP, USER, PASS)
     raise NextScene("Main")
Ejemplo n.º 15
0
 def _confirm(self):
     self.save()
     if not self._validate():
         return
     uuid = self._model.current_machine
     for command in self.data["commands"]:
         # check for empty string
         if command:
             self._model.queue_command(self.data["cmdtype"], uuid, command)
     raise NextScene("View Host")
Ejemplo n.º 16
0
    def process_event(self, event):
        # Do the key handling for this Frame.
        if isinstance(event, KeyboardEvent):
            if event.key_code in [ord('|'), Screen.ctrl("c")]:
                raise StopApplication("User quit")
            if event.key_code in [ord('p'), ord('P')]:
                raise NextScene("Players")

        # Now pass on to lower levels for normal handling of the event.
        return super(JeopardyFrame, self).process_event(event)
Ejemplo n.º 17
0
    def _register(self):
        username = self._text_name.value
        nickname = self._text_nickname.value
        pwd = self._text_pwd.value
        gender = self._radio_gender.value
        err = Game.Register(username, nickname, pwd, gender)
        if err is not None:
            self._scene.add_effect(
                PopUpDialog(self._screen, err.__str__(), ["OK"]))
            return

        raise NextScene('Main')
Ejemplo n.º 18
0
    def _show_image(self, cmd: str):
        if cmd.isdecimal():
            idx = int(cmd)

            if self._data_context.links is not None and len(
                    self._data_context.links) > idx:
                link = self._data_context.links[idx]

                if re.match(r'.*\.(jpg|png|jpeg|gif)', link) is not None:
                    self._data_context.set_image(link)
                    self._save_history()
                    raise NextScene("Image")
Ejemplo n.º 19
0
    def process_event(self, event):
        if isinstance(event, KeyboardEvent):
            if len(self._options) > 0 and event.key_code == Screen.KEY_UP:
                # Move up one line in text - use value to trigger on_select.
                self._line = max(0, self._line - 1)
                self._line = min(self._line, len(self._options)-1) #If we move a line cursor from a line that has dissapear
                self.value = self._options[self._line][1]

            elif len(self._options) > 0 and event.key_code == Screen.KEY_DOWN:
                # Move down one line in text - use value to trigger on_select.
                self._line = min(len(self._options) - 1, self._line + 1)
                self.value = self._options[self._line][1]

            elif len(self._options) > 0 and event.key_code in [ord(' '), ord('\n')] :
                global current_selected_value, current_selected_queue
                if self.queue_name == "logs":
                    return event
                current_selected_value = self.value
                current_selected_queue = self.queue_name
                self._frame.save()
                raise NextScene("action_choice")

            # Quit if press q
            elif event.key_code == ord('q'):
                Dashboard._quit()

            else:
                # Ignore any other key press.
                return event

        elif isinstance(event, MouseEvent):
            # Mouse event - rebase coordinates to Frame context.
            new_event = self._frame.rebase_event(event)
            if event.buttons != 0:
                if (len(self._options) > 0 and
                        self.is_mouse_over(new_event, include_label=False)):
                    # Use property to trigger events.
                    self._line = min(new_event.y - self._y,
                                     len(self._options) - 1)
                    self.value = self._options[self._line][1]
                    # If clicked on button <k>, kill the queue
                    if self._x+2 <= new_event.x < self._x+4:
                        if self.queue_name in ["running", "idle"]:
                            kill_module(PID_NAME_DICO[int(self.value)], self.value)
                        else:
                            restart_module(self.value)

                    return
            # Ignore other mouse events.
            return event
        else:
            # Ignore other events
            return event
Ejemplo n.º 20
0
 def _start(self):
     global current_selected_action, current_selected_amount
     current_selected_action = "START"
     try:
         count = int(self.textEdit.value)
         count = count if count < 20 else 1
     except Exception:
         count = 1
     current_selected_amount = count
     self.label._text = "Choose action on module {} {}"
     self.save()
     raise NextScene("confirm")
Ejemplo n.º 21
0
    def process_event(self, event):
        if isinstance(event, KeyboardEvent):
            if self.__scene_keybinds:
                for keybind, scene in self.__scene_keybinds.items():
                    if event.key_code in [
                            ord(keybind.lower()),
                            ord(keybind.upper())
                    ]:
                        raise NextScene(scene)
            if event.key_code in [ord('q'), ord('Q'), Screen.ctrl("c")]:
                raise StopApplication("User quit")

        return super(GraphFrame, self).process_event(event)
Ejemplo n.º 22
0
    def process_event(self, event):
        if isinstance(event, KeyboardEvent):
            if event.key_code == KEY_BINDINGS["global"]["help"].value:
                self._scene.add_effect(Help(self.screen))
                return None
            elif event.key_code == self._keybindings["num_sort"].value:
                self._data_context.sort_threads("number")
                return None
            elif event.key_code == self._keybindings["num_des_sort"].value:
                self._data_context.sort_threads("number", True)
                return None
            elif event.key_code == self._keybindings["title_sort"].value:
                self._data_context.sort_threads("title")
                return None
            elif event.key_code == self._keybindings["title_des_sort"].value:
                self._data_context.sort_threads("title", True)
                return None
            elif event.key_code == self._keybindings["count_sort"].value:
                self._data_context.sort_threads("count")
                return None
            elif event.key_code == self._keybindings["count_des_sort"].value:
                self._data_context.sort_threads("count", True)
                return None
            elif event.key_code == self._keybindings["active_sort"].value:
                self._data_context.switch_active_sort()
                return None
            elif event.key_code == self._keybindings["speed_sort"].value:
                self._data_context.sort_threads("speed")
                return None
            elif event.key_code == self._keybindings["speed_des_sort"].value:
                self._data_context.sort_threads("speed", True)
                return None
            elif event.key_code == self._keybindings["find"].value:
                self._scene.add_effect(
                    CommandLine(self._screen, "find:", self._find))
                return None
            elif event.key_code == self._keybindings["ng_title"].value:
                self._scene.add_effect(
                    CommandLine(self._screen, "ng:", self._open_ngcreator))
                return None
            elif event.key_code == self._keybindings["update"].value:
                self._data_context.update()
                return None
            elif event.key_code == self._keybindings["back"].value:
                raise NextScene("Bbsmenu")
                return None
            elif event.key_code == self._keybindings["favorite"].value:
                self._data_context.favorite()
                return None

        return super().process_event(event)
Ejemplo n.º 23
0
 def _apply(self):
     self.save()
     if self.data["what"]:
         if (self._model._valid_string_check(self.data["what"])
                 and self._model._valid_string_check(self.data["notes"])):
             if self._model.update_current_todo(self.data):
                 raise NextScene("Main")
             else:
                 self._scene.add_effect(
                     PopUpDialog(self._screen, "It already exists!",
                                 ["OK"]))
     else:
         self._scene.add_effect(
             PopUpDialog(self._screen, "Please enter what to do!", ["OK"]))
Ejemplo n.º 24
0
 def _view_host(self):
     self.save()
     # This saves the row that was clicked
     id = self.data["machines"]
     if id is None:
         # TODO: some weird error if entering when all fields are none
         return
     # Get the widget managed by asciimatics
     widget = self._details_layout.find_widget("machines")
     # Get the option displayed on the menu in the MutliColumnListBox
     options = widget.options[id]
     # Unpack the data into a more usable struct
     machine = ClientInfo(*options[0])
     # Select the machine
     self.model.select_current(machine.uuid)
     raise NextScene("View Host")
Ejemplo n.º 25
0
    def _ok(self):
        global current_selected_value, current_selected_queue, current_selected_action, current_selected_amount
        if current_selected_action == "KILL":
            kill_module(PID_NAME_DICO[int(current_selected_value)], current_selected_value)
        else:
            count = int(current_selected_amount) #Number of queue to start
            if current_selected_queue in ["running", "idle"]:
                restart_module(PID_NAME_DICO[int(current_selected_value)], count)
            else:
                restart_module(current_selected_value, count)

        current_selected_value = 0
        current_selected_amount = 0
        current_selected_action = ""
        self.label._text = "{} module {} {}?"
        self.save()
        raise NextScene("dashboard")
Ejemplo n.º 26
0
 def _instrument_select(self):
     if self.instrument_list_box.value == 0:
         raise NextScene("Altaz")
     if self.instrument_list_box.value == 1:
         raise NextScene("Birger")
     if self.instrument_list_box.value == 2:
         raise NextScene("Filter Wheel")
     if self.instrument_list_box.value == 3:
         raise NextScene("Keithley")
     if self.instrument_list_box.value == 4:
         raise NextScene("Laser")
     if self.instrument_list_box.value == 9:
         raise NextScene("Shutter")
Ejemplo n.º 27
0
    def _ok(self):
        self.save()

        # Check if the current configuration is valid
        if len(self.slave_channels.options) < 1:
            self.show_popup(_("You must enable at least one slave channel."))
            return

        options = list(map(repr, self.slave_channels.options))
        if len(options) != len(set(options)):
            self.show_popup(_("Duplicate instances detected in slave channel settings. "
                              "Each module-instance pair must be unique."))
            return

        options = list(map(repr, self.middlewares.options))
        if len(options) != len(set(options)):
            self.show_popup(_("Duplicate instances detected in middleware settings. "
                              "Each module-instance pair must be unique."))
            return

        self._model.save_config()
        raise NextScene("ModulesSetup")
Ejemplo n.º 28
0
    def _ok_fn(self, gas_price_wei, nonce=None):
        try:
            self.dapp.rx = self.dapp.node.push(
                self._tx_fn, 
                gas_price_wei, 
                self.estimated_gas, 
                value=self.dapp.node.w3.toWei(Decimal(self.tx_value), 'ether'),
                nonce=nonce
            )
        except ValueError as e:
            logging.info("Error creating tx: {}".format(e))
            self.dapp.add_message_dialog("{}".format(e.args[0]['message']), destroy_window=self)
            return
        except (SignTxError) as e:
            logging.info("SignTxError: {}".format(e))
            self.dapp.add_message_dialog("Credstick did not sign Transaction", destroy_window=self)
            return
        except (OSError):
            self.dapp.add_message_dialog("Your credstick generated an error.", destroy_window=self)
            return

        #self.dapp.add_sl_frame(AskClipboardFrame(self.dapp, 3, 65, title="Tx Submitted.  Copy TxHash to clipboard?"))
        self._destroy_window_stack()
        raise NextScene(self._scene.name)
Ejemplo n.º 29
0
 def _showpaste(self):
     self.label._text = "Choose action on module {} {}"
     self.save()
     raise NextScene("show_paste")
Ejemplo n.º 30
0
 def _cancel(self):
     global current_selected_value
     current_selected_value = 0
     self.label._text = "Choose action on module {} {}"
     self.save()
     raise NextScene("dashboard")