Revision c39a768e lib/experiment.py

View differences:

lib/experiment.py
74 74
		self.is_source = source
75 75
		self.published = dataframe
76 76
		self.neighbours = None
77
		received = dataframe[dataframe['action'] == 'RECEIVED']
78
		sent = dataframe[dataframe['action'] == 'SENT']
79
		if len(received) > 0:
80
			i = received.first_valid_index()
81
			self.address = ''.join(received['receiver'][i])
82
		else:
83
			if len(sent) > 0:
84
				i = sent.first_valid_index()
85
				self.address = ''.join(sent['sender'][i])
77
		if len(dataframe) >0:
78
			received = dataframe[dataframe['action'] == 'RECEIVED']
79
			sent = dataframe[dataframe['action'] == 'SENT']
80
			if len(received) > 0:
81
				i = received.first_valid_index()
82
				self.address = ''.join(received['receiver'][i])
86 83
			else:
87
				self.address = 'unkwnon'
84
				if len(sent) > 0:
85
					i = sent.first_valid_index()
86
					self.address = ''.join(sent['sender'][i])
87
				else:
88
					self.address = 'unknown'
89
		self.address = 'unknown'
88 90

  
89 91
	def setNeighbours(self,neighs):
90 92
		self.neighbours = neighs
93
		if self.address == 'unknown':
94
			i = self.neighbours.first_valid_index()
95
			self.address = ''.join(self.neighbours['logger'][i])
91 96

  
92 97
	def published_interval(self,begin_time,end_time):
93 98
		return self.published[(self.published['logTime'] > begin_time) & \
......
98 103
				      						 (self.published['logTime'] < (end_time*1000000))]
99 104

  
100 105
	def neighbours_interval_sec(self,begin_time,end_time):
101
		return self.neighbours[(self.neighbours['logTime'] > (begin_time*1000000)) & \
102
			(self.neighbours['logTime'] < (end_time*1000000))]
106
		if self.neighbours:
107
			return self.neighbours[(self.neighbours['logTime'] > (begin_time*1000000)) & \
108
				(self.neighbours['logTime'] < (end_time*1000000))]
109
		else:
110
			print "[WARNING] peer "+str(self.hostname)+" has not neigh data"
111
			return None

Also available in: Unified diff