Example #1
0
def home(language):
    '''
    Show introduction
    '''
    ui = i18n[language]
    if request.method == 'POST':
        print("request form: ", request.form, flush=True)
        print("request form: ", list(request.form), flush=True)
        data = {}
        data['entity_type'] = request.form.get('entity_type', None)
        data['entity_id'] = request.form.get('selected_ids', None)
        data['project_name'] = request.form.get('project_name', None)
        data['project_id'] = request.form.get('project_id', None)
        hostname = request.host.split(":")
        config['vod_url'] = "{}{}:{}".format(configure['vod']['site']['ssl'],
                                             hostname[0],
                                             configure['vod']['site']['url'])
        print("config: ", config, flush=True)
        try:
            sg = Shotgun("{}{}".format(configure['shotgun']['site']['ssl'],\
                                        request.form.get("server_hostname", None)), \
                                        configure['shotgun']['site']['script_name'] , \
                                        configure['shotgun']['site']['script_key'], \
                                        sudo_as_login=request.form.get("user_login", None))

            config["sg"] = sg
            print("prefs: ", sg.preferences_read(), flush=True)
        except Exception as e:
            return render_template('%s.html' % 'message',
                                   message=ui['message']['auth_error'])
        if len(data['entity_id'].split(",")) == 1:

            entityhandler = entity_handler(config, data)

            if data["entity_type"] != "Task":
                data['tasks'] = entityhandler.get_tasks()
                print("Tasks: ", data['tasks'], flush=True)

            data['entity_name'] = entityhandler.get_entity_name()
            return render_template('%s.html' % 'index',
                                   data=data,
                                   i18n=ui["index"],
                                   language=language)
        else:
            message = ui['message']['select_error'].format(
                len(data['entity_id'].split(",")))
            return render_template('%s.html' % 'message', message=message)
    else:
        return render_template('%s.html' % 'message',
                               message=ui['message']['server_up'])
Example #2
0
def task_url():
    '''
    http://localhost:5000/task_url?language=cn&sg_url=autodesk-china-training.shotgunstudio.com&user_login={current_user.login}&project_id={project.Project.id}&project_name={project.Project.name}&task_name={content}&task_id={id}
    '''
    language = request.args.get('language')
    ui = i18n[language]
    data = {}
    data['entity_type'] = "Task"
    data['entity_id'] = request.args.get('task_id')
    data['project_name'] = request.args.get('project_name')
    data['project_id'] = request.args.get('project_id')
    hostname = request.host.split(":")
    config['vod_url'] = "{}{}:{}".format(configure['vod']['site']['ssl'],
                                         hostname[0],
                                         configure['vod']['site']['url'])
    print("config: ", config, flush=True)
    print("server_host: ", request.args.get("sg_url", None), flush=True)
    try:
        sg = Shotgun("{}{}".format(configure['shotgun']['site']['ssl'],\
                                        request.args.get("sg_url", None)), \
                                        configure['shotgun']['site']['script_name'] , \
                                        configure['shotgun']['site']['script_key'], \
                                        sudo_as_login=request.args.get('user_login', 'None'))
        config["sg"] = sg
        print("prefs: ", sg.preferences_read(), flush=True)
    except Exception as e:
        return render_template('%s.html' % 'message',
                               message=ui['message']['auth_error'])

    entityhandler = entity_handler(config, data)

    if data["entity_type"] != "Task":
        data['tasks'] = entityhandler.get_tasks()
        print("Tasks: ", data['tasks'], flush=True)

    data['entity_name'] = entityhandler.get_entity_name()
    return render_template('%s.html' % 'index',
                           data=data,
                           i18n=ui["index"],
                           language=language)