Esempio n. 1
0
def try_():
    user_id = request.form['id']
    print(user_id)
    text = request.form['text']
    timestamp = get_timestamp()
    text_file = 'tmp/tmp{0}.txt'.format(timestamp)
    file = open(text_file, 'w')
    file.write(text)
    file.close()
    subprocess.Popen(['python driver.py ' + str(timestamp) + ' ' + text_file],
                     shell=True)
    print 'insert into Videos values({0}, "{1}", "{2}", "{3}", {4})'.format(
        user_id, 'vid/vid{0}.mp4'.format(timestamp),
        'sum/sum{0}.txt'.format(timestamp), 'q/q{0}.txt'.format(timestamp),
        timestamp)
    mysql.commit(
        'insert into Videos values({0}, "{1}", "{2}", "{3}", {4})'.format(
            user_id, 'vid{0}.mp4'.format(timestamp),
            'sum/sum{0}.txt'.format(timestamp), 'q/q{0}.txt'.format(timestamp),
            int(timestamp / 1000)))
    return "Success"
Esempio n. 2
0
def upload_file():
    f = request.files['file']
    f.save(os.path.join(app.config['UPLOAD_FOLDER'], f.filename))
    os.system('pwd')
    os.system('chmod 777 "' +
              os.path.join(app.config['UPLOAD_FOLDER'], f.filename) + '"')
    print(os.system('ls -l ' + app.config['UPLOAD_FOLDER']))

    print(os.path.join(app.config['UPLOAD_FOLDER'], f.filename))

    user_id = 1

    timestamp = get_timestamp()
    pdf_file = os.path.join(app.config['UPLOAD_FOLDER'], f.filename)
    # print(pdf_file)
    text = convert_pdf_to_messy_txt(pdf_file)

    pdf_file = pdf_file.split('/')[-1]
    pdf = pdf_file[:-4] + '.txt'
    fw = open(os.path.join('tmp/', pdf), 'w')
    print(os.path.join('tmp/', pdf_file[:-4], '.txt'))
    fw.write(text)
    fw.close()

    convert_txt_to_clean(pdf)

    text_file = os.path.join('tmp/', (pdf_file[:-4] + '_clean.txt'))

    subprocess.Popen(['python driver.py ' + str(timestamp) + ' ' + text_file],
                     shell=True)
    print 'insert into Videos values({0}, "{1}", "{2}", "{3}", {4})'.format(
        user_id, 'vid/vid{0}.mp4'.format(timestamp),
        'sum/sum{0}.txt'.format(timestamp), 'q/q{0}.txt'.format(timestamp),
        timestamp)
    mysql.commit(
        'insert into Videos values({0}, "{1}", "{2}", "{3}", {4})'.format(
            user_id, 'vid{0}.mp4'.format(timestamp),
            'sum/sum{0}.txt'.format(timestamp), 'q/q{0}.txt'.format(timestamp),
            int(timestamp / 1000)))
    return redirect('/main.html?id=' + str(user_id))
Esempio n. 3
0
def receiveData():
    doc = util.parseDocument(request.get_json())
    mysql.insertDoc(doc)
    mysql.commit()
    return '', 204
Esempio n. 4
0
gd.generate_foreign_spy_sighting()
gd.generate_means_of_contact()
print("Data generated")

#execute insert commands
id.insert_agent()
id.insert_firearm()
id.insert_target()
id.insert_unit()
id.insert_spy()
id.insert_home_spy()
id.insert_foreign_spy_organization()
id.insert_foreign_spy()
id.insert_foreign_spy_sighting()
id.insert_common_location()
id.insert_target_sighting()
id.insert_operator()
id.insert_alias()
id.insert_other()
id.insert_means_of_contact()
print("Data inserted")

mysql.commit()

#testing
cursor.execute("SELECT * FROM AGENT")
print('error')
for x in cursor:
    print(x)
cursor.close()
Esempio n. 5
0
def user_register():
    print(request.form)
    mysql.commit(
        'insert into Users(username, password) values ("{0}", "{1}")'.format(
            request.form['username'], request.form['password']))
    return 'Success'