• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Submission类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Submission的典型用法代码示例。如果您正苦于以下问题:Python Submission类的具体用法?Python Submission怎么用?Python Submission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: main

def main() :

    POST_LIMIT = 10
    STREAMING_SUBS = ['mlbstreams', 'nbastreams', 'soccerstreams'] #, 'nflstreams', 'nhlstreams', 'cfbstreams', 'ncaabballstreams', 'boxingstreams', 'mmastreams']
    
    db = DB.initialize(rebuild = False);

    # Connect to Reddit
    reddit_obj = Reddit.connect()

    # Create submissions and comments
    for sub in STREAMING_SUBS:
        submissions_with_comments = Reddit.scrape_posts(reddit_obj, sub, POST_LIMIT)
        Submission.create_with_comments(submissions_with_comments, db)
    
    # Parse comments for streams
    comment_data = Comment.get_all(db)
    stream_list = Reddit.parse_comments_for_streams(comment_data, db)
    
    # Create streams
    for stream in stream_list:
        Stream.create(stream, db)

    # Print the matches table from SQLite
    Submission.print_all(db)

    # Close the DB connection
    DB.close(db)
开发者ID:LouAlicegary,项目名称:reddit_streams,代码行数:28,代码来源:main.py


示例2: evaluate

def evaluate(source_code_name, user_id, task, contest):
    extension = get_extension(source_code_name)
    command = get_command(extension)
    contest_id = contest.contest_id

    os.system(command.format(DEST_FOLDER.format(contest_id) + source_code_name, DEST_FOLDER.format(contest_id) + remove_extension(source_code_name)))
    source_code_name = remove_extension(source_code_name)
    task_id = task.task_id
    status = True

    for input_file in os.listdir(INPUT_FOLDER.format(contest_id, task_id)):
        if get_extension(input_file) == 'zip': continue
        user_output = subprocess.check_output(DEST_FOLDER.format(contest_id) + source_code_name + "< " + INPUT_FOLDER.format(contest_id, task_id) + input_file, shell=True)
        user_output = re.sub('[\s+]\\n', '\n', user_output)
        user_output = user_output.strip()
        input_num = input_file.split('_')[1].split('.')[0]


        with open(OUTPUT_FOLDER.format(contest_id, task_id) + 'out_' + input_num + '.out') as f:
            output = f.read().strip()

        print 'worker'
        print 'output\n {} \n user_output\n {}'.format(output, user_output)        
        status = user_output == output        
    
    accepted = 'Accepted' if status else 'Wrong Answer'

    submission = Submission(accepted, extension, datetime.utcnow(), task.name, user_id, task.task_id, contest.contest_id)
    submission.save()
开发者ID:drakipovic,项目名称:Penguin,代码行数:29,代码来源:evaluator.py


示例3: submit

def submit(request):
    team = get_team(request.user)
    params = dict()

    if request.method == 'POST':
        form = forms.UploadSubmissionForm(request.POST, request.FILES)
        params['form'] = form

        if form.is_valid():
            submission = Submission(
                team=team,
                package=request.FILES['file'],
                command=request.POST['command'],
            )
            submission.save()

            error = utils.unzip(submission.package.path)
            if error:
                submission.delete()
                params['error'] = error
                return render_submit(request, params)

            try:
                execute_tester(submission)
            except Exception as error:
                print u'ERROR: Blad wewnetrzny testerki:', error
                

            return my_results(
                request, message=_(u'Rozwiązanie zostało wysłane.'))

    return render_submit(request, params)
开发者ID:ziarrek,项目名称:django-subeval,代码行数:32,代码来源:views.py


示例4: put_submission

	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,代码行数:8,代码来源:adaptive_base_handler.py


示例5: new_submission

def new_submission(assignment_id):
    assignment = Assignment.query.get(assignment_id)
    if request.method == 'POST' and 'file' in request.files:
        filename = submissions.save(request.files['file'])
        rec = Submission(
            filename=filename,
            is_official=False,
            assignment_id=assignment_id,
            user_id=g.user.id)
        rec.save()
        rec.officialize()
    return redirect(url_for('view_assignment', assignment_id=assignment_id))
