예제 #1
0
def create_contactsheet():

    form = NewContactsheetForm()
    thread_id = current_user.get_id()

    redis_db.set(thread_id, "0")
    if form.validate_on_submit():
        upload_thread = Upload_thread(form, current_user.get_id(), thread_id)
        upload_thread.start()

        while True:
            status = redis_db.get(thread_id).decode("utf-8")
            if is_number(status):
                if float(status) >= 100.0:
                    flash("Successfully created contact sheet", "message")
                    return redirect(url_for("index"))
                else:
                    time.sleep(0.2)
            else:
                flash(redis_db.get(thread_id).decode("utf-8"), "error")
                return redirect(url_for("index"))

    return render_template("/create.html",
                           form=form,
                           max_file_size=size_of(Config.FILE_SIZE_LIMIT),
                           thread_id=thread_id)
예제 #2
0
 def progress_generator(thread_id):
     while True:
         status = redis_db.get(thread_id).decode("utf-8")
         if is_number(status):
             yield "data:" + status + "\n\n"
         else:
             return "data:" + status + "\n\n"
예제 #3
0
def check_admin_otp(entered_otp, phone):
    try:
        otp = redis_db.get(phone).decode('utf-8')
        if otp == entered_otp:
            return True
        return False
    except (InvalidRequestError, OperationalError):
        raise InvalidUsageError('sql connection or syntax is improper', 500)
예제 #4
0
def daily_weather_report(locations):

    daily_weather = []

    for location in locations:
        if redis_db.exists((location.lat, location.lng)):
            nh_weather_str = redis_db.get((location.lat, location.lng))
            nh_weather_dict = json.loads(nh_weather_str)
            daily_weather.append(nh_weather_dict)
    print "daily_weather in sun functions"
    return daily_weather
예제 #5
0
def daily_weather_report(locations):

    daily_weather = []

    for location in locations:
        if redis_db.exists((location.lat, location.lng)):
            nh_weather_str = redis_db.get((location.lat, location.lng))
            nh_weather_dict = json.loads(nh_weather_str)
            daily_weather.append(nh_weather_dict)
    print "daily_weather in sun functions"
    return daily_weather
예제 #6
0
def check_otp(entered_otp, phone):
    try:
        otp = redis_db.get(phone).decode('utf-8')
        user = User.query.filter_by(phone=phone).first()
        if otp == entered_otp:
            user.is_verified = 1
            db.session.commit()
        else:
            return make_response(jsonify({'response': "Invalid otp or expired otp"}), 400)
    except (InvalidRequestError, OperationalError):
        raise InvalidUsageError('sql connection or syntax is improper', 500)
예제 #7
0
파일: views.py 프로젝트: KetsuN/whatsup
def retrieve():
    key_values = {}
    for key in app.config["ACTIVE_ENVIRONMENTS"]:
        value = redis_db.get(key)
        if value:
            key_values[key] = json.loads(value)
        else:
            key_values[key] = {"environment": None, "jira_id": None}
    return app.response_class(response=json.dumps({"data": key_values}),
                              status=200,
                              mimetype="application/json")
예제 #8
0
def twilio_callback():
    to = request.form.get('To', '')
    from_ = request.form.get('From', '')
    message = request.form.get('Body', '').lower()
    if to == TWILIO_NUMBER:
        redis_db.incr(cgi.escape(message))
        socketio.emit('msg', {'div': cgi.escape(message),
                              'val': redis_db.get(message)},
                               namespace='/presentation')
    #resp = twiml.Response()
    #resp.message('Merci/Cheers.')
    return str(resp)
예제 #9
0
def seed_daily_weather():

    lat = 37.7655
    lng = -122.4429
    exp_time = 36000

    # pull coordinates from local db
    neighborhoods = Location.query.limit(10)

    # run api on each coordinate
    for nh in neighborhoods:

        forecast = app.weather_forecast.Weather.get_forecast(nh.lat, nh.lng, None, nh.n_hood)

        range_temp = forecast.high_F + u'\xb0F' +'-' + forecast.low_F + u'\xb0F'
        img_url = forecast.pic

        weather_id = (nh.lat, nh.lng)
        weather_details = { 'lat': nh.lat, 'lng': nh.lng, 'img_url': img_url ,'temp_range':range_temp }

        # store coord id and hash of weather details
        redis_db.set(weather_id, json.dumps(weather_details), exp_time)

        print redis_db.get(weather_id)
예제 #10
0
 def status(self, task_id):
     status = redis_db.get(task_id)
     if not status:
         return None
     return json.loads(status)
예제 #11
0
def check_if_token_in_blacklist(decrypted_token):
    jti = 'jti.' + decrypted_token['jti']
    return bool(redis_db.get(jti))
예제 #12
0
 def test_redis_connection(self):
     redis_db.set('foo', 'bar')
     self.assertEqual(redis_db.get('foo'), 'bar')
     redis_db.delete('foo')
예제 #13
0
 def test_redis_connection(self):
     redis_db.set('foo', 'bar')
     self.assertEqual(redis_db.get('foo'), 'bar')
     redis_db.delete('foo')