Exemple #1
0
def new_restaurant():
    if request.method == 'POST':
        import create_data
        newrest = Restaurant(name=request.form.get('name'))
        create_data.create(newrest)
        flash('New Restaurant Created')
        return redirect(url_for('restaurants'))
    else:
        return render_template('newrestaurant.html')
Exemple #2
0
def new_menu_item(restaurant_id):
    if request.method == 'POST':
        mi = MenuItem(name=request.form.get('name'),
                      price=request.form.get('price'),
                      description=request.form.get('description'),
                      course=request.form.get('course'),
                      restaurant_id=restaurant_id)
        import create_data
        create_data.create(mi)
        flash("Menu Item Created!")
        return redirect(url_for('restaurant_menu',
                                restaurant_id=restaurant_id))
    else:
        return render_template('newmenuitem.html', restaurant_id=restaurant_id)
Exemple #3
0
def script(dirname, subdirname):

    unzip(dirname, subdirname)

    if not os.path.isdir('check/{}'.format(dirname)):
        os.mkdir('check/{}'.format(dirname))

    if not os.path.isdir('/mnt/volume-nyc1-01/{}'.format(dirname)):
        os.mkdir('/mnt/volume-nyc1-01/{}'.format(dirname))

    if not os.path.isdir(os.path.join('check', dirname, 'xlses')):
        os.mkdir(os.path.join('check', dirname, 'xlses'))

    if not os.path.isdir(os.path.join('check', dirname, 'xlses', subdirname)):
        os.mkdir(os.path.join('check', dirname, 'xlses', subdirname))

    try:
        if os.path.isfile(
                os.path.join('/root/Novosad/mouses/Data', dirname,
                             subdirname + '.zip')):
            ext = '.zip'
        if os.path.isfile(
                os.path.join('/root/Novosad/mouses/Data', dirname,
                             subdirname + '.rar')):
            ext = '.rar'

        shutil.move(
            os.path.join('/root/Novosad/mouses/Data', dirname,
                         subdirname + ext),
            os.path.join('/mnt/volume-nyc1-01/', dirname))
    except Exception as e:
        print(e, 'already moved', subdirname)

    part(dirname, subdirname)
    start(dirname, subdirname)

    time.sleep(20)

    try:
        while True:
            if len([
                    f for f in os.listdir(
                        os.path.join('check', dirname, subdirname))
                    if 'done.txt' in f
            ]) == N_THREADS:
                xls_files = []

                for numb in range(N_THREADS):
                    xls_files += [
                        os.path.join('check', dirname, subdirname, str(numb),
                                     f) for f in os.listdir(
                                         os.path.join('check', dirname,
                                                      subdirname, str(numb)))
                        if '.xls' in f
                    ]

                for xls in xls_files:
                    shutil.move(
                        xls, os.path.join('check', dirname, 'xlses',
                                          subdirname))

                break

            else:
                time.sleep(60 * 1)
    except Exception as e:
        print(e)

    clear(dirname, subdirname)
    add_empt(dirname, subdirname)

    create(dirname, subdirname)

    concatenate('0', dirname, subdirname)
    concatenate('1', dirname, subdirname)

    infected = []
    if os.path.isdir(os.path.join('check', dirname, 'xlses', 'avg', '144')):
        infected = [
            f for f in os.listdir(
                os.path.join('check', dirname, 'xlses', 'avg', '144'))
            if '.xls' in f
        ]
    infected = list(set([f[0] for f in infected]))

    for m in infected:
        m = '0' if m == 'l' else '1'
        test(m, dirname)
import create_data
import LDA
import argparse

parser = argparse.ArgumentParser(description='Enter number of topics')
parser.add_argument('--n_topics', help='Number of Topics')

args = parser.parse_args()

path = "news-articles.txt"

create_data.create(path)
LDA.modeller(args.n_topics)
Exemple #5
0
    db_name = input("\033[0;32;40m Name >> ")

    print("\033[1;37;40m \n What would you like to do? (C)reate data // (I)nsert data // (U)pdate data // (D)elete data // (S)how all data // (P)ick one row to show")
    command = input("\033[0;32;40m Command >> ")

    try:
        if command.lower() == 'c':
            print("\033[1;37;40m \n Creating data. Please input the name of new entity.")
            table_name = input("\033[0;32;40m Table name >> ")
            print("\033[0;37;40m")
            sql = """create table {}
                    (ProductId integer,
                    Name text,
                    Price real,
                    primary key(ProductId))""".format(table_name)
            create(db_name, table_name, sql)

        elif command.lower() == 'i':
            print("\033[1;37;40m \n Inserting data. Please enter the name of the entity you would like to add data to.")
            table_name = input("\033[0;32;40m Table name >> ")

            print("\033[1;37;40m \n Please enter the name of the new record.")
            name = input("\033[0;32;40m Name >> ")

            print("\033[1;37;40m \n Please enter the new price.")
            price = input("\033[0;32;40m Price >> ")
            
            print("\033[0;37;40m")
            insert(db_name, name, price, table_name)

        elif command.lower() == 'u':