コード例 #1
0
ファイル: ui.py プロジェクト: alefnula/samovar
 def ask(self, message=None, password=False, strip=True):
     message = message or ''
     if password:
         value = getpass.getpass(message)
     else:
         value = input(message)
     return value.strip() if strip else value
コード例 #2
0
ファイル: sv.py プロジェクト: rubyengineer/samovar
        readline.set_completer(completer)
    except:
        pass


if __name__ == "__main__":
    if len(sys.argv) > 1:
        from samovar.main import main

        sys.exit(main(sys.argv))
    else:
        try:
            while True:
                import subprocess

                setup_readline()
                command = input("> ").strip()
                if command in ("exit", "quite"):
                    break
                if command != "":
                    timeit = False
                    if command.startswith("timeit "):
                        command = command.replace("timeit ", "", 1)
                        timeit = True
                    start_time = get_time()
                    subprocess.call([sys.executable, os.path.abspath(__file__)] + shutil.split(command), shell=False)
                    if timeit:
                        print("Duration: %.4fs", get_time() - start_time)
        except KeyboardInterrupt:
            print()
コード例 #3
0
ファイル: sv.py プロジェクト: alefnula/samovar
        readline.rl.read_inputrc(os.path.join(os.path.dirname(__file__), 'svreadline.ini'))
        readline.parse_and_bind('tab: complete')
        readline.set_completer(completer)
    except:
        pass


if __name__ == '__main__':
    if len(sys.argv) > 1:
        from samovar.main import main
        sys.exit(main(sys.argv))
    else:
        try:
            while True:
                import subprocess
                setup_readline()
                command = input('> ').strip()
                if command in ('exit', 'quite'):
                    break
                if command != '':
                    timeit = False
                    if command.startswith('timeit '):
                        command = command.replace('timeit ', '', 1)
                        timeit = True
                    start_time = get_time()
                    subprocess.call([sys.executable, os.path.abspath(__file__)] + shell.split(command), shell=False)
                    if timeit:
                        print('Duration: %.4fs', get_time() - start_time)
        except KeyboardInterrupt:
            print()
コード例 #4
0
        readline.rl.read_inputrc(os.path.join(os.path.dirname(__file__), 'svreadline.ini'))
        readline.parse_and_bind('tab: complete')
        readline.set_completer(completer)
    except:
        pass


if __name__ == '__main__':
    if len(sys.argv) > 1:
        from samovar.main import main
        sys.exit(main(sys.argv))
    else:
        try:
            while True:
                import subprocess
                setup_readline()
                command = input('> ').strip()
                if command in ('exit', 'quite'):
                    break
                if command != '':
                    timeit = False
                    if command.startswith('timeit '):
                        command = command.replace('timeit ', '', 1)
                        timeit = True
                    start_time = get_time()
                    subprocess.call([sys.executable, os.path.abspath(__file__)] + shutil.split(command), shell=False)
                    if timeit:
                        print('Duration: %.4fs', get_time() - start_time)
        except KeyboardInterrupt:
            print()