开发者ID:ianonavy,项目名称:wpia,代码行数:12,代码来源:server.py


示例6: post

 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,代码行数:30,代码来源:main.py


示例7: save

def save(request):
    form = request.POST
    sub = Submission(
        user=form["user"],
        date=time.strftime("%Y-%m-%d %H:%M:%S"),
        language=form["language"],
        code=form["code"],
        input=form["input"],
    )
    try:
        sub["memory"] = form["memory"]
        sub["time"] = form["time"]
    finally:
        sub.save()
        return HttpResponse("OK")
开发者ID:StevenDavidWD,项目名称:OJ_Test,代码行数:15,代码来源:views.py


示例8: get

    def get(self, test):
        """Retrieve submissions for the current user."""
        
        self.response.content_type = "application/json"

        gplus_id = self.session.get("gplus_id")
        if gplus_id is None:
            self.response.status = 401
            self.response.out.write(utils.createError(401, "Current user not connected."))
            return

        if test is not None:
            user = ndb.Key("TestUser", gplus_id).get()
        else:
            user = ndb.Key("User", gplus_id).get()

        if user is None:
            self.response.status = 401
            self.response.out.write(utils.createError(401, "Current user not connected."))
            return

        items = []
        submissions = Submission.query(ancestor=user.key).order(-Submission.date).fetch(50)
        for submission in submissions:
            items.append({
              "id": submission.key.id(),
              "colour": submission.colour,
              "url": submission.url,
              "date": submission.date.strftime("%Y-%m-%dT%H:%M:%S.%f")
            })
        
        self.response.out.write(json.dumps({"items": items}))        
开发者ID:babus,项目名称:mirror-api,代码行数:32,代码来源:service.py


示例9: get_level_stats

    def get_level_stats(self, format, delta = datetime.timedelta(), page = 0, limit = 100):
        level = get_current_level()
            
        if level is not None:
            submissions = Submission.all().filter("time >", level.time - delta).order('time').order('-score').fetch(limit, page * limit)

            i = 1
            ranks = []
            for submission in submissions:
                obj = {"rank" : i,
                      "user" : submission.user.name,
                      "score" : submission.score}
                
                if format == "json":
                    ranks.append(obj)
                elif format == "xml":
                    ranks.append({"ranking": obj})
                
                i = i + 1
            
            res = {"response": ranks}
        else :
            res = {"response": {"error": "could not get the level"}}
            
        if format == "json":
            return simplejson.dumps(res)
        elif format == "xml":
            return dict2xml(res).to_string()
开发者ID:akawry,项目名称:seekword,代码行数:28,代码来源:main.py


示例10: upload_file

def upload_file():
    title = request.form['song']
    artist = request.form['artist']
    picture_file = request.files['file']
    photo = Photo()
    photo.file.put(picture_file)
    photo.save()

    track = Track.get_from_spotify(artist, title)
    if track is None:
        return "No track found!"
    track.save()

    submission = Submission(photo=photo, track=track)
    submission.save()

    return redirect('/submissions')
开发者ID:diversify,项目名称:beautiful-world,代码行数:17,代码来源:web.py


示例11: get_all_attempts

 def get_all_attempts(self, magic, level, problemid, prob_type):
     return (
         Submission.all()
         .filter("student_magic_number =", str(magic))
         .filter("type =", str(prob_type))
         .filter("level =", level)
         .filter("problem_id =", problemid)
     )
开发者ID:jhopwood,项目名称:Adaptive-Cs233-Branch,代码行数:8,代码来源:base_handler.py


示例12: _save_submission

	def _save_submission(self,request):
		def get_type(request):
			try:
				return FacilityType.objects.get(name=request.POST['type'])
			except KeyError:
				return None
		
		submit_args = {
				'submitter':request.user,
				'raw':repr(request.POST),
				'name':request.POST.get('name',None),
				'address':request.POST.get('address',None),
				'type':get_type(request),
				'location':get_location(request.POST)
			}
		submission = Submission(**submit_args)
		submission.save()
		return submission
