Ejemplo n.º 1
0
def main():
	global group, groups, config, threads
	global action, scroll, machine, bluescreen, user, carouselSign, imgLoader, concentric, flash, blend
	
	####################################################################
	################  JUST FOR COMMAND LINE !!!!! ######################
	### Below are used to run individual modules from command line
	# eg ./run.sh explosion or ./run.sh scroll "TEST" 2
	####################################################################

	threads = []
	thrd = threading.Thread(target=stest.__main__)
	threads.append(thrd)
	thrd.start()

	if(configure()) :
		try:
			args = sys.argv
			#print(args)
			if(len(args) > 1):
				argument =  args[1]
				if(len(args) > 2) : options = args[2]
				if(len(args) > 3) : options2 = args[3]
				if(len(args) > 4) : options3 = args[4]
				if(argument == "explosion") : 
					actions.explosion()
					exit()
				elif(argument == "burst") : 
					actions.burst()
					exit()
				elif(argument == "user") : 
					user.userAnimator(250,2,True)
					exit()        	
				elif(argument == "cards") : 
					machine.machineAnimator(10000)
					exit()
				elif(argument == "glitch") : 
					actions.glitch()
					exit()
				elif(argument == "scroll") : 
					if (options2 != "") : scroll.steps = int(options2)
					actions.drawBlanksFlag = False
					scroll.scrollMessage(options, True, False, "Left")
					exit()
				elif(argument == "present") : 
					# e.g. spy sequence.py present "ASIF" 1 0
					if (options2 != "") : dur = int(options2)
					if (options3 != "") : scroll.countLimit = int(options3)
					actions.drawBlanksFlag = False
					scroll.present(options,(), dur)
					exit()
				elif(argument == "stroop") : 
					for i in range(0,10) : 
						if(scroll.opticalOpposites) : 
							scroll.opticalOpposites = False
						else : 
							scroll.opticalOpposites = True
						stroopSequence()
					exit()
				elif(argument == "squares") : 
					concentric.colorSwitch = False
					concentric.animator(60, "cols")
					exit()
				elif(argument == "sqrs") : 
					sqrs.colorSwitch = False
					sqrs.animator(60, "cols")
					exit()
				elif(argument == "flash") : 
					flash.colorSwitch = False
					flash.animator(100)
					exit()
				elif(argument == "blend") : 
					blend.colorSwitch = False
					blend.animator(100)
					exit()
				elif(argument == "blue") : 
					bluescreen.draw()
					exit()
				elif(argument == "pan") : 
					imgLoader.action = "pan"
					imgLoader.countLimit = 1
					imgLoader.start("",0,-1)
					exit()	
				elif(argument  == "play") :
					imgLoader.action = "play"
					imgLoader.countLimit = 100
					imgLoader.xOffset = 0
					imgLoader.yOffset = 0
					imgLoader.start()
				elif(argument  == "car") :
					carouselSign.go(options)

				###################################################
				# ----------  Play the group sequence  ---------- #
				###################################################

				elif(argument  == "seq") :
					group = groups[int(options)]
					runSequence()

			else : runSequence()
		except getopt.GetoptError as err:
			# print help information and exit:
			print ("Error:" + str(err))
