def import_objects(): output_file = 'flightlog.gpx' file = request.files['file'] logging.debug('uploading file ' + file.filename) if file and allowed_file(file.filename): # extract content content = file.read() csvreader = csv.DictReader(StringIO(content)) order = ['', 'latitude', 'longitude', 'altitude'] logger.debug("create Gpx Track") gpxData = createGPXTrack(csvreader, output_file, order) user_id = str(1234) doarama_params.update({'user-id': user_id}) # create temp file init_filesystem() logger.debug("creating temp file") filename = application.config[ 'UPLOAD_FOLDER'] + "flightlog" + id_generator() + ".gpx" gpxFile = open(filename, 'w') gpxFile.write(gpxData) gpxFile.close() # post temp file logger.debug("post file to doarama") gpxFile = open(filename, 'rb') post_id = post_file(user_id, gpxFile) print("Activity Id: " + str(post_id)) # remove temp file if application.config['UPLOAD_FOLDER'] == True: os.remove(filename) # Each activity must be assigned a valid activity type. This is used to control various aspects of the # visualisation including playback rate and elevation correction so please set appropriately. set_activity_info(30, post_id) # create a visual key which will be passed to iframe in visualisation.html logger.debug("create_visualisation, post id: " + str(post_id)) key_id = create_visualisation(post_id) print("Key Id: " + str(key_id)) global entries entries = [dict(key_id=key_id, file_name=filename)] return redirect(url_for('show_visualisation')) else: abort(make_response("File extension not acceptable", 400))
def import_objects(): output_file = 'flightlog.gpx' file = request.files['file'] logging.debug('uploading file ' + file.filename) if file and allowed_file(file.filename): # extract content content = file.read() csvreader = csv.DictReader(StringIO(content)) order = ['', 'latitude', 'longitude', 'altitude'] logger.debug("create Gpx Track") gpxData = createGPXTrack(csvreader, output_file, order) user_id = str(1234) doarama_params.update({'user-id': user_id}) # create temp file init_filesystem() logger.debug("creating temp file") filename = application.config['UPLOAD_FOLDER'] + "flightlog" + id_generator() + ".gpx" gpxFile = open(filename, 'w') gpxFile.write(gpxData) gpxFile.close() # post temp file logger.debug("post file to doarama") gpxFile = open(filename, 'rb') post_id = post_file(user_id, gpxFile) print("Activity Id: " + str(post_id)) # remove temp file if application.config['UPLOAD_FOLDER'] == True: os.remove(filename) # Each activity must be assigned a valid activity type. This is used to control various aspects of the # visualisation including playback rate and elevation correction so please set appropriately. set_activity_info(30, post_id) # create a visual key which will be passed to iframe in visualisation.html logger.debug("create_visualisation, post id: " + str(post_id)) key_id = create_visualisation(post_id) print("Key Id: " + str(key_id)) global entries entries = [dict(key_id=key_id,file_name=filename)] return redirect(url_for('show_visualisation')) else: abort(make_response("File extension not acceptable", 400))
# from xml.dom import minidom from StringIO import StringIO from logging.config import fileConfig from doarama import doarama_params, post_file, create_visualisation, set_activity_info # from sqlite3 import dbapi2 as sqlite3 from contextlib import closing from werkzeug import secure_filename application = Flask(__name__) application.config.from_object('config') fileConfig('logging_config.ini') logger = logging.getLogger() entries = [] doarama_params.update({'api-key' : os.environ['DOARAMA_API_KEY']}) @application.route('/', methods=['GET', 'POST']) def index(): return render_template('index.html') # def init_db(): # with closing(connect_db()) as db: # with app.open_resource('schema.sql') as f: # db.cursor().executescript(f.read()) # db.commit() # def connect_db(): # """ Connects to the database """ # return sqlite3.connect(app.config['DATABASE'])
# from xml.dom import minidom from StringIO import StringIO from logging.config import fileConfig from doarama import doarama_params, post_file, create_visualisation, set_activity_info # from sqlite3 import dbapi2 as sqlite3 from contextlib import closing from werkzeug import secure_filename application = Flask(__name__) application.config.from_object('config') fileConfig('logging_config.ini') logger = logging.getLogger() entries = [] doarama_params.update({'api-key': os.environ['DOARAMA_API_KEY']}) @application.route('/', methods=['GET', 'POST']) def index(): return render_template('index.html') # def init_db(): # with closing(connect_db()) as db: # with app.open_resource('schema.sql') as f: # db.cursor().executescript(f.read()) # db.commit() # def connect_db(): # """ Connects to the database """