.HIDE. Add a bunch of <font>s

This commit is contained in:
Nyo 2016-06-02 19:07:33 +02:00
parent feee262ed1
commit 6c85995e53
4 changed files with 13 additions and 6 deletions

View File

@ -50,7 +50,6 @@ import traceback
class handler(requestHelper.asyncRequestHandler):
def asyncPost(self):
glob.meme.acquire()
try:
# Track time if needed
if glob.requestTime == True:
@ -69,6 +68,7 @@ class handler(requestHelper.asyncRequestHandler):
# No token, first request. Handle login.
responseTokenString, responseData = loginEvent.handle(self)
else:
userToken = None # default value
try:
# This is not the first packet, send response based on client's request
# Packet start position, used to read stacked packets
@ -78,8 +78,10 @@ class handler(requestHelper.asyncRequestHandler):
if requestTokenString not in glob.tokens.tokens:
raise exceptions.tokenNotFoundException()
# Token exists, get its object
# Token exists, get its object and lock it
userToken = glob.tokens.tokens[requestTokenString]
userToken.lock.acquire()
consoleHelper.printColored("[{}] locked".format(userToken.token), bcolors.YELLOW)
# Keep reading packets until everything has been read
while pos < len(requestData):
@ -166,6 +168,11 @@ class handler(requestHelper.asyncRequestHandler):
responseData += serverPackets.notification("Whoops! Something went wrong, please login again.")
consoleHelper.printColored("[!] Received packet from unknown token ({}).".format(requestTokenString), bcolors.RED)
consoleHelper.printColored("> {} have been disconnected (invalid token)".format(requestTokenString), bcolors.YELLOW)
finally:
# Unlock token
if userToken != None:
consoleHelper.printColored("[{}] unlocked".format(userToken.token), bcolors.GREEN)
userToken.lock.release()
if glob.requestTime == True:
# End time
@ -192,7 +199,6 @@ class handler(requestHelper.asyncRequestHandler):
discordBotHelper.sendConfidential(msg)
finally:
self.finish()
glob.meme.release()
def asyncGet(self):
html = "<html><head><title>MA MAURO ESISTE?</title><style type='text/css'>body{width:30%}</style></head><body><pre>"

View File

@ -5,7 +5,7 @@ from objects import channelList
from objects import matchList
import threading
VERSION = "0.9"
VERSION = "1.2"
db = None
conf = None
@ -17,4 +17,3 @@ memes = True
restarting = False
pool = None
requestTime = False
meme = threading.Lock()

View File

@ -7,6 +7,7 @@ from helpers import consoleHelper
from constants import bcolors
from constants import serverPackets
from events import logoutEvent
import threading
class token:
"""Osu Token object
@ -75,6 +76,7 @@ class token:
self.rank = userHelper.getRankPrivileges(self.userID)
self.loginTime = int(time.time())
self.pingTime = self.loginTime
self.lock = threading.Lock() # <-- Sync primitive
# Default variables
self.spectators = []

2
pep.py
View File

@ -184,7 +184,7 @@ if __name__ == "__main__":
glob.requestTime = generalFunctions.stringToBool(glob.conf.config["server"]["outputrequesttime"])
# Server start message and console output
discordBotHelper.sendConfidential("w00t p00t! (pep.py started)")
discordBotHelper.sendConfidential("**asyncppytornadovroom** Server started!")
consoleHelper.printColored("> Tornado listening for clients on 127.0.0.1:{}...".format(serverPort), bcolors.GREEN)
# Start tornado