示例#1
0
def client():
    # Delete temp sqlite DB if it exists in the dir
    ut_db_filename = 'ut.db'
    if os.path.exists(ut_db_filename):
        os.unlink(ut_db_filename)

    # Create a special DB for this UT
    main.create_db(ut_db_filename)

    # Init file manager and start a fresh new filesystem
    main.init_filemanager(True)

    # Start flask app and get its test client
    app = main.start_flask()
    app.config['TESTING'] = True
    client = app.test_client()

    # Start the test
    yield client

    # Delete the temp DB file that was created for this UT
    os.unlink(ut_db_filename)

    # Delete the BLP FS
    main.purge_filesystem()
示例#2
0
 def onClick(self, Form):
     username = self.lineEdit.text()
     password = self.lineEdit_2.text()
     create_db(username, password)
     self.myapp = MyMainWindow()
     self.myapp.show()
     Form.close()
示例#3
0
# -*- coding:utf-8 -*-
from main import app, db, create_app, create_db

if __name__=="__main__":
    import sys
    args = sys.argv[1:]
    
    if "createdb" in args:
        create_db(db)
        print "Database tables created."
    elif "runserver" in args:
        create_app(app).run()
    else: 
        print "usage: %s [createdb|runserver|help]" % __file__ 
示例#4
0
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)

sys.path.insert(0, "/var/www/flask/")

import os
activate_this = '/var/www/flask_venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

import main
from main import app as application
main.create_db(app=application)
application.secret_key = 'somescret'
示例#5
0
import socket
import main

HOST = '127.0.0.1'  # Standard loopback interface address (localhost)
PORT = 65432  # Port to listen on
'''
creates a socket object that supports the context manager type,
 so you can use it in a with statement. There’s no need to call s.close()
'''
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.bind((HOST, PORT))
    s.listen()
    conn, addr = s.accept()
    with conn:
        print('Connected by', addr)
        main.create_db()  #create initial DB: dbtest
        while True:
            data = conn.recv(1024)
            if not data:
                break
            rec_data = data.decode(
            )  #get request from client according to menu bar
            if rec_data[0] == '1':
                main.read_available_tasks(data)
                conn.sendall(data)
            elif rec_data[0] == '2':
                main.add_to_available_tasks(data)
                conn.sendall(data)
            elif rec_data[0] == '3':
                main.insert_db(data)
                conn.sendall(data)
示例#6
0
 def test_Grand_Central(self):
     main.create_db('./GTFS')
     route_ids = main.find_passing_station('Grand Central - 42 St')
     main.close_db()
     # print(route_ids)
     self.assertEqual([], list(set(route_ids) - set(['2', '4', '5', '6', '6X', '7', '7X', 'GS'])))
示例#7
0
import main
import file_manager

main.create_db()
file_manager.init(False)
app = main.start_flask()