Exemple #1
0
    def __init__(self):
        cfg = config().get()
        storage.redisclient(cfg['services']['redis']['host'],
                            int(cfg['services']['redis']['port']))

        self.sensors = {}
        self.controls = {}
        self.reload()

        t = Thread(target=self.updateworker)
        t.start()
Exemple #2
0
from datetime import datetime
from jose import jwt
import qrcode
from io import BytesIO

app = Flask(__name__)

if 'REDIS_PORT' in os.environ:
    redis_addr = os.environ['REDIS_PORT']
else:
    redis_addr = 'tcp://localhost:6379'

redis_port = redis_addr.split(':')[2]
redis_ip = redis_addr.split('//')[1].split(':')[0]

redisclient(redis_ip, redis_port)

log = logging.getLogger('view')

scope_map = {"openid": "Use your NHS login to sign you in",
             "email": "View your email address"}


@app.before_request
def log_request():
    g.transaction_id = random.randint(0, 100000)
    log.info('Method=BeforeRequest Transaction=%s URL=%s ClientIP=%s Method=%s Proto=%s UserAgent=%s'
             % (g.transaction_id,
                request.url,
                request.headers.environ['REMOTE_ADDR'],
                request.headers.environ['REQUEST_METHOD'],
Exemple #3
0
 def __init__(self, *args, **kwargs):
     redisclient('localhost', 6379, db=1)
     super(tests_view, self).__init__(*args, **kwargs)
Exemple #4
0
from contextlib import closing
import random
import json
from athlete import Athlete
from segment import Segment
from division import Division
from storage import redisclient
from core import AlbaSotwCore
import os, requests
from functools import wraps
from collections import OrderedDict
from datetime import date, datetime, timedelta
import logging

app = Flask(__name__)
redisclient('localhost', 6379)
core = AlbaSotwCore()

log = logging.getLogger('sotw.frontend')


@app.before_request
def log_request():
    log.info('URL=%s ClientIP=%s Method=%s Proto=%s UserAgent=%s' %
             (request.url, request.headers.environ['REMOTE_ADDR'],
              request.headers.environ['REQUEST_METHOD'],
              request.headers.environ['SERVER_PROTOCOL'],
              request.headers.environ['HTTP_USER_AGENT']))
    # transaction = random.randint(0, 100000)
    # request.['transaction'] = str(transaction)
Exemple #5
0
 def __init__(self, *args, **kwargs):
     redisclient('localhost', 6379, db=1)
     super(tests_AlbaSotwCore, self).__init__(*args, **kwargs)
     self.test_data = loader().setupTestData(file='../test_seed_data.yml')
     self.efforts = self.test_data['loaded_efforts']
Exemple #6
0
 def setupTestData(self):
     redisclient('localhost', 6379, db=1)
     self.test_data = loader().setupTestData(file='../test_seed_data.yml')
Exemple #7
0
 def setupTestData(self):
     redisclient('localhost', 6379, db=1)
     self.test_data = loader().setupTestData(file='../test_seed_data.yml')
     self.efforts = self.test_data['loaded_efforts']
 def __init__(self, *args, **kwargs):
     redisclient('localhost', 6379, db=1)
     super(tests_Division, self).__init__(*args, **kwargs)
     self.setupTestData()
 def setupTestData(self):
     redisclient('localhost', 6379)
     self.test_data = loader().setupTestData(file='../test_seed_data.yml')
Exemple #10
0
 def __init__(self, *args, **kwargs):
     redisclient('localhost', 6379, db=1)
     super(tests_Division, self).__init__(*args, **kwargs)
     self.setupTestData()