コード例 #1
0
ファイル: index.py プロジェクト: gmanika/sc2share.com
    def post(self):
        upload_files = self.get_uploads('file')  # 'file' is file upload field in the form
	if not upload_files:
		self.redirect('/failed/nofile/')
		return
        blob_info = upload_files[0]
	key = blob_info.key()
	if blob_info.size > 1048576:
		blob_info.delete()
	        self.redirect('/failed/sizeerror/%s' % blob_info.filename)
		return
	blob_reader = blobstore.BlobReader(key)
	magic = blob_reader.read(50)
	if magic[0:3] != "MPQ" or not "StarCraft II replay" in magic:
		blob_info.delete()
	        self.redirect('/failed/typeerror/%s' % blob_info.filename)
		return


	replayid = counter_as_string('principal')
	increment('principal')

	m = md5()
	m.update(blob_reader.read(blob_info.size))
	replaymd5 = m.hexdigest()
	
	replay = Replay(replayid=replayid, replaymd5 = replaymd5, blobinfo = str(key), ip=self.request.remote_addr)
	replay.put()

        self.redirect('/success/%s' % replayid)
コード例 #2
0
ファイル: db.py プロジェクト: galuano1/twitalkerplus
 def add(jid):
   counter.increment('total')
   shard = counter.get_count('total') % config.CRON_NUM
   google_user = GoogleUser(key_name=jid, shard=shard, last_update=int(time.time()))
   google_user.jid = jid
   Db.set_datastore(google_user)
   return google_user
コード例 #3
0
ファイル: handlers.py プロジェクト: moefang/nacelle
    def get_context(self, counter_name):

        """
        Increment and return the specified counter's value
        """

        # increment the specified counter
        counter.increment(counter_name)
        # get the counter value
        hit_count = counter.get_count(counter_name)
        # return the counter value as JSON object
        return {'count': hit_count}
コード例 #4
0
ファイル: index.py プロジェクト: gmanika/sc2share.com
	def get(self, resource, extension):
		query = Replay.all()
		query.filter('replayid =', resource)

		results = query.fetch(1)

		if results:
			result = results[0]
			blob_info = blobstore.BlobInfo.get(result.blobinfo)
			increment(resource)
			self.send_blob(blob_info)
			return
コード例 #5
0
ファイル: tests.py プロジェクト: avastjohn/maventy_new
 def test1(self):
   name = "foo"
   assert counter.get_count(name) == 0
 
   counter.increment(name)
   assert counter.get_count(name) == 1
 
   counter.increment(name, 3)
   assert counter.get_count(name) == 4
 
   counter.set_value(name, 2)
   assert counter.get_count(name) == 2
コード例 #6
0
ファイル: __init__.py プロジェクト: d2m/tailbone
  def set_or_create(self, model, id, parent_key=None):
    u = current_user(required=True)
    if model == "users":
      if not (id == "me" or id == "" or id == u):
        raise AppError("Id must be the current " +
                       "user_id or me. User {} tried to modify user {}.".format(u, id))
      id = u
      cls = users
    else:
      cls = type(model.lower(), (ScopedExpando,), {})
    data = parse_body(self)
    key = parse_id(id, model, data.get("Id"))
    clean_data(data)
    validate(cls.__name__, data)
    already_exists = False
    if key:
      old_model = key.get()
      if old_model:
        if model != "users" and not old_model.can_write(u):
          raise AppError("You do not have sufficient privileges.")
        already_exists = True

    # TODO: might want to add this post creation since you already have the key
    if parent_key:
      data[parent_key.kind()] = parent_key.urlsafe()

    m = reflective_create(cls, data)
    if key:
      m.key = key
    if model != "users":
      if len(m.owners) == 0:
        m.owners.append(u)
    m.put()
    # increment count
    if not already_exists and store_metadata:
      increment(model)
    # update indexes
    search.put(m)
    redirect = self.request.get("redirect")
    if redirect:
      self.redirect(redirect)
      # Raising break error to avoid header and body writes from @as_json decorator since we override as a redirect
      raise BreakError()
    return m.to_dict()
コード例 #7
0
 def get(self):
     value = int(self.request.get('id'))
     cookie = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"])
     voteNumber = 0;
     if cookie:
         if "LastVote" in cookie:
             if int(cookie["LastVote"].value) != 0:
                 voteNumber = int(cookie["LastVote"].value);
                 stringOfCounter = 'IdeaWIVG_' + str(value);
                 stringOfCounterD = 'IdeaWIVG_' + str(voteNumber) + 'D';
                 counter.increment(stringOfCounter)
                 counter.increment(stringOfCounterD)
             else:
                 stringOfCounter = 'IdeaWIVG_' + str(value);
                 counter.increment(stringOfCounter)
         else:
             stringOfCounter = 'IdeaWIVG_' + str(value);
             counter.increment(stringOfCounter)
     NameOfVoted = "";
     if (value ==1):
         NameOfVoted  = "My Eyes"
     elif (value ==2):
         NameOfVoted  = "Furball Fury"
     elif (value ==3):
         NameOfVoted  = "Lux"
     elif (value ==4):
         NameOfVoted  = "Air Rocky"
     elif (value ==5):
         NameOfVoted  =  "Afterlife Empire"
     template = JINJA_ENVIRONMENT.get_template('WIVGVote.jinja')
     template_values = {
         "voteName": NameOfVoted,
         "voteValue": value,
         "Amount1":counter.get_count('IdeaWIVG_1')-counter.get_count('IdeaWIVG_1D'),
         "Amount2":counter.get_count('IdeaWIVG_2')-counter.get_count('IdeaWIVG_2D'),
         "Amount3":counter.get_count('IdeaWIVG_3')-counter.get_count('IdeaWIVG_3D'),
         "Amount4":counter.get_count('IdeaWIVG_4')-counter.get_count('IdeaWIVG_4D'),
         "Amount5":counter.get_count('IdeaWIVG_5')-counter.get_count('IdeaWIVG_5D'),
     }
     self.response.out.write(template.render(template_values))
