当前位置: 首页>>代码示例>>Python>>正文


Python HelperFunctions.toUtcTimestamp方法代码示例

本文整理汇总了Python中HelperFunctions.toUtcTimestamp方法的典型用法代码示例。如果您正苦于以下问题:Python HelperFunctions.toUtcTimestamp方法的具体用法?Python HelperFunctions.toUtcTimestamp怎么用?Python HelperFunctions.toUtcTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HelperFunctions的用法示例。


在下文中一共展示了HelperFunctions.toUtcTimestamp方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: publishFeedToUser

# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import toUtcTimestamp [as 别名]
 def publishFeedToUser(self,fromUid ,  user, _type, message, message2):
     f = Feed()
     f.fromUid = fromUid
     f.type = _type
     f.message = message
     if(message2!=None):
         f.message2 = message2
     f.timestamp = HelperFunctions.toUtcTimestamp(datetime.datetime.now())
     f.save()
     
     userFeed = UserFeed()
     userFeed.uidFeedIndex= user.uid+"_"+str(user.userFeedIndex.getAndIncrement(user).index)
     userFeed.feedMessage = f
     userFeed.save()
开发者ID:shalintripathi,项目名称:QuizApp_server,代码行数:16,代码来源:Db.py

示例2: publishFeed

# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import toUtcTimestamp [as 别名]
 def publishFeed(self, user, _type ,  message, message2=None):
     f = Feed()
     f.fromUid = user.uid
     f.message = message
     f.type = _type
     if(message2!=None):
         f.message2 = message2
     f.timestamp = HelperFunctions.toUtcTimestamp(datetime.datetime.now())
     f.save()
     #### move to tasks other server if possible
     for uid in user.subscribers:
         user = self.getUserByUid(uid)
         userFeed = UserFeed()
         userFeed.uidFeedIndex = uid+"_"+str(user.userFeedIndex.getAndIncrement(user).index)
         userFeed.feedMessage = f
         userFeed.save()
开发者ID:shalintripathi,项目名称:QuizApp_server,代码行数:18,代码来源:Db.py

示例3: getAllUpdates

# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import toUtcTimestamp [as 别名]
def getAllUpdates(response, user=None):
    isLogin = response.get_argument("isLogin",False)
    isFistLogin =  response.get_argument("isFirstLogin",False)
    lastOfflineChallengeIndex = int(response.get_argument("lastOfflineChallengeIndex",0));
    retObj = {"messageType":OK_UPDATES,
                               "payload7":user.toJson(),
                               "payload3":"["+','.join(map(lambda x:x.to_json(),dbUtils.getRecentUserFeed(user)))+"]",
                               "payload5":"["+','.join(map(lambda x:x.to_json(),dbUtils.getUserChallenges(user , fromIndex=lastOfflineChallengeIndex)))+"]"
                               }
    if(isLogin):
        quizzes = None
        categories= None
        badges = None
        userMaxQuizTimestamp = response.get_argument("maxQuizTimestamp",None)
        if(userMaxQuizTimestamp):
            userMaxQuizTimestamp = datetime.datetime.utcfromtimestamp(float(userMaxQuizTimestamp)+1)
            quizzes = dbUtils.getAllQuizzes(userMaxQuizTimestamp)
            categories = dbUtils.getAllCategories(userMaxQuizTimestamp)
            retObj["payload"]="["+','.join(map(lambda x:x.toJson() , quizzes ))+"]"
            retObj["payload1"] ="["+','.join(map(lambda x:x.toJson() , categories ))+"]"
            
        userMaxBadgesTimestamp = response.get_argument("maxBadgesTimestamp",None)
        if(userMaxBadgesTimestamp):
            userMaxBadgesTimestamp = datetime.datetime.utcfromtimestamp(max(0,float(userMaxBadgesTimestamp)+1))
            badges = dbUtils.getNewBadges(userMaxBadgesTimestamp)
            retObj["payload2"] = "["+",".join(map(lambda x:x.toJson(),badges))+"]"

        retObj["payload6"]=json.dumps({server.serverId : server.addr for server in routerServer.servers.values()})#id:serveraddr
     
    if(isFistLogin):
        retObj["payload8"]= json.dumps(dbUtils.getPeopleWithWhomUserConversed(user))
    
    
    recentMessages = None
    lastSeenTimestamp = response.get_argument("lastSeenTimestamp",None)
    if(lastSeenTimestamp):
        lastSeenTimestamp = datetime.datetime.utcfromtimestamp(float(lastSeenTimestamp))
        recentMessages = "["+','.join(map(lambda x:x.to_json(),dbUtils.getRecentMessagesIfAny(user, lastSeenTimestamp)))+"]"
        retObj["payload4"] = recentMessages #unseen messages if any
        
    retObj["payload10"] = json.dumps({"serverTime":HelperFunctions.toUtcTimestamp(datetime.datetime.now())})
    responseFinish(response, retObj)
    if(isLogin):
        #every time user logs in lets increment the index
        dbUtils.incrementLoginIndex(user)