开发者ID:global-health-bridge,项目名称:HealthcareFacilityMapping,代码行数:18,代码来源:rest_views.py


示例13: get

 def get(self):
   magic = self.request.get('student')
   submissions = Submission.all().filter('student_magic_number =', str(magic))
   submissions_objects = []
   for submission in submissions:
      utc = int(time.mktime(submission.answered_on.timetuple()))
      submissions_objects.append({"type":submission.type, "level":submission.level, "id":submission.problem_id, "score":submission.score, "answered_on":utc, "answer":submission.answer})
   blob = json.dumps(submissions_objects)
   self.response.out.write(blob)
开发者ID:mansara2,项目名称:cache,代码行数:9,代码来源:main.py


示例14: update_group

    def update_group(self, key):
        if not auth.logged_in():
            return self.redirect('/groups')
        
        user = auth.current_user()
        group = Group.get(key)
        if group.owner.user_id() != user.user_id() and not auth.user_is_admin():
            Messages.add('Only the owner of the group owner may modify it')
            return self.redirect('/groups')
        
        name = self.request.get('name')
        public = self.request.get('public') == 'public'
        abandon = self.request.get('abandon-project')
        sub_text = self.request.get('submission-text')
        sub_url = self.request.get('submission-url')
        remove_submission = self.request.get_all('remove-submission')
        remove = self.request.get_all('remove')
        owner = self.request.get('owner')
        delete = self.request.get('delete')
        
        if delete:
            group.delete()
            return self.redirect('/groups')
        
        group.name = name
        group.public = public
        
        if abandon:
            group.project = None
        
        if sub_text and sub_url:
            Submission(text=sub_text, url=sub_url, group=group).put()

        for sub in Submission.get(remove_submission):
            sub.delete()

        pending  = list(group.pending_users)
        for user in pending:
            approve = self.request.get("approve-%s" % user)
            if approve == "approve":
                group.members.append(user)
                group.pending_users.remove(user)
            elif approve == "refuse":
                group.pending_users.remove(user)
        
        group.owner = auth.user_from_email(owner)
        
        for user in remove:
            if auth.user_from_email(user) == group.owner:
                Messages.add('Cannot remove the group owner')
                return self.redirect('/groups/%s/edit' % key)
            else:
                group.members.remove(auth.user_from_email(user))
        
        group.put()
        return self.redirect('/groups/%s' % key)
开发者ID:DanAlbert,项目名称:d20mgr,代码行数:56,代码来源:back.main.py


示例15: get

	def get(self):
		submissions = []
		#subs= Submission.gql("WHERE pid=:1", 11)
		for submission in Submission.all().order('-post_time'):
			submissions.append({
				'name': submission.name,
				'pid': submission.pid,
				'image_url': submission.image_url,
            })
        	self.response.out.write(json.dumps(submissions))
开发者ID:jonkiersey,项目名称:clupics,代码行数:10,代码来源:main.py


示例16: post_queue_copytoava

def post_queue_copytoava():
    if (not request.json) or (not 'queueId' in request.json):
        abort(400)
    if (not 'avaQueueId' in request.json):
        abort(400)

    q_id = int(request.json['queueId'])
    aq_id = int(request.json['avaQueueId'])
    # Get the queue information
    queue = Queue.query.filter(Queue.id == q_id).first()
    ava_queue = Queue.query.filter(Queue.id == aq_id).first()

    if not queue:
        abort(404)

    if not ava_queue:
        abort(404)

    # Check if queue is a scheduled queue
    if queue.qType != 2:
        abort(403)

    if ava_queue.qType != 1:
        abort(403)

    # Submit to queue using normal submission function
    subs = queue.submissions
    subs_to_remove = ava_queue.submissions
    for sub in subs_to_remove:
        db.session.delete(sub)
    db.session.commit()
    ava_subs = []
    for sub in subs:
        ava_sub = Submission()
        ava_sub.ava_clone(sub, ava_queue)
        db.session.add(ava_sub)
        ava_subs.append(ava_sub)
    db.session.commit()
    # Create match to be scheduled
    for p, q in itertools.combinations(ava_subs,2):
        match = schedule_match(ava_queue, p, q, test=False)

    return jsonify({'done': True}), 201