コード例 #8
0
ファイル: app.py プロジェクト: haldun/optimyser2
 def get(self):
   selected = self.get_selected()
   if selected is None:
     return
   counter.increment('%s:%s:conversion' % (self.experiment.key().name(), selected))
   self.write('1')
コード例 #9
0
 def get(self):
     user = users.get_current_user()
     if user:
         submission =  Idea_VideoGameW1.get(Idea_VideoGameW1_key(user.user_id()))
         template = JINJA_ENVIRONMENT.get_template('ideaWIVG.jinja')
         if (submission==None):
             counter.increment('IdeaWIVG1')
             
             submission = Idea_VideoGameW1(key=Idea_VideoGameW1_key(user.user_id()))
             submission.put()
             quickGet = Idea_QuickGet(key=Idea_QuickGet_key(counter.get_count('IdeaWIVG1')))
             quickGet.link = submission
             quickGet.put()
        
         a = ''
         b = ''
         c = ''
         d = ''
         e = ''
         f = ''
         z = False
         y = False
         if submission.legal1:
             a='checked'
         if submission.legal2:
             b='checked'
         if submission.legal3:
             c='checked'
         if submission.review:
             d='checked'
         if submission.comment:
             e='checked'
         if submission.visible:
             f='checked'
         if submission.visible:
             y='checked'
         template_values = {
         "name": submission.name,
         "namePerson":submission.namePerson,
         "tagline": submission.tagline,
         "genres": submission.genres,
         "describe": submission.describe,
         "original": submission.original,
         "look": submission.look,
         "who": submission.who,
         "email": submission.email,
         "additionalInfo": submission.additionalInfo,
         "residenceStatus": submission.residenceStatus,
         "legal1": a,
         "legal2": b,
         "legal3": c,
         "review": d,
         "legal4": y,
         "comment": e,
         "showIt": f,
         "justSaved":z,
         
         }
         
         
         self.response.out.write(template.render(template_values))
     
     else:
         url = '/submitIdea'
         self.response.out.write('''<meta http-equiv="refresh" content="0; url=%s" />''' % users.create_login_url(url));
コード例 #10
0
    def post(self):
        user = users.get_current_user()
        if user:
            submission =  Idea_VideoGameW1.get(Idea_VideoGameW1_key(user.user_id()))
            if (submission==None):
                counter.increment('IdeaWIVG1')
                submission = Idea_VideoGameW1(key=Idea_VideoGameW1_key(user.user_id()))
                submission.put()
                quickGet = Idea_QuickGet(key=Idea_QuickGet_key(counter.get_count('IdeaWIVG1')))
                quickGet.link = submission
                quickGet.put()
            submission.name=self.request.get('name')
            submission.tagline=self.request.get('tagline')
            submission.genres=self.request.get('genres')
            submission.describe=self.request.get('describe')
            submission.original=self.request.get('original')
            submission.look=self.request.get('look')
            submission.namePerson=self.request.get('namePerson')
            submission.who=self.request.get('who')
            submission.email=self.request.get('email')
            submission.additionalInfo=self.request.get('additionalInfo')
           
            
            submission.residenceStatus=self.request.get('residenceStatus')
            submission.legal1=False;
            submission.legal2=False;
            submission.legal3=False;
            submission.legal4=False;
            submission.review = False;
            submission.comment = False;
            submission.visible = False;
            
            a = ''
            b = ''
            c = ''
            d = ''
            e = ''
            f = ''
            y = ''
            z = True
            
            
            
            if self.request.get('legal1'):
                submission.legal1 = True;
                a = 'checked'
            if self.request.get('legal2'):
                b = 'checked'
                submission.legal2 = True;
            if self.request.get('legal3'):
                c = 'checked'
                submission.legal3 = True;
            if self.request.get('review'):
                d = 'checked'
                submission.review = True;
            if self.request.get('comment'):
                e = 'checked'
                submission.comment = True;
            if self.request.get('showIt'):
                f = 'checked'
                submission.visible = True
            if self.request.get('legal4'):
                y = 'checked'
                submission.visible = True

            
            

            
            
            submission.put()
            template = JINJA_ENVIRONMENT.get_template('ideaWIVG.jinja')
           

            template_values = {
            "name": submission.name,
            "namePerson":submission.namePerson,
            "tagline": submission.tagline,
            "genres": submission.genres,
            "describe": submission.describe,
            "original": submission.original,
            "look": submission.look,
            "who": submission.who,
            "email": submission.email,
            "additionalInfo": submission.additionalInfo,
            "residenceStatus": submission.residenceStatus,
            "legal1": a,
            "legal2": b,
            "legal3": c,
            "review": d,
            "legal4": y,
            "comment": e,
            "showIt": f,
            "justSaved":z,

            }
            self.response.out.write(template.render(template_values))
コード例 #11
0
ファイル: earthbeat.py プロジェクト: aborilov/Earthbeat
def increment(mood):
    if mood:
        counter.increment("smile_count")
    else:
        counter.increment("cry_count")
コード例 #12
0
ファイル: models.py プロジェクト: avastjohn/maventy_new
 def increment_count():
   return counter.increment('Visit')
コード例 #13
0
ファイル: models.py プロジェクト: avastjohn/maventy_new
 def increment_count():
   return counter.increment('Patient')