當前位置: 首頁>>代碼示例>>Python>>正文


Python Submission.put方法代碼示例

本文整理匯總了Python中models.Submission.put方法的典型用法代碼示例。如果您正苦於以下問題:Python Submission.put方法的具體用法?Python Submission.put怎麽用?Python Submission.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Submission的用法示例。


在下文中一共展示了Submission.put方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import put [as 別名]
 def post(self):
     
     format = self.request.get('format', 'json').lower()
     id = self.request.get('level_id', None)
     if id is None:
         res = {"response": {"error": "no level id with submission"}}
     else:
         level = Level.get_by_id(long(id))
         user_name = self.request.get('user')
         user = User.all().filter('name =', user_name).get()
         if user is None:
             user = User(name = user_name)
             user.put()
         score = self.request.get('score', 0)
         words_found = self.request.get('words_found').split(",")
              
         submission = Submission()
         submission.user = user
         submission.level = level
         submission.score = score
         submission.words_found = words_found
         submission.time = datetime.datetime.now()
         submission.put()
         
         res = {"response": {"status" : "OK"}}
     
     if format == "json":
         self.response.out.write(simplejson.dumps(res))
     elif format == "xml":
         self.response.out.write(dict2xml(res).to_string())
開發者ID:akawry,項目名稱:seekword,代碼行數:32,代碼來源:main.py

示例2: put_submission

# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import put [as 別名]
	def put_submission(self, problem_name, level, score, answer):
		submission = Submission(student_magic_number = self.magic,
								problem_id = self.problem_id, answer = answer,
								score = score, type = problem_name, level = level)
		# logging.warn("submit: %s %s %s %s %s %s" % (self.magic, self.problem_id, answer, score, problem_name, level))
		submission.put()
		self.increment_number_of_attempts(self.magic, self.level, self.problem_id, problem_name)
		self.best_score(self.magic, self.level, self.problem_id, problem_name, score)
開發者ID:jhopwood,項目名稱:Adaptive-Cs233-Branch,代碼行數:10,代碼來源:adaptive_base_handler.py

示例3: post

# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import put [as 別名]

#.........這裏部分代碼省略.........
        a = numpy.asarray(i, int)

        R, G, B = a.T

        m = numpy.min(a, 2).T
        M = numpy.max(a, 2).T

        #Chroma
        C = M - m
        Cmsk = C != 0

        # Hue
        H = numpy.zeros(R.shape, int)
        mask = (M == R) & Cmsk
        H[mask] = numpy.mod(60*(G-B)/C, 360)[mask]
        mask = (M == G) & Cmsk
        H[mask] = (60*(B-R)/C + 120)[mask]
        mask = (M == B) & Cmsk
        H[mask] = (60*(R-G)/C + 240)[mask]

        # Value
        V = M

        # Saturation
        S = numpy.zeros(R.shape, int)
        S[Cmsk] = ((255*C)/V)[Cmsk]

        mask = (V > 100) & (S > 100)

        count = {}
        for col in COLORS:
            count[col] = 0
            v1 = COLORS[col]["min"]
            v2 = COLORS[col]["max"]
            if (v1 < 0):
                col_mask = ((H < v2) | (H > 360 + v1)) & mask
            else:
                col_mask = ((H > v1) & (H < v2)) & mask
            Col = numpy.zeros(R.shape, int)
            Col[col_mask] = numpy.ones(R.shape, int)[col_mask]
            count[col] = numpy.count_nonzero(Col)

        sum = 0
        for col in count:
            if count[col] < 1000:
                count[col] = 0
            else:
                sum = sum + count[col]
        
        if sum == 0:
            item["text"] = "No colours recognized."
            service.timeline().update(id=item_id, body=item).execute()
            return

        recognized = []
        correct = False
        task = user.currentTask
        for col in count:
            count[col] = count[col] * 100 / sum
            if count[col] > 40:
                if col == task:
                    correct = True
                    break
                recognized.append(col)

        if correct:
            item["text"] = "Congratulations!"
            service.timeline().update(id=item_id, body=item).execute()
            user.currentTask = None
            user.put()
            
            # Insert submission
            file_name = files.blobstore.create(mime_type=content_type)
            with files.open(file_name, 'a') as f:
                f.write(content)
            files.finalize(file_name)
            blob_key = files.blobstore.get_blob_key(file_name)
            url = get_serving_url(blob_key, secure_url=True, size=640)

            submission = Submission(colour=task,
                                    hue=COLORS[task]["hue"],
                                    blobkey=blob_key,
                                    url=url,
                                    parent=user.key)
            submission.put()
            
            # TODO: Update scores/achievements
            
            # Create next task
            taskqueue.add(url="/tasks/createtask",
                          params={"user": gplus_id, "test": test},
                          method="POST")
        
        else:
            if len(recognized) == 0:
                item["text"] = "No colours recognized."
            else:
                item["text"] = "Recognized " + ", ".join(recognized) + " but your current task is " + user.currentTask

            service.timeline().update(id=item_id, body=item).execute()
開發者ID:MarcosBermudez,項目名稱:mirror-api,代碼行數:104,代碼來源:tasks.py


注:本文中的models.Submission.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。