Esempio n. 1
0
def deploy():
    from flask_migrate import upgrade
    import app.models as md

    upgrade()
    db.create_all()
    md.init_data()
Esempio n. 2
0
def analyse_mingzi():
    if len(models.wx_dict) == 0:
        models.init_data()
    xing = request.values['xing']
    ming = request.values['ming']
    ret = models.analyse_mingzi(xing, ming)
    return json.dumps(ret, ensure_ascii=False)
Esempio n. 3
0
    def setUp(self):
        self.app = create_app('test')
        self.app_context = self.app.app_context()
        self.app_context.push()

        db.create_all()
        md.init_data()

        self.client = self.app.test_client(use_cookies=True)
Esempio n. 4
0
def analyse_bazi():
    if len(models.wx_dict) == 0:
        models.init_data()
    date = request.values['date']
    birthdaytime = request.values['time']
    birthdayStr = date + ' ' + birthdaytime
    birthday = time.strptime(birthdayStr, '%Y-%m-%d %H:%M:%S')
    ret = models.get_bazi_from_date(birthday.tm_year, birthday.tm_mon,
                                    birthday.tm_mday, birthday.tm_hour,
                                    birthday.tm_min)
    return json.dumps(ret, ensure_ascii=False)
Esempio n. 5
0
def querycustom():
    if len(models.wx_dict) == 0:
        models.init_data()
    firstWx = request.values['firstWx']
    secondWx = request.values['secondWx']
    xing = request.values['xing']
    sex = request.values['sex']
    doublename = request.values['doublename']
    if doublename == '1':
        ret = models.get_one_custom(xing, firstWx, sex, 50)
    else:
        ret = models.get_two_custom(xing, firstWx, secondWx, sex, 50)
    return json.dumps(ret, ensure_ascii=False)
Esempio n. 6
0
def query():
    if len(models.wx_dict) == 0:
        models.init_data()
    tonglei = request.values['tonglei']
    rigan_wx = request.values['rigan_wx']
    is_weak = request.values['is_weak']
    minTong = request.values['minTong']
    minYi = request.values['minYi']
    wuxingscore = request.values['wuxingscore']
    xing = request.values['xing']
    sex = request.values['sex']
    doublename = request.values['doublename']
    firstname = request.values['firstname']
    secname = request.values['secname']
    if doublename == '1':
        ret = models.get_one(tonglei, rigan_wx, is_weak, minTong, minYi,
                             wuxingscore.split(','), xing, 50, sex)
    else:
        if len(firstname) == 1:
            ret = models.get_sec(tonglei,
                                 rigan_wx,
                                 is_weak,
                                 minTong,
                                 minYi,
                                 wuxingscore.split(','),
                                 xing,
                                 50,
                                 sex,
                                 first=firstname)
        elif len(secname) == 1:
            ret = models.get_first(tonglei,
                                   rigan_wx,
                                   is_weak,
                                   minTong,
                                   minYi,
                                   wuxingscore.split(','),
                                   xing,
                                   50,
                                   sex,
                                   sec=secname)
        else:
            ret = models.get_two(tonglei, rigan_wx, is_weak, minTong, minYi,
                                 wuxingscore.split(','), xing, 50, sex)
    return json.dumps(ret, ensure_ascii=False)
Esempio n. 7
0
    def setUpClass(cls):
        try:
            cls.client = webdriver.Chrome()
        except:
            pass

        if cls.client:
            cls.app = create_app('test')
            cls.app_context = cls.app.app_context()
            cls.app_context.push()

            import logging
            logger = logging.getLogger('werkzeug')
            logger.setLevel("ERROR")

            db.create_all()
            models.init_data()

            threading.Thread(target=cls.app.run).start()
Esempio n. 8
0
 def test_init_data(self):
     models.init_data()
     self.assertTrue(Shikigami.query.count() > 0)
     self.assertTrue(Mission.query.count() > 0)