コード例 #1
0
ファイル: mnemonic.py プロジェクト: technwallet/techn-core
    async def edit_loop(self):
        timeout = loop.sleep(1000 * 1000 * 1)
        touch = loop.wait(io.TOUCH)
        wait_timeout = loop.spawn(touch, timeout)
        wait_touch = loop.spawn(touch)
        content = None

        self.back.taint()
        self.input.taint()

        while content is None:
            self.render()
            if self.pbutton is not None:
                wait = wait_timeout
            else:
                wait = wait_touch
            result = await wait
            if touch in wait.finished:
                event, *pos = result
                content = self.touch(event, pos)
            else:
                if self.input.word:
                    # just reset the pending state
                    self.edit(self.input.content)
                else:
                    # invalid character, backspace it
                    self.edit(self.input.content[:-1])
        return content
コード例 #2
0
ファイル: __init__.py プロジェクト: zhaojun-sh/trezor-core
 def wait(self, *tasks):
     '''
     Wait until one of the passed tasks finishes, and return the result,
     while servicing the wire context.  If a message comes until one of the
     tasks ends, `UnexpectedMessageError` is raised.
     '''
     return loop.spawn(self.read(()), *tasks)
コード例 #3
0
ファイル: __init__.py プロジェクト: proteanx/trezor-firmware
 def wait(self, *tasks: Awaitable) -> Any:
     """
     Wait until one of the passed tasks finishes, and return the result,
     while servicing the wire context.  If a message comes until one of the
     tasks ends, `UnexpectedMessageError` is raised.
     """
     return loop.spawn(self.read(None), *tasks)
コード例 #4
0
ファイル: passphrase.py プロジェクト: zhaojun-sh/trezor-core
 async def __iter__(self):
     self.edit(self.input.content)  # init button state
     while True:
         change = self.change_page()
         enter = self.enter_text()
         wait = loop.spawn(change, enter)
         result = await wait
         if enter in wait.finished:
             return result
コード例 #5
0
    async def handle_input(self):
        touch = loop.wait(io.TOUCH)
        timeout = loop.sleep(1000 * 1000 * 1)
        spawn_touch = loop.spawn(touch)
        spawn_timeout = loop.spawn(touch, timeout)

        while True:
            if self.pending_button is not None:
                spawn = spawn_timeout
            else:
                spawn = spawn_touch
            result = await spawn

            if touch in spawn.finished:
                event, x, y = result
                self.dispatch(event, x, y)
            else:
                self.on_timeout()
コード例 #6
0
ファイル: workflow.py プロジェクト: mcudev/trezor-firmware
def spawn(workflow: loop.Task) -> loop.spawn:
    """Spawn a workflow task.

    Creates an instance of loop.spawn for the workflow and registers it into the
    workflow management system.
    """
    task = loop.spawn(workflow)
    _on_start(task)
    task.set_finalizer(_on_close)
    return task
コード例 #7
0
async def paginate(render_page, page_count, page=0, *args):
    while True:
        changer = change_page(page, page_count)
        renderer = render_page(page, page_count, *args)
        waiter = loop.spawn(changer, renderer)
        result = await waiter
        if changer in waiter.finished:
            page = result
        else:
            return result
コード例 #8
0
ファイル: passphrase.py プロジェクト: zhaojun-sh/trezor-core
 async def enter_text(self):
     timeout = loop.sleep(1000 * 1000 * 1)
     touch = loop.wait(io.TOUCH)
     wait_timeout = loop.spawn(touch, timeout)
     wait_touch = loop.spawn(touch)
     content = None
     while content is None:
         self.render()
         if self.pbutton is not None:
             wait = wait_timeout
         else:
             wait = wait_touch
         result = await wait
         if touch in wait.finished:
             event, *pos = result
             content = self.touch(event, pos)
         else:
             # disable the pending buttons
             self.edit(self.input.content)
     return content
コード例 #9
0
ファイル: workflow.py プロジェクト: mcudev/trezor-firmware
def start_default() -> None:
    """Start a default workflow.

    Use `set_default` to set the default workflow constructor.
    If a default task is already running, nothing will happen.
    """
    global default_task
    global default_constructor

    assert default_constructor is not None

    if not default_task:
        default_task = loop.spawn(default_constructor())
        if __debug__:
            log.debug(__name__, "start default: %s", default_task.task)
        default_task.set_finalizer(_finalize_default)
    else:
        if __debug__:
            log.debug(__name__, "default already started")