def distribute(servers, repos, locations, run=0):
	#below is version 0.2 of the distribution protocol.
	placed = False
	#set the base locations
	for repo in repos:
		if repo not in repo.base_location.repos:
			repo.base_location.repos.append(repo)
		if repo.base_location not in repo.locations:
			repo.locations.append(repo.base_location)

	repos = sorted(repos, key=lambda r : r.local_size, reverse=True)
	locations = sorted(locations, key=lambda l : l.max_size - l.committed_size(), reverse=True)

	for repo in repos:
		possible_locations = find_possible_locations(repo, locations)
		print("Will try to place {repo} in {min_loc} of {pos}".format(repo=repo, min_loc=repo.min_locations - len(repo.locations) if run == 0 else 1, pos=possible_locations))
		for placing in (range(repo.min_locations - 1) if run == 0 else [0]):
			if len(possible_locations) > 0:
				print("Placing {repo} in {loc}".format(repo=repo, loc=possible_locations[-1]))
				placed = True
				repo.locations.append(possible_locations[-1])
				possible_locations[-1].repos.append(repo)
				possible_locations = possible_locations[:-1]
			elif run == 0:
				print('wine!')
				break
	return placed
dataset/ETHPy150Open TuinfeesT/TuinWolk/tuinwolk/tests/algorithm_test.py/distribute/original