Exemplo n.º 1
0
    def __init__(self):
	
	#Load up the server conifg.
	check_config.init_server()
	cfg = ConfigParser.RawConfigParser()
	self.config = "/etc/tpm_server/config"
	
	if check_config.check(self.config):
	    cfg.readfp(open(self.config))
	    self.package_file = cfg.get("package", "dir")
	    self.sql = sql.Database(self.package_file)
	    self.random_package_num = 100000
	    self.init_gnupg()
	    self.parse_options()
Exemplo n.º 2
0
Arquivo: tpm.py Projeto: Cightline/tpm
    def __init__(self):
	
	self.config = "/etc/tpm/config"
	
	#Check to see if our config exists, then grab some args.
	if check_config.check(self.config):
	    cfg = ConfigParser.RawConfigParser()
	    cfg.readfp(open(self.config))
	    self.json_server = cfg.get("server", "address")
	    self.json_port = cfg.get("server", "port")
	    
	
	self.SUCCESS = {"update_database":"Database updated"}
	self.ERROR = {"update_database":"Could not update database"}
	
	self.q = []
	
	
	#Setup our command line options
	parser = optparse.OptionParser()
	
	
	parser.add_option('--update',
				action="store_true",
				dest='update_database', 
				help="Update your local torrent list", 
			)
			
	parser.add_option('-s', '--search',
				action="store",
				dest="search_torrent",
				help="Search for a package",
			)
			
	parser.add_option('-l', '--list',
				action="store_true",
				dest="list_torrents",
				help="List packages"
			)

			
	parser.add_option('--torrent-largest',
				action="store",
				dest="torrent_largest",
				help="--spider [path] find the biggest file and torrent it)"
			)
			
			
	(self.options, self.args) = parser.parse_args()
Exemplo n.º 3
0
    def __init__(self):
	self.daemon_config = "/etc/tpm/config"
	
	check_config.init_tpm()
	
	#Check the config, might make this a def.
	if check_config.check(self.daemon_config):
	    self.local_database = "/etc/tpm/torrent.db"
	    self.sql = sql.Database(self.local_database)
	    self.cfg = ConfigParser.RawConfigParser()
	    self.cfg.readfp(open(self.daemon_config))
	    self.ports = self.cfg.get("tracker", "ports")
	    self.tracker = self.cfg.get("tracker", "address")
	    self.server = self.cfg.get("server", "address")
	    self.s = libtorrent.session()
	    self.s.listen_on(int(self.ports.split(" ")[0]), int(self.ports.split(" ")[1]))
	    print "[tpmd] Running"