def main(): uid = get_uid_from_cookie() storage_dir = os.path.join(app_dir, 'storage') uid_dir = os.path.join(storage_dir, 'users', uid['uid']) userconfig = read_user_config(uid) form = cgi.FieldStorage() m = re.compile('([^&+/;]*)').match(form.getvalue('task_name')) taskname = m.group(1) taskfile = '' for d in userconfig['task_files']: if d.get('name') == taskname: taskfile = os.path.join(uid_dir, 'task_' + str(d.get('id')) + '.tsk') if taskfile == '' or not os.path.exists(taskfile): raise RuntimeError('Task File does not exist') task = parse_xcsoar_task(taskfile) print "Content-Type: text/html" print print write_json_task(task)
def load(taskname): uid = get_uid_from_cookie() uid_dir = os.path.join(current_app.config["USERS_FOLDER"], uid["uid"]) userconfig = read_user_config(uid) taskfile = "" for d in userconfig["task_files"]: if d.get("name") == taskname: taskfile = os.path.join(uid_dir, "task_" + str(d.get("id")) + ".tsk") if taskfile == "" or not os.path.exists(taskfile): raise NotFound("Task File does not exist") task = parse_xcsoar_task(taskfile) return write_json_task(task)
def load(taskname): uid = get_uid_from_cookie() uid_dir = os.path.join(current_app.config['USERS_FOLDER'], uid['uid']) userconfig = read_user_config(uid) taskfile = '' for d in userconfig['task_files']: if d.get('name') == taskname: taskfile = os.path.join( uid_dir, 'task_' + str(d.get('id')) + '.tsk') if taskfile == '' or not os.path.exists(taskfile): raise NotFound('Task File does not exist') task = parse_xcsoar_task(taskfile) return write_json_task(task)
def load(taskname): uid = get_uid_from_cookie() uid_dir = os.path.join(current_app.config['USERS_FOLDER'], uid['uid']) userconfig = read_user_config(uid) taskfile = '' for d in userconfig['task_files']: if d.get('name') == taskname: taskfile = os.path.join(uid_dir, 'task_' + str(d.get('id')) + '.tsk') if taskfile == '' or not os.path.exists(taskfile): raise NotFound('Task File does not exist') task = parse_xcsoar_task(taskfile) return write_json_task(task)