Exemplo n.º 1
0
from BitTorrent.IPC import ipc_interface
from BitTorrent.prefs import Preferences
from BitTorrent.RawServer_twisted import RawServer
if os.name == 'nt':
    from BitTorrent.platform import win_version_num
from BitTorrent import zurllib

defaults = get_defaults('bittorrent')
defaults.extend((('donated' , '', ''), # the version that the user last donated for
                 ('notified', '', ''), # the version that the user was last notified of
                 ))

defconfig = dict([(name, value) for (name, value, doc) in defaults])
del name, value, doc

inject_main_logfile()
global_logger = logging.getLogger('')
rawserver = None

if __name__ == '__main__':

    psyco = None
    try:
        # 95, 98, and ME seem to have problems with psyco
        # so only import it on NT and up
        # and only if we're not using python 2.5, becuase it's broken
        if (os.name == 'nt' and win_version_num >= (2, 4, 0) and
            sys.version_info < (2, 5)):
            import psyco_BROKEN
            import traceback
            psyco.cannotcompile(traceback.print_stack)
Exemplo n.º 2
0
                            _(" is not a directory"))

        # the default behavior is to save_in files to the platform
        # get_save_dir.  For launchmany, if no command-line argument
        # changed the save directory then use the torrent directory.
        if config['save_in'] == platform.get_save_dir():
            config['save_in'] = config['torrent_dir']

    except BTFailure, e:
        print _("error: ") + unicode(e.args[0]) + \
              _("\nrun with no args for parameter explanations")
        sys.exit(1)
    except KeyboardInterrupt:
        sys.exit(1)

    inject_main_logfile()

    class LaunchManyApp(object):
        class LogHandler(logging.Handler):
            def __init__(self, level, displayer):
                logging.Handler.__init__(self,level)
                self.displayer = displayer
            def emit(self, record):
                if len(record.getMessage()) > 0:
                    self.displayer.message(record.getMessage() )
                if record.exc_info is not None:
                    self.displayer.message(
                        "Traceback (most recent call last):" )
                    tb = record.exc_info[2]
                    stack = traceback.extract_tb(tb)
                    l = traceback.format_list(stack)