Jump to content

[Python issue] channelID returns 0


Recommended Posts

Hello, I am trying to figure out why channelID returns KeyError : 0

Can someone please help me ?

Relevant code from serverinfo.py

CHANNEL_DICT = {
	1:{"key":11,"name":CH1_NAME,"ip":SERVER_IP,"tcp_port":PORT_1,"udp_port":PORT_1,"state":STATE_NONE,},
	2:{"key":12,"name":CH2_NAME,"ip":SERVER_IP,"tcp_port":PORT_2,"udp_port":PORT_2,"state":STATE_NONE,},
	3:{"key":13,"name":CH3_NAME,"ip":SERVER_IP,"tcp_port":PORT_3,"udp_port":PORT_3,"state":STATE_NONE,},
	4:{"key":14,"name":CH4_NAME,"ip":SERVER_IP,"tcp_port":PORT_4,"udp_port":PORT_4,"state":STATE_NONE,},
}

REGION_DICT2 = { 'name': SERVER_NAME, 'channel': CHANNEL_DICT }

Relevant code from intrologin.py

def __RequestChannelList(self):
		channelDict = (serverInfo.REGION_DICT2["channel"])
		ServerStateChecker.Initialize();
		for id, channelDataDict in channelDict.items():
			key=channelDataDict["key"]
			ip=channelDataDict["ip"]
			udp_port=channelDataDict["udp_port"]
			ServerStateChecker.AddChannel(key, ip, udp_port)

		ServerStateChecker.Request()
		
	def __RefreshChannelList(self):
	
		bakChannelID = self.channelList.GetSelectedItem()
		
		self.channelList.ClearItem()
		
		channelDict = (serverInfo.REGION_DICT2["channel"])
		
		for channelID, channelDataDict in channelDict.items():
			channelName = channelDataDict["name"]
			channelState = channelDataDict["state"]
			self.channelList.InsertItem(channelID, " %s %s" % (channelName, channelState))

		self.channelList.SelectItem(bakChannelID-1)

def __OnLoadScript(self, fileName):
...
channelID = self.__GetChannelID()
channelDict = (serverInfo.REGION_DICT2["channel"])
state = channelDict[channelID]["state"]
.
.
.
def __GetChannelID(self):
	return self.channelList.GetSelectedItem()
Edited by covfefe
Added more code
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.