コード例 #1
0
    def do_action(self, cmd):
        if not cmd or cmd not in ['YES', 'NO']:
            texture.tprint('Is this correct? (YES / NO)')
            return texture.dotick

        if cmd == 'YES':
            # Update file
            self.state['current_file'] = self.state.get('new_file', '')
            self.state['new_file'] = ''

            return texture.loader(six.u('main'))

        # Ask for file again
        return texture.loader(six.u('loader'))
コード例 #2
0
ファイル: start.py プロジェクト: rmed/fyd
    def do_action(self, cmd):
        if cmd != 'START':
            texture.tprint(START)
            return texture.dotick

        # Load main dialog
        return texture.loader(six.u('main'))
コード例 #3
0
    def do_action(self, cmd):
        if not cmd:
            texture.tprint('Write the full path to the file to use')
            return texture.dotick

        self.state['new_file'] = cmd
        return texture.loader(six.u('loader_confirm'))
コード例 #4
0
    def do_action(self, cmd):
        # Need a file to work with
        if not self.state.get('current_file', ''):
            texture.tprint('No file specified, set one using the LOAD command')
            return texture.loader(six.u('main'))


        if cmd == 'START':
            texture.tprint('Preparing to copy')

            file_path = self.state['current_file']

            # File must exist
            if not os.path.isfile(file_path):
                texture.tprint('File does not exist, cancelling...')
                return texture.loader(six.u('main'))

            # Countdown
            for i in reversed(range(10)):
                texture.tprint(str(i))
                time.sleep(1)

            # Write file
            texture.tnewline()
            texture.tprint('Copying...')
            keyboard = PyKeyboard()

            with open(file_path, 'r') as f:
                for line in f:
                    # Mind newline
                    keyboard.type_string(line.rstrip('\n'))
                    keyboard.tap_key(keyboard.enter_key)

            texture.tprint('Done!')
            return texture.loader(six.u('main'))

        texture.tprint('Write START to copy or CANCEL to go back')
コード例 #5
0
ファイル: main.py プロジェクト: rmed/fyd
    def do_action(self, cmd):
        if cmd == 'LOAD':
            return texture.loader(six.u('loader'))

        elif cmd == 'COPY':
            return texture.loader(six.u('copyist'))
コード例 #6
0
def cancel(state):
    """Cancel current operation and return to main dialog."""
    return texture.loader(six.u('main'))