def fetch_first_submission(nonce): key = REDIS_FIRSTSUBMISSION_KEY(nonce=nonce) jsondata = redis_store.get(key) try: return json.loads(jsondata.decode('utf-8')) except: return None
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.decode('utf-8').split(',') if len(values) != 2: raise ValueError("temp_hostname value is invalid: " + value) else: return values
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(REDIS_COUNTER_KEY(form_id=form.id, month=month)) \ or 0 print('%s submissions for %s' % (nsubmissions, form))
def get_monthly_counter(self, basedate=None): basedate = basedate or datetime.datetime.now() month = basedate.month key = REDIS_COUNTER_KEY(form_id=self.id, month=month) counter = redis_store.get(key) or 0 return int(counter)