def generation_zone_object(self, path: str): z = Zone() addition = "" with open(path, "r") as file_z: for line in file_z: line = line.replace("(", " ") line = line.replace(")", " ") line_list = line.split() if "$ORIGIN" in line_list: addition = line_list[1] elif "$TTL" in line_list: z.ttl = self.time_convert(line_list[1]) elif "A" in line_list: z.records_a.append(self.record_a_aaaa(line_list, addition)) elif "AAAA" in line_list: z.records_aaaa.append( self.record_a_aaaa(line_list, addition)) elif "CNAME" in line_list: z.records_cname.append( self.record_ns_cname(line_list, addition)) elif "NS" in line_list: z.records_ns.append( self.record_ns_cname(line_list, addition)) elif "SOA" in line_list: z.dns_servers_zone.append( self.record_soa(line_list, addition)) elif "MX" in line_list: z.records_mx.append( self.record_mx_recor(line_list, addition)) print(str(z)) return z
def create(self, width, height, zonewidth, zoneheight): "Créer une carte vierge" assert width > 0 assert height > 0 assert zonewidth > 0 assert zoneheight > 0 # resize zones and the map widget Zone.WIDTH = zonewidth Zone.HEIGHT = zoneheight self.resize(Zone.WIDTH, Zone.HEIGHT) # build tile-items at first load if not self.isEnabled(): self.build_tiles() self.setEnabled(True) self.set_cursor_visible(True) self.width = width self.height = height del self.zones[:] for i in xrange(width * height): zone = Zone(self) zone.fill_with_tile(0) self.zones.append(zone) self.filename = None self.set_current_zone(0)
def add_line(self, where, tile_id): assert where >= 0 and where <= self.height for i in xrange(self.width): zone = Zone(self) zone.fill_with_tile(tile_id) self.zones.insert(self.width * where, zone) self.height += 1 self.set_current_zone(0)
def add_column(self, where, tile_id): assert where >= 0 and where <= self.width for i in xrange(where, len(self.zones) + self.height, self.width + 1): zone = Zone(self) zone.fill_with_tile(tile_id) self.zones.insert(i, zone) self.width += 1 self.set_current_zone(0)
def test_get_random_zone_definitionKey_lvl1(self): random.choice = MonkeyPatches.mock_choice lvl = 1 z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"emptySpace") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"gas") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"nebula") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"safeSpace") self.assertRaises(StopIteration,Zone.get_random_zone_definitionKey,lvl)
def test_load_zone_from_pk(self): pk = dbHelp.create_test_hero_using_test_values() z1 = Zone("gas") z1.maxMonsters = 10 z1.lvl = 10 z1.save_changes(pk) z2 = Zone.construct_model_from_pk(z1.get_pk()) self.assertEqual(z1.get_description(),z2.get_description()) self.assertEqual(z1.get_fullName(),z2.get_fullName()) self.assertEqual(z1.maxMonsters,z2.maxMonsters) self.assertEqual(z1.lvl,z2.lvl)
def setTargetAddress(self, addr): """ <method internal="yes"> <summary> Set the target server address. </summary> <description> <para> This is a compatibility function for proxies that override the routed target. </para> </description> <metainfo> <arguments> <argument maturity="stable"> <name>addr</name> <type></type> <description>Server address</description> </argument> </arguments> </metainfo> </method> """ # NOTE: handling SockAddr types is a compatibility hack, as # proxies might call setServer with a SockAddr instance # instead of a tuple of SockAddrs if isinstance(addr, SockAddrType): self.target_address = (addr,) else: self.target_address = addr self.target_zone = [Zone.lookup(a) for a in self.target_address]
def __init__( self, centroid=(0, 0, 0), size=10.0 ): self.centroid = Vertex( *centroid ) self.size = float( size ) # generate min and max bounds for zone init radius = self.size / 2.0 min_bound = Vertex( *[c - radius for c in self.centroid] ) max_bound = Vertex( *[c + radius for c in self.centroid] ) Zone.__init__( self, min_bound, max_bound ) self.selected_color = ( 0.7, 0.0, 0.1, 1.0 ) self.last_color = None self.specular = ( 1.0, 1.0, 1.0, 1.0 ) self.shininess = 100.0 self.diffuse = ( 0.1, 0.0, 0.7, 1.0 )
def test_load_zone_from_dict(self): from Zone import ZoneDBFields zd = { ZoneDBFields.DEFINITION_KEY: "gas" } z = Zone.construct_model_from_dict(zd) self.assertEqual(z.get_fullName(),"Gas Planet Orbit")
def setServerAddress(self, addr): """ <method internal="yes"> <summary> Sets the server address and looks up the server zone and sets the server_zone property. </summary> </method> """ self.server_address = addr self.server_zone = Zone.lookup(addr)
def InitZones(dtc): if (printInitZoneStatus): print("\nInitializing Zones...") ret = [] for i in range(0,len(dtc),1): ret += [Zone(i, dtc[i])] if (printInitZoneStatus): print("New Zone Added") ret[len(ret)-1].PrintData() return ret
def resolveZones(name_list): """ Helper function to convert a list of zone names to a list of Zone instnaces """ name_list = makeSequence(name_list) for name in name_list: if Zone.lookup_by_name(name) == None: raise ValueError, "No zone was defined with that name; zone='%s'" % (name,)
def main(): # liste agent: http://pplapi.com/ for agent_attributes in json.load(open("agents-100k.json")): latitude = agent_attributes.pop("latitude") longitude = agent_attributes.pop("longitude") position = Position(longitude, latitude) agent = Agent(position, **agent_attributes) zone = Zone.find_zone_that_contains(position) zone.add_inhabitant(agent) agreeableness_graph = AgreeablenessGraph() agreeableness_graph.show(Zone.ZONES)
def _getSession(self, client_stream, client_local, client_listen, client_address): """<method internal="yes"> </method> """ result = getKZorpResult(client_address.family, client_stream.fd) if result is None: ## LOG ## # This message indicates that the KZorp result # lookup has failed for this session. ## log(None, CORE_POLICY, 0, "Unable to determine service, KZorp service lookup failed; bindto='%s'", (self.bindto[0], )) return None (client_zone_name, server_zone_name, dispatcher_name, service_name, rule_id) = result service = Globals.services.get(service_name) client_zone = Zone.lookupByName(client_zone_name) server_zone = Zone.lookupByName(server_zone_name) return MasterSession(service, client_stream, client_local, client_listen, client_address, client_zone = client_zone, server_zone = server_zone, rule_id = rule_id, instance_id=getInstanceId(service.name))
def test_define_zone(self): random.choice = MonkeyPatches.mock_choice_first_index random.randint = lambda l,u: 5 lvl = 6 visited = {} z = Zone.construct_next_zone_choice(lvl,visited) self.assertEqual(z[ZoneDBFields.FULL_NAME],"Empty Space") self.assertEqual(z[ZoneDBFields.LVL],11) self.assertEqual(z[ZoneDBFields.MAX_MONSTERS],5) self.assertEqual(len(visited),1) self.assertEqual(visited['emptySpace'],1) z = Zone.construct_next_zone_choice(lvl,visited) self.assertEqual(len(visited),1) self.assertEqual(visited['emptySpace'],2) self.assertEqual(z[ZoneDBFields.FULL_NAME],"Empty Space Alpha") z = Zone.construct_next_zone_choice(lvl,visited,True) self.assertEqual(z[ZoneDBFields.LVL],6) self.assertEqual(len(visited),1) self.assertEqual(visited['emptySpace'],3) self.assertEqual(z[ZoneDBFields.FULL_NAME],"Empty Space Beta")
def setServerAddress(self, addr): """ <method internal="yes"> <summary> Sets the server address and looks up the server zone and sets the server_zone property. </summary> </method> """ self.server_address = addr self.server_zone = Zone.lookup(addr) self.owner.server_address = addr self.owner.server_zone = self.server_zone
def gameLoop(): gameExit = False zone = Zone(gameDisplay) kanyes = [] start = 60 def countEnemy(): blank = Kanye(gameDisplay) kanyes.append(blank) while not gameExit: for event in pygame.event.get(): if event.type == pygame.QUIT: gameExit = True if event.type == pygame.MOUSEBUTTONDOWN: pos = pygame.mouse.get_pos() for kanye in kanyes: if kanye.kanyerect.collidepoint(pos): kanye.loseHealth() zone.addPoints() print(zone.points) if kanye.kanyerect.colliderect(zone.zonerect): kanye.loseHealth() zone.loseHealth() print("health") print(zone.health) pygame.display.update() clock.tick(60) start -= 1 if start <= 0: # spawner countEnemy() start = 45 gameDisplay.fill(backgroundcolor) for kanye in kanyes: kanye.alive() zone.showZone() # zone zone.displayUI()
def __init__(self, client_stream, client_local, client_listen, client_address): """<method internal="yes">""" self.client_stream = client_stream self.client_local = client_local self.client_listen = client_listen self.client_address = client_address if client_address is not None: try: self.client_zone = Zone.lookup(client_address) except ZoneException: self.client_zone = None else: self.client_zone = None
def __init__(self,D,zone_,nb_sharks_,nb_predators_,ori_shark) : #zone_ c'est les limites de chaque zones, ori_shark c est notre requin modele de base self.D=D #profondeur du milieu self.zones={} #dico, cle bornes de la zones sous forme de tuple, objet zone self.nb_sharks=nb_sharks_ ori_shark.updateBiolum() ori_shark.calculProfondeur() ori_shark.initProfondeur() for key in zone_: if(ori_shark.position>key[0] and ori_shark.position < key[1]): s = nb_sharks_ else : s=0 self.zones[key]=Zone(key[0],key[1],s,nb_sharks_,ori_shark) self.predators=nb_predators_ self.adaptNbPred();
def check_in_and_get_notices(heroPk,accountPk,checkinTimeUtc,utcOffset): """ this should be called on page load and should be used to get any notices for the use args: heroPk: we want a pymongo objectId for the hero table accountPk: we want a pymongo objectId for the hero table checkinTimeUtc: this needs to be that the user check in and it needs to be utc utcOffset: the time-zone offset from UTC, in minutes, for the current locale. returns: we return a dict with two elements: 'story' which will be a list of huge things of text and 'zoneChoice' which is a list of dicts each of which contain 'zonePk','description' but zoneChoice may be none. """ from Hero import Hero from Account import Account hero = Hero.construct_model_from_pk(heroPk) account = Account.construct_model_from_pk(accountPk) lastCheckinTime = account.lastCheckInTime account.lastCheckInTime = checkinTimeUtc account.save_changes() if not lastCheckinTime: messages = build_first_time_checkin_messages(hero) hero.save_changes() return messages if hero.isInZoneLimbo: autoPickedZoneDict = random.choice(hero.zone.nextZoneReferenceList) hero.zone = Zone.construct_model_from_dict(autoPickedZoneDict) hero.monster = Monster.construct_new_monster(hero.zone.definitionKey,hero.zone.lvl) timeDiffInDays = (checkinTimeUtc - lastCheckinTime)/(60*60*24) if timeDiffInDays >= 1: pass
def check_in_and_get_notices(heroPk, accountPk, checkinTimeUtc, utcOffset): """ this should be called on page load and should be used to get any notices for the use args: heroPk: we want a pymongo objectId for the hero table accountPk: we want a pymongo objectId for the hero table checkinTimeUtc: this needs to be that the user check in and it needs to be utc utcOffset: the time-zone offset from UTC, in minutes, for the current locale. returns: we return a dict with two elements: 'story' which will be a list of huge things of text and 'zoneChoice' which is a list of dicts each of which contain 'zonePk','description' but zoneChoice may be none. """ from Hero import Hero from Account import Account hero = Hero.construct_model_from_pk(heroPk) account = Account.construct_model_from_pk(accountPk) lastCheckinTime = account.lastCheckInTime account.lastCheckInTime = checkinTimeUtc account.save_changes() if not lastCheckinTime: messages = build_first_time_checkin_messages(hero) hero.save_changes() return messages if hero.isInZoneLimbo: autoPickedZoneDict = random.choice(hero.zone.nextZoneReferenceList) hero.zone = Zone.construct_model_from_dict(autoPickedZoneDict) hero.monster = Monster.construct_new_monster(hero.zone.definitionKey, hero.zone.lvl) timeDiffInDays = (checkinTimeUtc - lastCheckinTime) / (60 * 60 * 24) if timeDiffInDays >= 1: pass
def test_zone_properties_default(self): testZoneKey = ZoneDefinitionFields.EMPTY_SPACE z = Zone(testZoneKey) z.suffix = "Alpha" z.monstersKilled = 5 z.maxMonsters = 10 z.lvl = 4 pZPk = dbHelp.create_test_zone_obj(ZoneDefinitionFields.HOME).get_pk() z.previousZoneReferencePK = pZPk z.nextZoneReferenceList = [dbHelp.create_test_zone_dict(ZoneDefinitionFields.ASTEROID_FIELD), dbHelp.create_test_zone_dict(ZoneDefinitionFields.GAS), dbHelp.create_test_zone_dict(ZoneDefinitionFields.NEBULA)] self.assertEqual(z.definitionKey, testZoneKey) self.assertEqual(z.get_fullName(), ZoneDefinition.get_name_for_key(testZoneKey) + " Alpha") self.assertEqual(z.suffix,"Alpha") self.assertEqual(z.monstersKilled, 5) self.assertEqual(z.maxMonsters,10) self.assertEqual(z.lvl, 4) self.assertEqual(z.get_description(),ZoneDefinition.get_description_for_key(testZoneKey)) self.assertEqual(z.previousZoneReferencePK,pZPk) self.assertListEqual(z.nextZoneReferenceList,[dbHelp.create_test_zone_dict(ZoneDefinitionFields.ASTEROID_FIELD), dbHelp.create_test_zone_dict(ZoneDefinitionFields.GAS), dbHelp.create_test_zone_dict(ZoneDefinitionFields.NEBULA)])
def test_get_random_zone_definitionKey_lvl5(self): random.choice = MonkeyPatches.mock_choice lvl = 5 z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"emptySpace") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"gas") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"nebula") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"safeSpace") MonkeyPatches.testZoneGroup = "lvl5Zones" z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"asteroidField") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"backwater") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"solar") z = Zone.get_random_zone_definitionKey(lvl) self.assertEqual(z,"uncharted") self.assertRaises(StopIteration,Zone.get_random_zone_definitionKey,lvl)
def scanForZones(self): print("SCAN!") global Zones addressDict = psutil.net_if_addrs() ipList = [] for key in addressDict: intf = addressDict[key] for l in intf: if l.family == socket.AddressFamily.AF_INET and l.address.startswith( '192.168.'): ipList.append(l.address) #zones = soco.discover(interface_addr='192.168.1.86') for ip in ipList: zones = soco.discover(timeout=1, interface_addr=ip) if zones is not None and len(Zones) != len(zones): self.zoneStore.clear() if len(zones) > 0: self.titleLabel.set_label("Rooms (" + str(len(zones)) + ")") for zone in zones: z = Zone(zone, self) Zones.append(z) self.zoneStore.append([ self.testSymbol, zone.player_name, self.testSymbol2, zone.get_current_transport_info() ["current_transport_state"], z ]) # print(zone.get_current_transport_info()) self.selected_row_iter = self.zoneStore.get_iter_first() self.select.select_iter(self.selected_row_iter) break elif zones is None: print("No zones found at " + ip) else: print("CACHED!") if zones is None: self.titleLabel.set_label("No Zones Found") self.show_all()
def loadValues(self): self.zones=[] config=ConfigParser.RawConfigParser() config.read(self.cfgFileName) for section in config.sections(): zone = Zone() zone.zoneid=config.get(section,"zoneid") zone.name=config.get(section,"name") zone.description=config.get(section,"description") zone.imagearea=config.get(section,"imagearea") zone.imagearea=config.get(section,"imagearea") zone.days=config.get(section,"days") zone.start=config.get(section,"start") zone.duration=config.get(section,"duration") #zone.started=config.get(section,"zoneid") #fields = zone.getDefaultFields() #for value in fields: # exec (("zone.%s=config.get(section,name)") ,value) self.zones.append(zone) return
def test_zone_properties_from_dict(self): hpk = dbHelp.setup_test_hero_using_default_values() zd = dbHelp.create_test_zone_dict() testZoneKey = ZoneDefinitionFields.EMPTY_SPACE z = Zone.construct_model_from_dict(zd) self.assertEqual(z.definitionKey, testZoneKey) self.assertEqual(z.get_fullName(), ZoneDefinition.get_name_for_key(testZoneKey) + " Alpha") self.assertEqual(z.suffix,"Alpha") self.assertEqual(z.monstersKilled, 2) self.assertEqual(z.maxMonsters,15) self.assertEqual(z.lvl, 3) self.assertEqual(z.get_description(),ZoneDefinition.get_description_for_key(testZoneKey)) oldCount = tu.get_record_count_from_table(ZoneDBFields.COLLECTION_NAME) z.save_changes(hpk) newCount = tu.get_record_count_from_table(ZoneDBFields.COLLECTION_NAME) self.assertEqual(oldCount +1, newCount) oldCount = tu.get_record_count_from_table(ZoneDBFields.COLLECTION_NAME) z.save_changes(hpk) newCount = tu.get_record_count_from_table(ZoneDBFields.COLLECTION_NAME) self.assertEqual(oldCount, newCount)
def __init__(self): Zone.__init__(self, "models/maps/toontown_central.egg") self.setSpawnPoint(0, 18, 4) self.setSpawnRot(180)
def __init__( self, position=(0,0,0), size=2, color=(0,0,1,1) ): Zone.__init__( self ) self.position = Vector3( position ) self.size = float( size )
def setServerAddress(self, addr): self.server_address = addr self.server_zone = Zone.lookup(addr)
def setClientAddress(self, addr): self.client_address = addr self.client_zone = Zone.lookup(addr)
''' Created on 2017-12-18 @author: Administrator ''' # -*- coding:utf-8 -*- from Zone import Zone import logging zonelist={ #'鼓楼':'https://nj.lianjia.com/ershoufang/gulou/', #'建邺':'https://nj.lianjia.com/ershoufang/jianye/', #'秦淮':'https://nj.lianjia.com/ershoufang/qinhuai/', #'玄武':'https://nj.lianjia.com/ershoufang/xuanwu/', '雨花台':'https://nj.lianjia.com/ershoufang/yuhuatai/', #'栖霞':'https://nj.lianjia.com/ershoufang/qixia/', #'江宁':'https://nj.lianjia.com/ershoufang/jiangning/', #'浦口':'https://nj.lianjia.com/ershoufang/pukou/' } if __name__ == '__main__': for k, v in zonelist.items(): zone = Zone(k, v) zone.scrapysubzone() logging.debug('finish scrap zone %s with url %s'%(k, v))
def test_convert_number_to_naming_number_base(self): n = Zone.skip_powers_of_base_in_number(0,10) self.assertEqual(n,0) n = Zone.skip_powers_of_base_in_number(1,10) self.assertEqual(n,1) n = Zone.skip_powers_of_base_in_number(9,10) self.assertEqual(n,9) n = Zone.skip_powers_of_base_in_number(10,10) self.assertEqual(n,11) n = Zone.skip_powers_of_base_in_number(11,10) self.assertEqual(n,12) n = Zone.skip_powers_of_base_in_number(18,10) self.assertEqual(n,19) n = Zone.skip_powers_of_base_in_number(19,10) self.assertEqual(n,21) n = Zone.skip_powers_of_base_in_number(20,10) self.assertEqual(n,22) n = Zone.skip_powers_of_base_in_number(21,10) self.assertEqual(n,23) n = Zone.skip_powers_of_base_in_number(27,10) self.assertEqual(n,29) n = Zone.skip_powers_of_base_in_number(28,10) self.assertEqual(n,31) n = Zone.skip_powers_of_base_in_number(91,10) self.assertEqual(n,101) n = Zone.skip_powers_of_base_in_number(100,10) self.assertEqual(n,111)
def _getSession(self, client_stream, client_local, client_listen, client_address): """ <method internal="yes"> <summary>Virtual function which returns the service to be ran</summary> <description> <para> This function is called by our base class to find out the service to be used for the current client_info. It uses the client and the server zone name to decide which service to use. </para> </description> <metainfo> <arguments> <argument maturity="stable"> <name>client_info</name> <type></type> <description>Session information</description> </argument> </arguments> </metainfo> </method> """ dest_zone = Zone.lookup(client_local) client_zone = Zone.lookup(client_address) cache_ndx = (client_zone.getName(), dest_zone.getName()) cached = self.cache.lookup(cache_ndx) if cached == 0: ## LOG ## # This message indicates that no applicable service was found for this client zone in the services cache. # It is likely that there is no applicable service configured in this CSZoneListener/Receiver at all. # Check your CSZoneListener/Receiver service configuration. # @see: Listener.CSZoneListener # @see: Receiver.CSZoneReceiver ## log(None, CORE_POLICY, 2, "No applicable service found for this client & server zone (cached); bindto='%s', client_zone='%s', server_zone='%s'", (self.bindto, client_zone, dest_zone)) elif cached: return MasterSession(cached, client_stream, client_local, client_listen, client_address, client_zone = client_zone, instance_id=getInstanceId(cached.name)) src_hierarchy = {} dst_hierarchy = {} if self.follow_parent: z = client_zone level = 0 while z: src_hierarchy[z.getName()] = level z = z.admin_parent level = level + 1 src_hierarchy['*'] = level max_level = level + 1 z = dest_zone level = 0 while z: dst_hierarchy[z.getName()] = level z = z.admin_parent level = level + 1 dst_hierarchy['*'] = level max_level = max(max_level, level + 1) else: src_hierarchy[client_zone.getName()] = 0 src_hierarchy['*'] = 1 dst_hierarchy[dest_zone.getName()] = 0 dst_hierarchy['*'] = 1 max_level = 10 best = None for spec in self.services.keys(): try: src_level = src_hierarchy[spec[0]] dst_level = dst_hierarchy[spec[1]] except KeyError: src_level = max_level dst_level = max_level if not best or \ (best_src_level > src_level) or \ (best_src_level == src_level and best_dst_level > dst_level): best = self.services[spec] best_src_level = src_level best_dst_level = dst_level service = None if best is not None and best_src_level < max_level and best_dst_level < max_level: try: service = Globals.services[best] except KeyError: log(None, CORE_POLICY, 2, "No such service; service='%s'", (best)) else: ## LOG ## # This message indicates that no applicable service was found for this client zone. # Check your CSZoneListener/Receiver service configuration. # @see: Listener.CSZoneListener # @see: Receiver.CSZoneReceiver ## log(None, CORE_POLICY, 2, "No applicable service found for this client & server zone; bindto='%s', client_zone='%s', server_zone='%s'", (self.bindto, client_zone, dest_zone)) if service is None: return None self.cache.store(cache_ndx, service) return MasterSession(service, client_stream, client_local, client_listen, client_address, client_zone = client_zone, instance_id=getInstanceId(service.name))
def test_generate_area_name_suffix(self): symbols = Zone.get_symbols() combos = set() for s1 in symbols: for s2 in symbols: if not s1: continue combos.add("{} {}".format(s1,s2).strip()) for i in range(1, 10101): s = Zone.generate_full_zone_name_suffix(i) self.assertTrue(s in combos) combos.discard(s) self.assertEqual(len(combos),0) s = Zone.generate_full_zone_name_suffix(0) self.assertEqual(s,"") s = Zone.generate_full_zone_name_suffix(1) self.assertEqual(s,"Alpha") s = Zone.generate_full_zone_name_suffix(2) self.assertEqual(s,"Beta") s = Zone.generate_full_zone_name_suffix(9) self.assertEqual(s,"November") s = Zone.generate_full_zone_name_suffix(100) self.assertEqual(s,"Zed") s = Zone.generate_full_zone_name_suffix(101) self.assertEqual(s,"Alpha Alpha") s = Zone.generate_full_zone_name_suffix(102) self.assertEqual(s,"Alpha Beta") s = Zone.generate_full_zone_name_suffix(200) self.assertEqual(s,"Alpha Zed") s = Zone.generate_full_zone_name_suffix(201) self.assertEqual(s,"Beta Alpha") s = Zone.generate_full_zone_name_suffix(202) self.assertEqual(s,"Beta Beta") s = Zone.generate_full_zone_name_suffix(10099) self.assertEqual(s,"Zed Omega") s = Zone.generate_full_zone_name_suffix(10100) self.assertEqual(s,"Zed Zed") s = Zone.generate_full_zone_name_suffix(10101) self.assertEqual(s,"Alpha 2") s = Zone.generate_full_zone_name_suffix(10102) self.assertEqual(s,"Beta 2")
def __init__(self, service, client_stream, client_local, client_listen, client_address, **kwargs): """ <method internal="yes"> <summary> Constructor to initialize a MasterSession instance. </summary> <description> <para> This constructor initializes a new MasterSession instance based on its arguments. </para> </description> <metainfo> <arguments/> </metainfo> </method> """ if client_address is None and hasattr(kwargs, 'client_zone') is True: raise AttributeError super(MasterSession, self).__init__() self.service = service self.client_stream = client_stream self.client_local = client_local self.client_listen = client_listen self.client_address = client_address self.client_zone = getattr(kwargs, 'client_zone', None) self.rule_id = getattr(kwargs, 'rule_id', None) self.server_address = getattr(kwargs, "server_address", None) self.server_zone = getattr(kwargs, "server_zone", None) self.server_local = None self.target_address = getattr(kwargs, "target_address", ()) self.target_local = getattr(kwargs, "target_local", None) self.target_zone = getattr(kwargs, "target_zone", ()) self.instance_id = kwargs.pop("instance_id", 0) for arg_name,value in kwargs.items(): setattr(self, arg_name, value) log(None, CORE_DEBUG, 8, "Added value to the session; name='%s', value='%s'" % (arg_name, value)) if self.client_address is not None and self.client_zone is None: try: self.client_zone = Zone.lookup(client_address) except ZoneException: self.client_zone = None if self.server_address is not None and self.server_zone is None: try: self.server_zone = Zone.lookup(server_address) except ZoneException: self.server_zone = None # these are set by the router to indicate how target address # selection should work based on the type of the router used self.target_address_inband = FALSE self.target_local_loose = TRUE self.target_local_random = FALSE self.proxy = None self.started = 0 self.auth_user = "" self.auth_groups = () self.authorized = FALSE self.protocol = self.client_listen.protocol self.protocol_name = get_protocol_name(self.protocol) self.base_session_id = 'svc' self.session_id = "%s/%s/%s:%d" % (self.base_session_id, Globals.virtual_instance_name, self.service.name, self.instance_id) self.master_session_id = self.session_id self.verdict = ConnectionVerdict(ConnectionVerdict.ACCEPTED)
def create_test_zone_obj(zoneKey=None): zoneDict = create_test_zone_dict(zoneKey) zoneObj = Zone.construct_model_from_dict(zoneDict) return zoneObj
def __init__( self, vertex_a, vertex_b ): self.vertices = [ vertex_a, vertex_b ] Zone.__init__( self, *self.generate_bounds() )
def test_get_unlocked_zones(self): z = Zone.get_unlocked_zone_groupKeys(1) self.assertEqual(len(z),1) z = Zone.get_unlocked_zone_groupKeys(2) self.assertEqual(len(z),1) z = Zone.get_unlocked_zone_groupKeys(4) self.assertEqual(len(z),1) z = Zone.get_unlocked_zone_groupKeys(5) self.assertEqual(len(z),2) z = Zone.get_unlocked_zone_groupKeys(9) self.assertEqual(len(z),2) z = Zone.get_unlocked_zone_groupKeys(10) self.assertEqual(len(z),3) z = Zone.get_unlocked_zone_groupKeys(14) self.assertEqual(len(z),3) z = Zone.get_unlocked_zone_groupKeys(15) self.assertEqual(len(z),4) z = Zone.get_unlocked_zone_groupKeys(19) self.assertEqual(len(z),4) z = Zone.get_unlocked_zone_groupKeys(20) self.assertEqual(len(z),5) z = Zone.get_unlocked_zone_groupKeys(24) self.assertEqual(len(z),5) z = Zone.get_unlocked_zone_groupKeys(25) self.assertEqual(len(z),6) z = Zone.get_unlocked_zone_groupKeys(29) self.assertEqual(len(z),6) z = Zone.get_unlocked_zone_groupKeys(30) self.assertEqual(len(z),7) z = Zone.get_unlocked_zone_groupKeys(300) self.assertEqual(len(z),7)