Esempio n. 1
0
def signUp():
    try:
        AccountBookService.getInstance().signUp(app)
    except Exception as e:
        logger.debug('exception occured!' + str(e))
        return redirect("/", 404)
    return index()
Esempio n. 2
0
def login():
    try:
        AccountBookService.getInstance().login(app)
    except Exception as e:
        logger.debug('exception occured!' + str(e))
        return redirect("/", 404)
    return "success"
Esempio n. 3
0
def parseMessage():
    try:
        return AccountBookService.getInstance().parseMessage()
    except Exception as e:
        logger.debug('exception occured!' + str(e))
        result = {}
        result.setdefault('result', 'fail')
        result = json.dumps(result)
        return result
Esempio n. 4
0
def getTableContents():
    try:
        if request.method == 'GET':
            return AccountBookService.getInstance().getTableContents()
        elif request.method == 'POST':
            return AccountBookService.getInstance().createTableContents()
        elif request.method == 'PUT':
            return None
        else:
            return AccountBookService.getInstance().deleteTableContents()
    except Exception as e:
        logger.debug('exception occured!' + str(e))
        return redirect("/home", 302)
Esempio n. 5
0
    def parseMessage(self):
        if request.method == "POST":
            results = self.repo.selectQuery(
                self.query.find_all_message_pattern, ())
            #results = self.repo.findOne(message_pattern());
            #print('results : ', results , len(results));
            #logger.debug(request.data);
            json_str = (request.data).decode("utf-8")
            logger.debug('decoded message : ' + json_str)
            json_obj = json.loads(json_str.replace('\n', '\\n'))
            message = json_obj['message']
            logger.debug('json obj message : ' + message)
            for pattern_row in results:
                p = re.compile(pattern_row['message_pattern'], re.VERBOSE)
                mo = p.search(message)
                if mo:
                    logger.debug('message_pattern : ' +
                                 pattern_row['message_pattern'])
                    logger.debug(mo.groups())
                    #logger.debug('response: ' + json.dumps(dict(zip(position_key , [mo.groups()[i] for i in position_info[pattern_row['card_company_number']]]))))
                    result_obj = dict(
                        zip(position_key, [
                            mo.groups()[i] for i in position_info[
                                pattern_row['card_company_number']]
                        ]))
                    print('comehere ' + result_obj.__str__())
                    result_obj.setdefault('result', 'success')
                    return json.dumps(result_obj)
                # 패턴을 못찾는경우라면 unknown_message_pattern테이블에 insert

        # post method가 아니거나 패턴을 찾지못했을경우
        result = {}
        result.setdefault('result', 'fail')
        return json.dumps(result)
Esempio n. 6
0
    def login(self, app):
        json_obj = self.json_load(request.data)
        _name = json_obj['adminId']
        _password = json_obj['adminPassword']
        print(_name, _password, app.custom_id_min_length,
              app.custom_password_min_length)

        # 아디 및 비번 길이체크
        if (len(_name) < app.custom_id_min_length
                or len(_password) < app.custom_password_min_length):
            logger.debug('_name or _password length is not enough')
            raise Exception('id or password length is not enough!')

        results = self.repo.selectQuery(self.query.find_a_user, (_name, ))
        if (len(results) == 0):
            logger.debug('already exists admin_id')
            raise Exception('not exists admin_id')
        return json.dumps({}.setdefault('result', 'success'))
Esempio n. 7
0
def createCardCompanies():
    try:
        return AccountBookService.getInstance().createCardCompanies()
    except Exception as e:
        logger.debug('exception occured!' + str(e))
        return redirect("/home", 302)
Esempio n. 8
0
def getAllPatternList():
    try:
        return AccountBookService.getInstance().getPatternList()
    except Exception as e:
        logger.debug('exception occured!' + str(e))
        return redirect("/", 302)
Esempio n. 9
0
def menus():
    try:
        return AccountBookService.getInstance().getMenus()
    except Exception as e:
        logger.debug('exception occured!' + str(e))
        return redirect("/", 302)