Example #1
0
class ManualSlave(Slave):

	def loop(self, streaming = False):
		self.run()
		self.introduce()
		self.bidder  = Bidder(setting.default_bidder_params(self.peername), self)
		self.auctioneer = Auctioneer(setting.default_auctioneer_params(self.peername), self)
		self.bidder.run()
		self.auctioneer.run()
		if streaming:
			if sys.platform.startswith('linux'):
				from vlc_player import VlcPlayer as Player
			elif sys.platform.startswith('darwin'):
				from qtvlc_player import QtvlcPlayer as Player
			player = Player()
			player.open_api_run()
		else:
			try:
				while True:
					command = raw_input().lower()
					if not command or command == 'exit':
						break
			except KeyboardInterrupt:
				pass
		self.bidder.close()
		self.auctioneer.close()
		self.close()
Example #2
0
class AutoSlave(Slave):

	def loop(self, streaming = False):
		self.run()
		self.introduce()
		#auctioneer bidder
		self.bidder = None
		self.auctioneer = None
		if streaming:
			if sys.platform.startswith('linux'):
				import qtvlc_player.QtvlcPlayer as Player
			elif sys.platform.startswith('darwin'):
				import vlc_player.VlcPlayer as Player
			player = Player()
			player.open_api_run()
		else:
			try:
				while True:
					command = raw_input().lower()
					if not command or command == 'exit':
						break
			except KeyboardInterrupt:
				pass
		if self.bidder and self.bidder.running:
			self.bidder.close()
		if self.auctioneer and self.auctioneer.running:
			self.auctioneer.close()
		self.close()

	'Override'
	def bidder_start_from_master(self, master_ip, info):
		if self.bidder and self.bidder.running:
			self.bidder.close()
		bidder_params = setting.default_bidder_params(self.peername)
		bidder_params['bnumber'] = int(info)
		self.bidder  = Bidder(bidder_params, self)
		self.bidder.run()

	def bidder_stop_from_master(self, master_ip, info):
		if self.bidder:
			self.bidder.close()

	def auctioneer_start_from_master(self, master_ip, info):
		if self.auctioneer and self.auctioneer.running:
			self.auctioneer.close()
		auctioneer_params = setting.default_auctioneer_params(self.peername)
		auctioneer_params['delay'] = float(info)
		self.auctioneer = Auctioneer(auctioneer_params, self)
		self.auctioneer.run()

	def auctioneer_stop_from_master(self, master_ip, info):
		if self.auctioneer:
			self.auctioneer.close()