def _dispersy(self, callback): # start Dispersy dispersy = Dispersy.get_instance(callback, self._workdir) dispersy.endpoint = StandaloneEndpoint(dispersy, 12345) dispersy.endpoint.start() # load/join discovery community public_key = "3081a7301006072a8648ce3d020106052b81040027038192000406b34f060c416e452fd31fb1770c2f475e928effce751f2f82565bec35c46a97fb8b375cca4ac5dc7d93df1ba594db335350297f003a423e207b53709e6163b7688c0f60a9cf6599037829098d5fbbfe786e0cb95194292f241ff6ae4d27c6414f94de7ed1aa62f0eb6ef70d2f5af97c9aade8266eb85b14296ed2004646838c056d1d9ad8a509b69f81fbc726201b57".decode("HEX") if False: # when crypto.py is disabled a public key is slightly # different... public_key = ";".join(("60", public_key[:60].encode("HEX"), "")) master = Member(public_key) try: self._discovery = DiscoveryCommunity.load_community(master) except ValueError: ec = ec_generate_key(u"low") self._my_member = Member(ec_to_public_bin(ec), ec_to_private_bin(ec)) self._discovery = DiscoveryCommunity.join_community(master, self._my_member) else: self._my_member = self._discovery.my_member dispersy.define_auto_load(PreviewCommunity, (self._discovery, False)) dispersy.define_auto_load(SquareCommunity, (self._discovery,)) # load squares for master in SquareCommunity.get_master_members(): yield 0.1 dispersy.get_community(master.mid)
def _dispersyCreateCommunity(self, title, description, avatar, lat, lon, radius): community = SquareCommunity.create_community(self._my_member, self._discovery) #TODO: Publish the avatar via swift and set the avatar's hash here community.set_square_info(title, description, '', (int(lat*10**6), int(lon*10**6)), radius)