X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=apt-dht.py;h=70a12640b7c7f5481bd86cdb327c80587a1d9853;hb=831e4f2adebf21b0427edde718668356a8df4837;hp=9684f572eca4b6d1c5fd81dd23b10c5fa074b3a7;hpb=925b712a25f84ef20887cd575c86fb9ab2cfa3e5;p=quix0rs-apt-p2p.git diff --git a/apt-dht.py b/apt-dht.py index 9684f57..70a1264 100644 --- a/apt-dht.py +++ b/apt-dht.py @@ -45,25 +45,31 @@ if __name__ == '__main__': config_file = opts.opts['config-file'] config.read(config_file) -if config.defaults()['username']: - uid,gid = pwd.getpwnam(config.defaults()['username'])[2:4] +if config.has_option('DEFAULT', 'username') and config.get('DEFAULT', 'username'): + uid,gid = pwd.getpwnam(config.get('DEFAULT', 'username'))[2:4] else: uid,gid = None,None +log.msg('Starting application') application = service.Application("apt-dht", uid, gid) -print service.IProcess(application).processName -service.IProcess(application).processName = 'apt-dht' +#print service.IProcess(application).processName +#service.IProcess(application).processName = 'apt-dht' -DHT = __import__(config.get('DEFAULT', 'DHT'), globals(), locals(), ['DHT']) -assert(IDHT.implementedBy(DHT.DHT), "You must provide a DHT implementation that implements the IDHT interface.") +log.msg('Starting DHT') +DHT = __import__(config.get('DEFAULT', 'DHT')+'.DHT', globals(), locals(), ['DHT']) +assert IDHT.implementedBy(DHT.DHT), "You must provide a DHT implementation that implements the IDHT interface." myDHT = DHT.DHT() if not config.getboolean('DEFAULT', 'DHT-only'): + log.msg('Starting main application server') from apt_dht.apt_dht import AptDHT myapp = AptDHT(myDHT) site = myapp.getSite() - s = strports.service('tcp:'+config.defaults()['port'], channel.HTTPFactory(site)) + s = strports.service('tcp:'+config.get('DEFAULT', 'port'), channel.HTTPFactory(site)) s.setServiceParent(application) +else: + myDHT.loadConfig(config, config.get('DEFAULT', 'DHT')) + myDHT.join() if __name__ == '__main__': # Run on command line