def getSessionKey(self): t = time.localtime() today = Date(t.tm_year, t.tm_mon, t.tm_mday) # for each character in openid sessionKey = "" for c in self.openid: asc = ord(c) sessionKey += chr((asc+1) * 2 % 128) sessionKey += chr(today.getCheckCode()) return sessionKey
def handleSendQuestionTime(): date = Date.fromRequest(request) if not date.checkCode(): return CODE_ERROR questionPath = date.getQuestionPath() return str(int(os.path.getmtime(questionPath)))
def checkQuestion(): date = Date.fromRequest(request) user = User.fromRequest(request) days = DaysRecord() if date.checkCode(): if days.check(date): fileName = date.toString() + "." + days.getFormat(date) return {"f": fileName, "s": user.getSessionKey()} return FIND_QUESTION_ERROR else: return CODE_ERROR
def handleSubmitPicture(): """ submit the user's clock picture from request :return: """ try: user = User.fromRequest(request) submitDate = Date.fromRequest(request) todayDate = Date.fromRequest(request, key="today") picture = Picture.fromRequest(request) filePath = user.getClockPicturePath(submitDate, picture.format) picture.save(filePath) lock = current_app.describeLock saveClockDescription(lock, user, submitDate, todayDate, picture.format) except Exception as e: print("[ERROR] in app.route(routes.clockPicture): ", e) return SERVER_ERROR else: return PICTURE_RECEIVED
def handleSubmitQuestion(): """ The Manager submit one day's question :return: """ current_app.datesLock.acquire() # user = User.fromRequest(request) date = Date.fromRequest(request) days = DaysRecord() picture = Picture.fromRequest(request) savePath = date.getQuestionPath(picture.format) picture.save(savePath) days.add(date, picture.format) days.save() current_app.datesLock.release() return PICTURE_RECEIVED
def handleGetAllDays(): date = Date.fromRequest(request) days = DaysRecord() if not date.checkCode(): return CODE_ERROR return "/".join(days.days)
def handleTimeSwap(): date = Date.fromRequest(request) if not date.checkCode(): return CODE_ERROR fileTime = os.path.getmtime(date.getQuestionPath()) return fileTime
from WePro.until.User import User from WePro.until.Date import Date from WePro.tool.saveClockDescription import saveClockDescription from WePro.until.Lock import Lock import threading lock = Lock.getFileLock('description') user = User("oF7S25CRBHEe_iOoVwJ7ntQPpo5o") date = Date(2020, 7, 30) class TestThreading(threading.Thread): def __init__(self): super().__init__() def run(self): saveClockDescription(lock, user, date, 'jpg')