Beispiel #1
0
def testapi():
    """Test to see if API is working"""
    conn = Connection(app_site())

    print 'Attempting to get data from API...'
    conn.get('data_source')
    print 'Content retreived via API!'
Beispiel #2
0
 def __init__(self, ui):
     self.root = ui
     self.senddataVar = tk.StringVar()
     self.MainWindow = Ui_MainWindows(self.root)
     self.serialtype = SerialInterface()
     self.ConnectApi = Connection()
     self.mainUiWidget()
     self.initValue()
     self.configInit()
     # 建脚本运行的线程,传入的参数为脚本的路径
     self.OneSecPrcocess = threading.Thread(target=self.oneSecProcess)
     self.OneSecPrcocess.setDaemon(True)
     self.OneSecPrcocess.start()
Beispiel #3
0
def login():

    if session:
        return redirect(url_for('index'))
    else:
        c = Connection()
        conn = c.login(request.form['username'], request.form['password'])

        if conn['code'] == 1:
            session['username'] = request.form['username']
            return redirect(url_for('index'))
        else:
            return render_template('error.html')
Beispiel #4
0
def worth_data():
	conn = Connection(app_site())
	tables = [
		'transaction', 'dividend', 'security_prices', 'price', 'security_data']
	table = request.args.get('table', 'USD')
	res = [getattr(conn, t) for t in tables]
	res.append(conn.commodity_ids(table))

	# TODO: Fix 'nan' error with init_db
	mp = Worth(*res)
	worth = mp.convert_worth(mp.calc_worth())
	return jsonify(
		result=worth, id=mp.currency_id, missing=mp.missing, empty=mp.empty)
Beispiel #5
0
def resetdb():
    """Remove all content from database and creates new tables"""
    conn = Connection(app_site())
    conn.get('reset')
    print 'Database reset'