コード例 #1
0
ファイル: get_task.py プロジェクト: ubx/proSoar
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)
コード例 #2
0
ファイル: tasks.py プロジェクト: Turbo87/proSoar
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)
コード例 #3
0
ファイル: tasks.py プロジェクト: GliderGeek/proSoar
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)
コード例 #4
0
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)