Example #1
0
def main():
	global calculated_time, elapsed_time
	queue = Queue()
	estimateT = threading.Thread(target=getestimate)
	# elapsedT = threading.Thread(target=getelapsed)
	estimateT.start()
	# elapsed├ąT.start()
	temppath = os.path.expanduser(os.path.join("~", "AppData", "Local", "Temp"))
	lelap, lcalc = elapsed_time, calculated_time

	json.dump({}, open(os.path.join(temppath, "toscript.json"), "w"))

	while True:
		if os.path.exists(os.path.join(temppath, "toscript.json")):
			dataf = open(os.path.join(temppath, "toscript.json"))
			datat = dataf.read()
			try:
				data = json.loads(datat)
				if data and data["action"] != null:
					print(data)
			except:
				if "action" in data and data["action"] != "null":
					print(datat)
			if data:
				try:
					comm.parseData(queue, data)
				except: pass
				json.dump(comm.generateData(queue, calculated_time, elapsed_time), open(os.path.join(temppath, "topage.json"), "w"))
				json.dump({}, open(os.path.join(temppath, "toscript.json"), "w"), {})
				if data["action"] != "null": print(queue.queue)
		elif lelap != elapsed_time or lcalc != calculated_time:
			json.dump(open(os.path.join(temppath, "topage.json"), "w"), comm.generateData(queue, calculated_time, elapsed_time))
Example #2
0
def process(data):
	global queue, shamed, sessions
	if data:
		try:
			queue.metapriority()
			x = comm.parseData(queue, sessions, data)
			if "action" in data and data["action"] != "null":
				sessions.update()
				if args.backup:
					json.dump(queue.queue, open("cache.json", "w"), indent=2)
					sids.cache(sessions)
			if x and type(x) is str:
				if x == "uuddlrlrba":
					if config["easter_eggs"]:
						serveToAllConnections({"action":"rickroll"})
					else:
						cprint(bcolors.YELLOW + "This is a serious establishment, son. I'm dissapointed in you.")
				elif x == "refresh":
					if config["allow_force_refresh"]:
						serveToAllConnections({"action":"refresh"})
					else:
						cprint(bcolors.YELLOW + "Force refresh isn't enabled. (config.json, allow_force_refresh)")
				elif x == "sorry":
					if data["sid"][:int(len(data["sid"])/2)] in shamed:
						shamed.remove(data["sid"][:int(len(data["sid"])/2)])
				else:
					cprint(bcolors.YELLOW + x)
				time.sleep(0.2)
			else:
				if x is False:
					shamed.append(data["sid"][:int(len(data["sid"])/2)])
				return comm.generateData(queue, sessions, shamed)
		except Exception as e: 
			cprint(bcolors.YELLOW + str(e))
Example #3
0
def process(data, ws):
    """
	Process data from an incoming socket, and serve the result to everyone.
	"""
    global queue, sessions, socks, queuehash
    if data:
        # Parse the data through the socket command handler
        x = comm.parseData(queue, ws, socks, sessions, data)
        # Back up the queue
        if args.backup:
            json.dump(queue.queue,
                      open("cache.json", "w"),
                      indent=2,
                      sort_keys=True)
        # If the socket handler had an error, report it to the socket
        if x and type(x) is str:
            serve_connection(
                {
                    "action": "notification",
                    "title": "Failed to process data",
                    "text": x
                }, ws)
            color_print(x, color=ansi_colors.YELLOW)
        # If the queue changed, serve it
        if queuehash != hash(str(queue.queue)):
            queuehash = hash(str(queue.queue))
            serve_connections(comm.generateData(queue.serialize()), socks)
Example #4
0
def process(data, ws):
	"""
	Process data from an incoming socket, and serve the result to everyone.
	"""
	global queue, sessions, socks, queuehash
	if data:
		# Parse the data through the socket command handler
		x = comm.parseData(queue, ws, socks, sessions, data)
		# Back up the queue
		if args.backup:
			json.dump(queue.queue, open("cache.json", "w"), indent=2, sort_keys=True)
		# If the socket handler had an error, report it to the socket
		if x and type(x) is str:
			serve_connection({
					"action": "notification",
					"title": "Failed to process data",
					"text": x
				}, ws)
			color_print(x, color=ansi_colors.YELLOW)
		# If the queue changed, serve it
		if queuehash != hash(str(queue.queue)):
			queuehash = hash(str(queue.queue))
			serve_connections(comm.generateData(queue.serialize()), socks)