예제 #1
0
파일: fcli.py 프로젝트: XCage15/fcli
    def __init__(self):
        # Initialise curses screen
        self.stdscr = curses.initscr()
        # Disable echo of characters
        curses.noecho()
        # Remove need to press enter before reacting to key press
        curses.cbreak()
        # Process special characters
        self.stdscr.keypad(1)

        # Ensure terminal is cleaned up if program crashes in main_loop
        curses_wrapper(self.main_loop)
예제 #2
0
    # color
    curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
    # non-blocking on input
    stdscr.nodelay(1)
    # allow function keys to be interpreted as a single value
    stdscr.keypad(1)

    # draw banner
    draw_banner(stdscr)

    # game start
    state = init_state()
    curses.curs_set(1)

    # main game loop
    while not is_game_over(stdscr, state):
        now = time.time()
        draw(stdscr, state, now)
        curses.napms(100)
        key = stdscr.getch()
        state = update_state(stdscr, state, key)

    draw_game_over(stdscr, state, now)


if __name__ == '__main__':
    logging.basicConfig(filename='tictactoe.log',
                        level=logging.DEBUG,
                        format='%(asctime)s %(message)s')
    curses_wrapper(game_loop)
예제 #3
0
    ] )
    try:
        configdir = ConfigDir('launchmanycurses')
        defaultsToIgnore = ['responsefile', 'url', 'priority']
        configdir.setDefaults(defaults,defaultsToIgnore)
        configdefaults = configdir.loadConfig()
        defaults.append(('save_options',0,
         "whether to save the current options as the new default configuration " +
         "(only for btlaunchmanycurses.py)"))
        if len(argv) < 2:
            print "Usage: btlaunchmanycurses.py <directory> <global options>\n"
            print "<directory> - directory to look for .torrent files (semi-recursive)"
            print get_usage(defaults, 80, configdefaults)
            exit(1)
        config, args = parseargs(argv[1:], defaults, 1, 1, configdefaults)
        if config['save_options']:
            configdir.saveConfig(config)
        configdir.deleteOldCacheData(config['expire_cache_data'])
        if not os.path.isdir(args[0]):
            raise ValueError("Warning: "+args[0]+" is not a directory")
        config['torrent_dir'] = args[0]
    except ValueError, e:
        print 'error: ' + str(e) + '\nrun with no args for parameter explanations'
        exit(1)

    curses_wrapper(LaunchManyWrapper, configdir, config)
    if Exceptions:
        print '\nEXCEPTION:'
        print Exceptions[0]
        print 'please report this to '+report_email