self.displayer.message(" %s" % s)
                    self.displayer.message(" %s: %s" % (str(record.exc_info[0]), str(record.exc_info[1])))

        def __init__(self):
            pass

        def run(self, scrwin, config):
            self.displayer = CursesDisplayer(scrwin)

            log_handler = LaunchManyApp.LogHandler(STDERR, self.displayer)
            log_handler.setFormatter(bt_log_fmt)
            logging.getLogger("").addHandler(log_handler)
            logging.getLogger().setLevel(STDERR)
            logging.getLogger("").removeHandler(console)

            # more liberal with logging launchmany-curses specific output.
            lmany_logger = logging.getLogger("launchmany-curses")
            lmany_handler = LaunchManyApp.LogHandler(INFO, self.displayer)
            lmany_handler.setFormatter(bt_log_fmt)
            lmany_logger.setLevel(INFO)
            lmany_logger.addHandler(lmany_handler)

            config = Preferences().initWithDict(config)
            LaunchMany(config, self.displayer.display, "launchmany-curses")

    app = LaunchManyApp()
    curses_wrapper(app.run, config)
    if exceptions:
        print _("\nEXCEPTION:")
        print exceptions[0]
            d.display(activity = 'shutting down')
            dow.shutdown()
            break

    except KeyboardInterrupt:
        # ^C to exit.. 
        pass 
    try:
        rawserver.shutdown()
    except:
        pass
    if not d.done:
        d.failed()


if __name__ == '__main__':
    if argv[1:] == ['--version']:
        print version
        exit(0)
    if len(argv) <= 1:
        print "Usage: btdownloadcurses.py <global options>\n"
        print get_usage(defaults)
        exit(1)

    errlist = []
    curses_wrapper(run, errlist, argv[1:])

    if errlist:
       print "These errors occurred during execution:"
       for error in errlist:
          print error
Ejemplo n.º 3
0
        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(sys.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)
            sys.exit(1)
        config, args = parseargs(sys.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 as e:
        print 'error: {}\nrun with no args for parameter explanations' \
            ''.format(e)
        sys.exit(1)

    curses_wrapper(LaunchManyWrapper, config)
    if Exceptions:
        print '\nEXCEPTION:'
        print Exceptions[0]
        print 'please report this to ' + report_email
        sys.exit(1)
    try:
        config, args = configfile.parse_configuration_and_args(defaults,
                                       uiname, sys.argv[1:], 0, 1)

        torrentfile = None
        if len(args):
            torrentfile = args[0]
        for opt in ('responsefile', 'url'):
            if config[opt]:
                print '"--%s"' % opt, _("deprecated, do not use")
                torrentfile = config[opt]
        if torrentfile is not None:
            metainfo, errors = GetTorrent.get(torrentfile)
            if errors:
                raise BTFailure(_("Error reading .torrent file: ") + '\n'.join(errors))
        else:
            raise BTFailure(_("you must specify a .torrent file"))
    except BTFailure, e:
        print str(e)
        sys.exit(1)

    errlist = []
    dl = DL(metainfo, config, errlist)
    curses_wrapper(dl.run)

    if errlist:
       print _("These errors occurred during execution:")
       for error in errlist:
          print error
Ejemplo n.º 5
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, config)
    if Exceptions:
        print '\nEXCEPTION:'
        print Exceptions[0]
        print 'please report this to '+report_email
Ejemplo n.º 6
0
                    self.displayer.message( " %s: %s" %
                        ( str(record.exc_info[0]),str(record.exc_info[1])))

        def __init__(self):
            pass

        def run(self,scrwin, config):
            self.displayer = CursesDisplayer(scrwin)

            log_handler = LaunchManyApp.LogHandler(STDERR, self.displayer)
            log_handler.setFormatter(bt_log_fmt)
            logging.getLogger('').addHandler(log_handler)
            logging.getLogger().setLevel(STDERR)
            logging.getLogger('').removeHandler(console)

            # more liberal with logging launchmany-curses specific output.
            lmany_logger = logging.getLogger('launchmany-curses')
            lmany_handler = LaunchManyApp.LogHandler(INFO, self.displayer)
            lmany_handler.setFormatter(bt_log_fmt)
            lmany_logger.setLevel(INFO)
            lmany_logger.addHandler(lmany_handler)

            config = Preferences().initWithDict(config)
            LaunchMany(config, self.displayer.display, 'launchmany-curses')

    app = LaunchManyApp()
    curses_wrapper(app.run, config)
    if exceptions:
        print _("\nEXCEPTION:")
        print exceptions[0]
Ejemplo n.º 7
0
            dow.shutdown()
            break

    except KeyboardInterrupt:
        # ^C to exit...
        pass
    try:
        rawserver.shutdown()
    except:
        pass
    if not d.done:
        d.failed()


if __name__ == '__main__':
    if sys.argv[1:] == ['--version']:
        print version
        sys.exit(0)
    if len(sys.argv) <= 1:
        print "Usage: btdownloadcurses.py <global options>\n"
        print get_usage(defaults)
        sys.exit(1)

    errlist = []
    curses_wrapper(run, errlist, sys.argv[1:])

    if errlist:
        print "These errors occurred during execution:"
        for error in errlist:
            print error
Ejemplo n.º 8
0
def curses_wraps(fn):
    """Decorator for curses_wrapper"""
    return lambda *args, **kwargs: curses_wrapper(fn, *args, **kwargs)
Ejemplo n.º 9
0
    try:
        config, args = configfile.parse_configuration_and_args(
            defaults, uiname, sys.argv[1:], 0, 1)

        torrentfile = None
        if len(args):
            torrentfile = args[0]
        for opt in ('responsefile', 'url'):
            if config[opt]:
                print '"--%s"' % opt, _("deprecated, do not use")
                torrentfile = config[opt]
        if torrentfile is not None:
            metainfo, errors = GetTorrent.get(torrentfile)
            if errors:
                raise BTFailure(
                    _("Error reading .torrent file: ") + '\n'.join(errors))
        else:
            raise BTFailure(_("you must specify a .torrent file"))
    except BTFailure, e:
        print str(e)
        sys.exit(1)

    errlist = []
    dl = DL(metainfo, config, errlist)
    curses_wrapper(dl.run)

    if errlist:
        print _("These errors occurred during execution:")
        for error in errlist:
            print error
Ejemplo n.º 10
0
def curses_wraps(fn):
	"""Decorator for curses_wrapper"""
	return lambda *args, **kwargs: curses_wrapper(fn, *args, **kwargs)