Ejemplo n.º 1
0
def _get_default_context():
    global _default_context

    if _default_context is None:
        _default_context = Context.get_default_context()

    return _default_context
Ejemplo n.º 2
0
def get_address(profile_service, query, payload):
    add_url = Context.get_default_context().get_context(
        "addsvc_url") + "/addresses"

    logger.error("/address check: context = " + add_url)

    address_id = None
    address_entry = profile_service.retrieve_address(query, payload)

    if address_entry is not None:
        r_address = requests.post(add_url, json=address_entry)

        logger.error("/address check: address service response = " +
                     str(r_address.status_code) + " " + str(r_address.json()))
        if r_address.status_code == 200:

            address_id = r_address.json()['deliver_point_barcode']
            logger.error(
                "/address check: address service response = Successfully retrieved valid address id "
                + address_id)
        else:
            logger.error(
                "/address check: address service response = Invalid address")
            address_id = "Invalid"

    return address_id
Ejemplo n.º 3
0
def init():
    global _default_context, _user_service

    _default_context = Context.get_default_context()
    _user_service = UserService(_default_context)

    logger.debug("_user_service = " + str(_user_service))
Ejemplo n.º 4
0
def init():

    global _default_context, _user_service, _registration_service

    _default_context = Context.get_default_context()
    _user_service = UserService(_default_context)
    _registration_service = RegisterLoginSvc()
    logger.debug("_user_service = " + str(_user_service))
Ejemplo n.º 5
0
    def __init__(self, ctx=None):

        super().__init__()

        if ctx is None:
            ctx = Context.get_default_context()

        self._ctx = ctx
def init():
    global _default_context, _user_service, _registration_service, v_service

    _default_context = Context.get_default_context()
    _user_service = UserService(_default_context)
    _registration_service = _get_registration_service()
    v_service = ValidatorService(_default_context)

    logger.debug("_user_service = " + str(_user_service))
Ejemplo n.º 7
0
def _get_default_connection():
    ctx = Context.get_default_context()
    c_info = ctx.get_context("db_connect_info")

    _default_connection = pymysql.connect(
        host=c_info['host'],
        user=c_info['user'],
        password=c_info['password'],
        port=c_info['port'],
        db=c_info['db'],
        charset=c_info['charset'],
        cursorclass=pymysql.cursors.DictCursor
    )
    return _default_connection
Ejemplo n.º 8
0
def _get_default_connection():

    global _default_connection

    if _default_connection is None:
        ctx = Context.get_default_context()
        c_info = ctx.get_context("db_connect_info")

        _default_connection = pymysql.connect(
            host=c_info['host'],
            user=c_info['user'],
            password=c_info['password'],
            port=c_info['port'],
            db='ebdb',
            charset='utf8mb4',
            cursorclass=pymysql.cursors.DictCursor)

    return _default_connection
Ejemplo n.º 9
0
def _get_default_connection():

    global _default_connection

    if _default_connection is None:
        ctx = Context.get_default_context()
        c_info = ctx.get_context("db_connect_info")

        # local test
        # basedata = {
        #     'host': 'localhost',
        #     'port': 3306,
        #     'user': '******',
        #     'password': '******',
        #     'db': 'se',
        #     'charset': 'utf8'
        # }

        basedata = {
            'host': 'sedatabase.ccrfnreg6ro1.us-east-1.rds.amazonaws.com',
            'user': '******',
            'password': '******',
            'port': 3306,
            'db': 'e6156'
        }

        c_info = basedata

        _default_connection = pymysql.connect(
            host=c_info['host'],
            user=c_info['user'],
            password=c_info['password'],
            port=c_info['port'],
            db=c_info['db'],
            charset='utf8mb4',
            cursorclass=pymysql.cursors.DictCursor
        )

    return _default_connection
Ejemplo n.º 10
0
def main():
    app = QApplication(sys.argv)

    # create system default folder
    username = os.environ['USERNAME']
    workspace_path = 'C:\Users\\' + username + '\Documents\HeartRateAnalyser\\'
    people_files_path = workspace_path + 'peoples\\'

    if not os.path.exists(workspace_path):
        os.mkdir(workspace_path)
        os.mkdir(people_files_path)

    # context at the background to save detector's data set
    context = Context()

    # schedule the interaction between IHM & context
    controller = Controller(context)

    # Interface Human-Machine
    analyser_window = AnalyserMainWindow(controller)
    analyser_window.show()

    app.exec_()
Ejemplo n.º 11
0
 def get_context(cls):
     if cls._context is None:
         cls.set_context(Context.get_default_context())
     return cls._context
Ejemplo n.º 12
0
import jwt
import jwt.jwt.api_jwt as apij
from Context.Context import Context
from time import time
import unicodedata
import logging

_context = Context.get_default_context()


def hash_password(pwd):
    global _context
    h = apij.encode(pwd,
                    key=_context.get_context("JWT_SECRET")).decode('utf-8')
    h = str(h)
    return h


def generate_token(info):

    info["timestamp"] = time()
    email = info['email']

    if email == '*****@*****.**':
        info['role'] = 'admin'
    else:
        info['role'] = 'usr'

    # What's this???
    # info['created'] = str(info['created'])
def t1():

    ctx = Context.get_default_context()

    db_info = ctx.get_context('db_connect_info')
    print("DB Connect Info = \n", json.dumps(db_info, indent=2))
Ejemplo n.º 14
0
import jwt
from Context.Context import Context
from time import time

_context = Context()


def hash_password(pwd):
    global _context
    h = jwt.encode(pwd, key=_context.get_context("JWT_SECRET"))
    h = str(h)
    return h


'''
def generate_token(uni):
    token = {
        "uni": uni,
        "timestamp": time()
    }
    if uni == 'dff9':
        token['role'] = 'admin'
    else:
        token['role'] = 'student'
    h = jwt.encode(token, key=_context.get_context("JWT_SECRET"))

    return h
'''


def generate_token(info):
Ejemplo n.º 15
0
    def __init__(self, ctx=None):

        if ctx is None:
            ctx = Context.get_default_context()
Ejemplo n.º 16
0
    def __init__(self, ctx=None):

        if ctx is None:
            ctx = Context.get_default_context()
        self.sns_client = boto3.client('sns',region_name='us-east-1')
        self._ctx = ctx