Ejemplo n.º 2
0
def runSequence() :
	global group, groups
	global action, scroll, machine, bluescreen, user, carouselSign, imgLoader, concentric, flash, blend, sqrs
	global T1,T2,thrd
	lastAction  = 0

	try:

		# If there are more than one set of animations per group e.g. various
		# text sequences, "randomize" the selection and try to avoid repeating
		# the exact same one twice in a row ...

		if(len(group) > 1) :
			seq = int(random.uniform(1,30))
			while (seq not in group and seq != lastAction) : 
				seq = int(random.uniform(1,30))
		else : 
			seq = group[0]
		# try not to repeat
		lastAction = seq
		#print("running", group, len(group))

		# --------------------------------------------------------------------------#
		# Force the checking of the status file  -- sometimes the cron does not run
		# probably it seems due to higher CPU load etc ...
		# --------------------------------------------------------------------------#
		T2 = time.time()
		'''
		# Commenting this ut in favor of dedicated off-button
		if((T2 - T1) > 15) :
			# Disabling the remote url checks

			threads = []
			thrd = threading.Thread(target=off_signal.checker)
			threads.append(thrd)
			thrd.start()

			
			#print(threads)
			#off_signal.checker()
			T1 = time.time()
		'''

		# -------  SCROLL         -------------
		if(seq == 1) :
			if(random.random() > .8) :actions.burst(10)
			scroll.scrollMessage("** PTGS ** GIFS ** JPEGS ** AVIs ** MOVs ** CODEZ ** CRACKS **", True, False, "Left")
		
		# -------  SCROLL         -------------
		elif(seq == 2) :
			if(random.random() > .8) : actions.explosion()
			scroll.scrollMessage("** FIGURATIVE ** ABSTRACT ** NO SOFTWARE **", True, False, "Left")
		
		# -------  SCROLL         -------------
		elif(seq == 3) :
			if(random.random() > .8) : actions.explosion()
			scroll.scrollMessage("** All USERS!! **", True, False, "Left")
			if(random.random() > .8) :
				scroll.scrollMessage("Hey there " + str(int(random.uniform(10000,99999))) + "asdfasdfasdsf", True, False, "Left")
				actions.explosion()
		
		# -------  SCROLL  $$$$   -------------
		elif(seq == 4) :
			if(random.random() > .8) : actions.explosion()
			numDolls = int(random.uniform(3,24))
			strg = ""
			for n in range (3,numDolls) : strg += "$"
			scroll.scrollMessage(strg, True, False, getDirection())
		
		# -------  STROOP STROOP  -------------
		elif (seq == 5) :
			numRuns = int(random.uniform(2,6))
			for i in range(0,numRuns) : 
				if(scroll.opticalOpposites) : 
					scroll.opticalOpposites = False
				else : 
					scroll.opticalOpposites = True
				stroopSequence()
		
		# -------  SCROLL         -------------
		elif (seq == 6) :
			if(random.random() > .8) : actions.burst(10)
			scroll.scrollMessage("<> THOUSANDS of COLORS <>", True, True, "Left")
		
		# -------  SCROLL         -------------
		elif(seq == 7) :
			if(random.random() > .8) : actions.burst(10)
			scroll.scrollMessage("** PTGS PTGS PTGS **", True, False, "Left")
		
		# -------  SCROLL         -------------
		elif(seq == 8) :
			if(random.random() > .8) : actions.burst(10)
			if(random.random() > .8) : actions.explosion()
			scroll.scrollMessage("** COLD AND HOT **", True, False, "Left")
		
		# -------  SCROLL         -------------
		elif(seq == 9) :
			if(random.random() > .8) : actions.explosion()
			scroll.scrollMessage("% % %%%% HUGE PROBABILITIES %%%% % %", True, False, "Left")					
		
		# ------- * EMOTIES       -------------
		elif (seq == 10) :
			# reset blanks
			if (random.random() > .5) : actions.setBlanks()
			numDolls = int(random.uniform(30,60))
			strg = ""
			scroll.fontSize -= 6
			actions.drawCounterXOsFlag = True
			space = "  "
			for n in range (2, numDolls) : 
				strg += ":)"+space
				if (random.random() > .95) : strg += ":o"+space
				if (random.random() > .95) : strg += ";)"+space
			scroll.scrollMessage(strg, True, True, "Left")

			# After completition reset for other runs
			scroll.fontSize += 6
			actions.drawCounterXOsFlag = False
		
		# -------  ASIF SCREEN     -------------
		elif (seq == 11) :
			scroll.countLimit = 5
			scroll.present("ASIF",1)
		
		# -------  ASIF LOVE FEAR CAROUSEL -------	
		elif(seq == 12) :
			clrFlicker = carouselSign.useColorFLicker
			if(random.random() > .95) : carouselSign.useColorFLicker = True
			carouselSign.go("    **** HOT & COLD ****", 0)
			#carouselSign.useColorFlicker = clrFlicker
			carouselSign.useColorFLicker = False
		
		# -------  ASIF LOVE FEAR CAROUSEL noend *	
		elif(seq == 13) :
			if(random.random() > .5) : carouselSign.useColorFLicker = True
			carouselSign.go("       ***** BEEF * CHICKEN * PORK * FISH * LAMB  ****", -1)
			carouselSign.useColorFlicker = False

		# Animation only modules
		
		# -------  USER            -------------
		elif(seq == 14) :
			fixed = False
			duration = int(random.uniform(24,100))
			if(random.random() > .4) : fixed = True
			user.userAnimator(duration, 2, fixed)
		
		# -------  CARDS / MACHINE -------------
		elif(seq == 15) :
			machine.machineAnimator(830) # 430
			if(random.random() > .9) : user.userAnimator(24)
		
		# -------  BLUE SCREEN     -------------
		elif(seq == 16) :
			bluescreen.draw()
		
		# -------  GLITCH SCREEN   -------------
		elif(seq == 17) :
			actions.glitch()
		
		# -------  CONCENTRICS     -------------
		elif (seq == 18) :
			concentric.colorSwitch = False
			concentric.animator(60)
		
		# -------  EXLPOSIONS      -------------
		elif (seq == 19) :
			actions.explosion()

		# -------  BLEND/FLASH     -------------
		elif(seq == 23) : 
			blend.colorSwitch = False
			blend.animator(0)


		# Image Loading Modules	
		
		# -------  DEFAULT PAN     -------------
		elif (seq == 20) :
			imgLoader.action = "pan"
			imgLoader.countLimit = 1
			imgLoader.start("",0,-1)
		
		# -------  DEFAULT PLAY (FLAMES) -------
		elif (seq == 21) :
			imgLoader.action = "play"
			imgLoader.countLimit = 500
			imgLoader.xOffset = 0
			imgLoader.yOffset = 0
			imgLoader.start()
		
		#------ Plane Scrolling --------
		elif (seq == 22) :
			imageScrollSeq()

		#------ Present Bad Pixel --------
		elif (seq == 24 or seq == 25) :
			imageList = ['badpixel.gif'] 
			imgLoader.debug = False
			imgLoader.action = "present"
			imgLoader.countLimit = 1 #int(random.uniform(10,100))
			imgLoader.gifPlaySpeed = int(random.uniform(50,250))
			imgLoader.brightnessFactor  = random.uniform(.25,.75)
			imgLoader.brightnessFlux = True
			imgLoader.brightnessFluxRate = 240
			imgLoader.xOffset = 0
			imgLoader.yOffset = 0
			img = 0
			path = config.path  + "/imgs"
			img = int(random.random() *  len(imageList))
			imgLoader.start(path + "/" + imageList[img],0,-1)

	except Exception, e:
		if(e == "KeyboardInterrupt") :
			print("Stopping")
			exit()
		else :
			# Weak....
			pass