示例#1
0
文件: action.py 项目: bogolt/dclord
	def on_data_downloaded(self, evt):
		key = evt.attr1
		data = evt.attr2
		if not key:
			#all data downloaded
			if len(self.stored_actions) > 0:
				self.do_perform()
			else:
				# time to save all performed changes locally
				save_load.save_local_data()
				wx.PostEvent(self.GetParent(), event.MapUpdate())
			return
			
		if not data:
			#print 'failed to load info for user %s'%(key,)
			return
		
		user_info = import_xml.processRawData(data)
		if not user_info:
			log.error('Wrong data for login %s'%(key,))
			return

		user_id = user_info['user_id']
		if 'results' in user_info:
			actions_result = user_info['results']
			self.on_reply_received(user_id, actions_result)
示例#2
0
	def onDownloadRawData(self, evt):
		key = evt.attr1
		path = evt.attr2
		if not key:
			log.info('all requested data downloaded')
			self.log('All requested data downloaded')
			save_load.save_local_data()
			#local_data_path = config.options['data']['path']
			#save_load.save_common_data(os.path.join(local_data_path, 'common')
			
			#sync_data_path = config.options['data']['sync_path']
			#if sync_data_path:
			#	save_load.save_common_data(os.path.join(sync_data_path), config.options['data']['sync_key'])
			self.map.update()
			return
		if not path:
			log.error('failed to load info for user %s'%(key,))
			self.log('Error: failed to load info for user %s'%(key,))
			return
		
		self.log('Downloaded %s %s'%(key, path))
		user = import_xml.processRawData(path)
		if not user:
			#status_text = 'Not authorized' if status == import_raw.XmlHandler.StatusAuthError else 'Turn in progress'
			self.log('Error processing %s'%(key))
		else:
			for login, acc in config.users.iteritems():
				ll = unicode(login)
				kk = unicode(key)
				if ll == kk and not 'id' in acc:
					acc['id'] = int(user['user_id'])
					print 'got user id %s for user %s'%(acc['id'], login)
					config.users[login] = acc
					config.saveUsers()
					
					config.user_id_dict[acc['id']] = acc
			
			if 'name' in user and 'turn' in user:
				self.backup_xml(path, user)
			if 'request' in user and '1' == user['request']:
				self.process_performed_actions(user['user_id'])
		
		#if key in self.recv_data_callback:
		#	func, user_id, data = self.recv_data_callback[key]
		#	del self.recv_data_callback[key]
		#	func(user_id, path)
		#	db.clear_action_result(user_id)
		
		self.map.update()
		self.object_filter.update()