def setUp(self):
     main.app.config["TESTING"] = True
     main.connect_db()
     self.app = main.app.test_client()
     self.app.post('/createModel',
                   data = json.dumps({"model_name": "test_model1",
                                      "model_type": "OnlineLinearRegression",
                                      "retrain_counter": 1}))
 def setUp(self):
     main.app.config["TESTING"] = True
     main.connect_db()
     self.app = main.app.test_client()
     self.app.post('/createModel',
                   data=json.dumps({
                       "model_name": "test_model1",
                       "model_type": "LinearRegression",
                       "retrain_counter": 10
                   }))
Esempio n. 3
0
 def setUp(self):
     print "starting setup"
     main.app.config["TESTING"] = True
     main.connect_db()
     self.app = main.app.test_client()
     try:
         rv = self.app.get('/models/test_model1')
     except:
         self.app.post('/createModel',
                       data = json.dumps({"model_name": "test_model1",
                                          "model_type": "OnlineLinearRegression",
                                          "retrain_counter": 1}))
     print "finished setup"
 def setUp(self):
     print "starting setup"
     main.app.config["TESTING"] = True
     main.connect_db()
     self.app = main.app.test_client()
     try:
         rv = self.app.get('/models/test_model1')
     except:
         self.app.post('/createModel',
                       data=json.dumps({
                           "model_name": "test_model1",
                           "model_type": "OnlineLinearRegression",
                           "retrain_counter": 1
                       }))
     print "finished setup"
Esempio n. 5
0
 def setUp(self):
     main.app.config['TESTING'] = True
     main.app.logger.setLevel('DEBUG')
     self.app = main.app.test_client()
     main.init_db()
     self.db = main.connect_db()
     self.service = Service(self.db)
Esempio n. 6
0
def add_profile():

    db = connect_db()
    #cursor = db.cursor()

    user_id = request.cookies.get('user_id')
    color = request.form['color']
    skill = request.form['skill']

    if len(skill) > 2 or int(skill) > 12:
        return jsonify({'error': 'skill can be a number from 1 to 12 '})

    if not check_cookies():
        return jsonify({'error': 'in cookies'})

    skills = replace_skills(skill)

    skill = request.form['skill']
    abilities = Matrix.get_skill_matrix(skill)
    res = App.add_profile(user_id, skills, color, abilities)
    if res:
        return jsonify({'success': True})
    else:
        return jsonify({
            'error':
            'profile not added(a profile with this id already exists)'
        })
Esempio n. 7
0
def result():
    conn = connect_db()
    cur = conn.cursor()
    sql_str = "SELECT * FROM t_persons"
    cur.execute(sql_str)
    content = cur.fetchall()

    sql_str = "SHOW FIELDS FROM t_persons"
    cur.execute(sql_str)
    labels = cur.fetchall()
    labels = [l[0] for l in labels]

    return render_template('result.html', labels=labels, content=content)
Esempio n. 8
0
    def display_customer(self):
        for i in range(1, 11, 2):
            self.tick = Label(root, text="|")
            self.tick.grid(row=1, column=i)
            self.array_cursor_top.append(self.tick)

        self.customer_id = Label(root, text='N°client')
        self.money = Label(root, text='Cagnotte')
        self.last_name = Label(root, text='Nom')
        self.first_name = Label(root, text='Prénom')
        self.contact = Label(root, text='Contact')

        self.customer_id.grid(row=1, column=0)
        self.money.grid(row=1, column=2)
        self.last_name.grid(row=1, column=4)
        self.first_name.grid(row=1, column=6)
        self.contact.grid(row=1, column=8)

        connection, cursor = connect_db('db.db')

        cursor.execute("SELECT *FROM Customer")
        row = cursor.fetchall()
        i = 2
        self.array_cursor = []
        self.array_data = []
        for customer in row:
            j = 0
            k = 1
            for data in customer:

                self.data_label = Label(root, text=data)
                self.data_label.grid(row=i, column=j)
                self.array_data.append(self.data_label)

                self.tick = Label(root, text="|")
                self.tick.grid(row=i, column=k)
                self.array_cursor.append(self.tick)

                j += 2
                k += 2
            i += 1
        connection.close()
Esempio n. 9
0
#import main
import main

main.connect_db()
print(
    main.push(
        "sc", 1,
        "####  完美解码V.20201225 已发布  \n #### 下载地址: http://www.wmzhe.com/soft-13163.html"
    ))
Esempio n. 10
0
import sqlite3 as db
from main import connect_db
from datetime import date, datetime, timedelta

print('Releasing assets for ' + str(date.today()))
conn = connect_db()
curs =  conn.cursor()
#curs.execute('update asset set releasedate = (?) where isreserved = 1', [str(date.today())])
curs.execute('update asset set isreserved = 0 where isreserved = 1 AND releasedate = (?)', [str(date.today())])
conn.commit()
Esempio n. 11
0
#! python3
# coming_soon.py - PART2 Task2: Parses coming_soon.json to movies.db

import sys, os, json, uuid
from main import Movie as Movie
from main import get_movie as get_movie
from main import connect_db as connect_db
from main import create_movie_table as create_movie_table

pyPath = os.path.abspath(os.path.dirname(sys.argv[0]))
jsonSrc = os.path.join(pyPath, 'coming_soon.json')

if __name__ == '__main__':
    conn, cursor = connect_db('movies.db')

    create_movie_table(conn, cursor)  #if not exists

    if os.path.exists(jsonSrc):
        with open(jsonSrc) as jsonFile:
            jsonData = json.load(jsonFile)

    for amovie in jsonData['results']:
        newmovie = Movie(str(uuid.uuid1()), amovie['rating'],
                         amovie.get('release_date', "Now Showing"),
                         str(amovie['cast']), amovie['synopsis'],
                         amovie['movie_title'], amovie['image_url'],
                         amovie['id'], None)
        if newmovie.check_movie_exists(conn, cursor):
            print(
                str(newmovie) +
                " already exists in our database. Updating release date instead."
Esempio n. 12
0
    for p in profits:
        share = main.shared_money(p['money'])
        if fee + share > app.config['REDPACK_MAX']:
            sys_pay = _share(p['agent_openid'], fee, p['user_pay_id'])
            if sys_pay['state'] == SUCCESS:
                save_shares(profits_in_one_share, sys_pay['id'])
                total += fee
            profits_in_one_share = []
            fee = 0
        fee += share
        profits_in_one_share.append(p)

    if fee > app.config['REDPACK_MIN']:
        sys_pay = _share(p['agent_openid'], fee, p['user_pay_id'])
        if sys_pay['state'] == SUCCESS:
            save_shares(profits_in_one_share, sys_pay['id'])
            total += fee
    app.logger.info('share %d points to user: %d', total, agent)
        

if __name__ == '__main__':
    app.logger.info('share profilt run')

    service = Service(main.connect_db())
    weixin.ssl_cert_file = './apiclient_cert.pem'
    weixin.ssl_key_file = './apiclient_key.pem'
    profit = service.find_unshared_profit()

    for k, g in groupby(profit, lambda x: x['agent']):
        settlement(k, g)
Esempio n. 13
0
 def setUp(self):
     main.app.config["TESTING"] = True
     main.connect_db()
     self.app = main.app.test_client()