开发者ID:lazerwalker,项目名称:kernkrieg,代码行数:43,代码来源:api.py


示例17: judgeProblem

def judgeProblem(request, name):
	if not request.user.is_authenticated():
		return HttpResponse("Please log in to submit your solution.")

	language = request.POST.get('language')
	sourceCode = request.POST.get('editor')
	problem = Problem.objects.get(name=name)

	inputString = problem.standardInput
	outputString = problem.expectedOutput.replace('\r', '')
	
	result = judge.subprocessJudge(sourceCode, language, inputString, outputString)
	resultTuple = status.resultCodeToText(result)
	
	if resultTuple:
		s = Submission(user=request.user, problem=problem, result=resultTuple[0],
			sourceCode=sourceCode, language=language)
		s.save()
		resultText = resultTuple[1]
		return HttpResponse(resultText)
	else:
		return HttpResponse("Invalid response. Something went wrong!")
开发者ID:guth,项目名称:secret-bear,代码行数:22,代码来源:views.py


示例18: handle

    def handle(self, sms):
        """Método chamado pelo RapidSMS para processar uma mensagem"""
        sub_type = Submission.TYPE_SMS  # estamos organizando as outras branchs do projeto
        answer = Config.get("message_unknown_format")

        if Submission.has_confirmation_pending(sms.connection.identity):
            submission = Submission.get_unconfirmed(sms.connection.identity)
            answer = submission.confirm(sms.text)
            return self.send_answer(sms, answer)

        if Form.main_form_exists():
            form = Form.get_main_form()

        else:
            keyword, separator, remaining_message = Form.extract_keyword(sms.text)
            sms.text = remaining_message
            form = Form.get_by_keyword_and_separator(keyword, separator)

        if form:
            answer = form.process_submission(sms, sub_type) or answer

        return self.send_answer(sms, answer)
开发者ID:institutotim,项目名称:resposta-rapida,代码行数:22,代码来源:app.py


示例19: submit

def submit(request):
    team = request.user.team
    params = dict()

    if request.method == 'POST':
        form = UploadSubmissionForm(request.POST, request.FILES)
        params['form'] = form

        if form.is_valid():
            submission = Submission(
                team=team,
                package=request.FILES['file'],
                user=request.user,
            )
            submission.save()

            error = utils.unzip(submission.package.path)
            if error:
                submission.delete()
                params['error'] = error
                return render_submit(request, params)

            submissions = team.submission_set.all()
            if len(submissions) > 2:
                for sub in submissions[2:]:
                    sub.delete()

            execute_tester(submission)
            messages.add_message(request, messages.INFO, _(u'Rozwiązanie zostało wysłane'))
            return redirect('my_results')
            #return my_results(
            #    request, message=_(u'Rozwiązanie zostało wysłane.'))
        else:
            print form.errors

    return render_submit(request, params)
开发者ID:ktalik,项目名称:django-subeval,代码行数:36,代码来源:views.py


示例20: _addSubmission

	def _addSubmission(self, request):
		user = endpoints.get_current_user()
		if not user:
			raise endpoints.UnauthorizedException("Please login to continue")
		data = {field.name: getattr(request, field.name) for field in request.all_fields()}
		q_key = ndb.Key(urlsafe=request.websafekey)
		del data['websafekey']
		s_id = Submission.allocate_ids(size = 1, parent=q_key)[0]
		s_key = ndb.Key(Submission, s_id, parent=q_key)
		data['key'] = s_key
		data['user'] = user
		data['subskey'] = s_key.urlsafe()
		Submission(**data).put()
		return SubmissionForm(code=data['code'], score=data['score'], 
						language=data['language'])
开发者ID:codegress,项目名称:code-gress,代码行数:15,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Subscription类代码示例发布时间:2022-05-27
下一篇:
Python models.Student类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap