예제 #1
0
파일: generate.py 프로젝트: ShiyuZeng/jrxy
def generate():
    user = config['users'][0]
    apis = app.getCpdailyApis(user)
    session = app.getSession(user, apis)
    params = app.getUnSignedTasks(session, apis)
    task = app.getDetailTask(session, params, apis)
    extraFields = task['extraField']
    if len(extraFields) < 1:
        app.log('没有附加问题需要填写')
        exit(-1)
    defaults = []
    for i in range(0, len(extraFields)):
        extraField = extraFields[i]
        extraFieldItems = extraField['extraFieldItems']
        print('额外问题%d ' % (i + 1) + extraField['title'])
        default = {}
        one = {}
        for j in range(0, len(extraFieldItems)):
            extraFieldItem = extraFieldItems[j]
            print('\t%d ' % (j + 1) + extraFieldItem['content'])
        choose = int(input("请输入对应的序号:"))
        if choose < 1 or choose > len(extraFieldItems):
            app.log('输入错误')
            exit(-1)
        one['title'] = extraField['title']
        one['value'] = extraFieldItems[choose - 1]['content']
        default['default'] = one
        defaults.append(default)
    print('======================分隔线======================')
    print(yaml.dump(defaults, allow_unicode=True))
예제 #2
0
def generate():
    config = app.config
    user = config['users'][0]
    apis = app.getCpdailyApis(user)
    session = app.getSession(user, apis['login-url'])
    try:
        form = dict(app.queryForm(session, apis['host']))['form']
    except TypeError:
        print('Error:请在疫情填报问卷开放时间时执行脚本')
        exit(-1)
    # app.log(form)
    defaults = []
    sort = 1
    for formItem in form:
        if formItem['isRequired'] == 1:
            default = {}
            one = {}
            default['title'] = formItem['title']
            default['type'] = formItem['fieldType']
            print('问题%d:' % sort + default['title'])
            if default['type'] == 1:
                default['value'] = input("请输入文本:")
            if default['type'] == 2:
                fieldItems = formItem['fieldItems']
                num = 1
                for fieldItem in fieldItems:
                    print('\t%d ' % num + fieldItem['content'])
                    num += 1
                choose = int(input("请输入序号:"))
                if choose < 1 or choose > num:
                    print('输入错误,请重新执行此脚本')
                    exit(-1)
                default['value'] = fieldItems[choose - 1]['content']
            if default['type'] == 3:
                fieldItems = formItem['fieldItems']
                num = 1
                for fieldItem in fieldItems:
                    print('\t%d ' % num + fieldItem['content'])
                    num += 1
                chooses = list(map(int, input('请输入序号(可输入多个,请用空格隔开):').split()))
                default['value'] = ''
                for i in range(0, len(chooses)):
                    choose = chooses[i]
                    if choose < 1 or choose > num:
                        print('输入错误,请重新执行此脚本')
                        exit(-1)
                    if i != len(chooses) - 1:
                        default['value'] += fieldItems[choose -
                                                       1]['content'] + ','
                    else:
                        default['value'] += fieldItems[choose - 1]['content']
            if default['type'] == 4:
                default['value'] = input("请输入图片名称:")
            one['default'] = default
            defaults.append(one)
            sort += 1
    print('======================复制下面信息替换config.yml默认配置======================')
    print(yaml.dump(defaults, allow_unicode=True))
예제 #3
0
def generate():
    config = app.config
    user = config['users'][0]
    apis = app.getCpdailyApis(user)
    session = app.getSession(user, apis['login-url'])
    form = dict(app.queryForm(session, apis))['form']
    # app.log(form)
    defaults = []
    sort = 1
    for formItem in form:
        if formItem['isRequired'] == 1:
            default = {}
            one = {}
            default['title'] = formItem['title']
            default['type'] = formItem['fieldType']
            print('问题%d:' % sort + default['title'])
            if default['type'] == 1:
                default['value'] = input("请输入文本:")
            if default['type'] == 2:
                fieldItems = formItem['fieldItems']
                num = 1
                for fieldItem in fieldItems:
                    print('\t%d ' % num + fieldItem['content'])
                    num += 1
                default['value'] = fieldItems[int(input("请输入序号:")) - 1]['content']
            if default['type'] == 3:
                fieldItems = formItem['fieldItems']
                num = 1
                for fieldItem in fieldItems:
                    print('\t%d ' % num + fieldItem['content'])
                    num += 1
                chooses = list(map(int, input('请输入序号(可输入多个,请用空格隔开):').split()))
                default['value'] = ''
                for i in range(0, len(chooses)):
                    if i != len(chooses) - 1:
                        default['value'] += fieldItems[chooses[i] - 1]['content'] + ','
                    else:
                        default['value'] += fieldItems[chooses[i] - 1]['content']
            if default['type'] == 4:
                default['value'] = input("请输入图片名称:")
            one['default'] = default
            defaults.append(one)
            sort += 1
    print('======================分隔线======================')
    print(yaml.dump(defaults, allow_unicode=True))