示例#1
0
def fetch_first_submission(nonce):
    key = REDIS_FIRSTSUBMISSION_KEY(nonce=nonce)
    jsondata = redis_store.get(key)
    try:
        return json.loads(jsondata)
    except:
        return None
示例#2
0
def fetch_first_submission(nonce):
    key = REDIS_FIRSTSUBMISSION_KEY(nonce=nonce)
    jsondata = redis_store.get(key)
    try:
        return json.loads(jsondata)
    except:
        return None
示例#3
0
def get_temp_hostname(nonce):
    key = REDIS_HOSTNAME_KEY(nonce=nonce)
    value = redis_store.get(key)
    if value is None:
        raise KeyError("no temp_hostname stored.")
    redis_store.delete(key)
    values = value.split(',')
    if len(values) != 2:
        raise ValueError("temp_hostname value is invalid: " + value)
    else:
        return values
示例#4
0
def get_temp_hostname(nonce):
    key = REDIS_HOSTNAME_KEY(nonce=nonce)
    value = redis_store.get(key)
    if value is None:
        raise KeyError("no temp_hostname stored.")
    redis_store.delete(key)
    values = value.split(',')
    if len(values) != 2:
        raise ValueError("temp_hostname value is invalid: " + value)
    else:
        return values
示例#5
0
def monthly_counters(email=None, host=None, id=None, month=datetime.date.today().month):
    if id:
        query = [Form.query.get(id)]
    elif email and host:
        query = Form.query.filter_by(email=email, host=host)
    elif email and not host:
        query = Form.query.filter_by(email=email)
    elif host and not email:
        query = Form.query.filter_by(host=host)
    else:
        print 'supply each --email or --form or both (or --id).'
        return 1

    for form in query:
        nsubmissions = redis_store.get(MONTHLY_COUNTER_KEY(form_id=form.id, month=month)) or 0
        print '%s submissions for %s' % (nsubmissions, form)
示例#6
0
def monthly_counters(email=None,
                     host=None,
                     id=None,
                     month=datetime.date.today().month):
    if id:
        query = [Form.query.get(id)]
    elif email and host:
        query = Form.query.filter_by(email=email, host=host)
    elif email and not host:
        query = Form.query.filter_by(email=email)
    elif host and not email:
        query = Form.query.filter_by(host=host)
    else:
        print 'supply each --email or --form or both (or --id).'
        return 1

    for form in query:
        nsubmissions = redis_store.get(
            MONTHLY_COUNTER_KEY(form_id=form.id, month=month)) or 0
        print '%s submissions for %s' % (nsubmissions, form)
示例#7
0
 def get_monthly_counter(self, basedate=None):
     basedate = basedate or datetime.datetime.now()
     month = basedate.month
     key = MONTHLY_COUNTER_KEY(form_id=self.id, month=month)
     counter = redis_store.get(key) or 0
     return int(counter)
示例#8
0
def get_temp_hostname(nonce):
    key = REDIS_HOSTNAME_KEY(nonce=nonce)
    value = redis_store.get(key)
    if value == None: raise KeyError()
    redis_store.delete(key)
    return value.split(',')
示例#9
0
 def get_monthly_counter(self, basedate=None):
     basedate = basedate or datetime.datetime.now()
     month = basedate.month
     key = MONTHLY_COUNTER_KEY(form_id=self.id, month=month)
     counter = redis_store.get(key) or 0
     return int(counter)