Ejemplo n.º 1
0
def main(useHelper=False):
	defaults = get_defaults('bittorrent-console')
	config, args = configfile.parse_configuration_and_args(defaults, 'iTorrent',
		sys.argv[1:], 0, 0)
	config = Preferences().initWithDict(config)
	config['tracker_proxy'] = config['http_proxy']
	display = Display()
	btControl = BTControl(config, display)
	os.chdir(config['data_dir'])
	prefix = 'http://localhost'
	if config['control_port'] != 80:
		prefix += ':%d' % config['control_port']
	prefix += '/'

	# TODO: iTunes drops the connection to a torrent download if a concurrent update takes too long. Figure out what the problem is. (Might have been hangups due to DNS queries)
	# TODO: make sure we don't buffer up too much data from socket connections and chew up megabytes of memory.
	# TODO: Allow configuration and feeds.yaml to be re-loaded during runtime.
	Resolver.startResolverThread(btControl.rawServer)
	server = HTTPServer(btControl.rawServer, display, btControl, config, useHelper)
	# TODO: FeedStore should be passed to HTTPServer, not created by it
	utils.tidyDataDir(config['data_dir'], server.feedStore, btControl.rawServer)
	btControl.rawServer.install_sigint_handler()
	if useHelper:
		btControl.rawServer.add_task(MacLauncher.startHelper, 0, (config['control_port'], server.address[1], btControl))
	btControl.rawServer.add_task(display.info, 0, ('Ready on ' + prefix,))
	btControl.start()