开发者ID:abhinavabcd,项目名称:QuizApp_server,代码行数:47,代码来源:server.py

示例4: initAppConfig

# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import toUtcTimestamp [as 别名]
def initAppConfig(response , user=None):
    responseFinish(response,{"messageType":OK, "payload1":json.dumps({"serverTime":HelperFunctions.toUtcTimestamp(datetime.datetime.now())})})
开发者ID:shalintripathi,项目名称:QuizApp_server,代码行数:4,代码来源:server.py

示例5: open

# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import toUtcTimestamp [as 别名]
        def open(self, user=None):
            # print self.request.arguments
            runningQuizId = self.get_argument("isRunningQuiz", None)
            self.isChallenge = isChallenge = self.get_argument("isChallenge", None)  # uid of other user
            self.isChallenged = isChallenged = self.get_argument("isChallenged", None)  # uid of the first user
            quizId = self.get_argument("quizId")
            if runningQuizId:
                pass

            self.quiz = quiz = dbUtils.getQuizDetails(quizId)
            self.quizPoolWaitId = quizPoolWaitId = "_".join(quiz.tags) + "_" + str(quiz.nPeople)
            self.user = user
            self.uid = user.uid
            if isChallenge != None:
                self.quizPoolWaitId = quizPoolWaitId = self.user.uid + "_" + HelperFunctions.generateKey(10)
            elif isChallenged != None:
                self.quizPoolWaitId = quizPoolWaitId = isChallenged

            quizConnections = quizWaitingConnectionsPool.get(quizPoolWaitId, None)
            if quizConnections:
                quizConnections.append(self)
            else:
                if not isChallenged:  # not challenge type , so we add insert into new pool
                    quizConnections = quizWaitingConnectionsPool[quizPoolWaitId] = [self]
                else:  # is challenged then user have definitely left
                    self.write_message(json.dumps({"messageType": USER_HAS_LEFT_POOL}))
                    return  # client should close connection after this

            self.quizConnections = quizConnections
            # print self.user
            # print self.uid
            # print self.quizConnections
            if isChallenge != None:  # send notification to other user
                addToGcmQueue(
                    self.isChallenge,
                    {
                        "fromUser": self.uid,
                        "fromUserName": self.user.name,
                        "quizPoolWaitId": self.quizPoolWaitId,
                        "serverId": Config.serverId,
                        "quizId": quiz.quizId,
                        "quizName": quiz.name,
                        "messageType": NOTIFICATION_GCM_CHALLENGE_NOTIFICATION,
                        "timeStamp": HelperFunctions.toUtcTimestamp(datetime.datetime.now()),
                    },
                )

            if len(quizConnections) >= int(quiz.nPeople):  # we have enough people
                self.quizConnections = [
                    quizConnections.pop() for i in range(0, quiz.nPeople)
                ]  # nPeople into current quiz
                uids = map(lambda x: x.uid, self.quizConnections)
                _runningQuizId, _runningQuiz = generateProgressiveQuiz(quiz.quizId, uids)
                for conn in self.quizConnections:
                    conn.runningQuizId = _runningQuizId
                    conn.runningQuiz = _runningQuiz
                    if conn != self:
                        conn.quizConnections = self.quizConnections
                # question_one = self.runningQuiz[QUESTIONS][0]
                self.broadcastToAll(
                    {
                        "messageType": LOAD_QUESTIONS,
                        "payload": self.runningQuizId,
                        "payload1": "[" + ",".join(map(lambda uid: dbUtils.getUserByUid(uid).toJson(), uids)) + "]",
                        "payload2": "[" + ",".join(map(lambda x: x.to_json(), self.runningQuiz[QUESTIONS])) + "]",
                    },
                    self.quizConnections,
                )
开发者ID:cuong48d,项目名称:QuizApp_server,代码行数:70,代码来源:ProgressiveQuizHandler.py

示例6: to_json

# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import toUtcTimestamp [as 别名]
 def to_json(self):
     son = self.to_mongo()
     del son["fromUid_LoginIndex"]
     del son["toUid_LoginIndex"]
     son["timestamp"] = HelperFunctions.toUtcTimestamp(self.timestamp)
     return bson.json_util.dumps(son)
开发者ID:shalintripathi,项目名称:QuizApp_server,代码行数:8,代码来源:Db.py

示例7: toJson

# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import toUtcTimestamp [as 别名]
 def toJson(self):
     sonObj = self.to_mongo()
     sonObj["tags"] = bson.json_util.dumps(self.tags)
     sonObj["modifiedTimestamp"] = HelperFunctions.toUtcTimestamp(self.modifiedTimestamp)
     return bson.json_util.dumps(sonObj)
开发者ID:shalintripathi,项目名称:QuizApp_server,代码行数:7,代码来源:Db.py


注:本文中的HelperFunctions.toUtcTimestamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。