コード例 #1
0
                client, participant_id, consent_questionnaire_id_and_version,
                consent_questions, answer_map)
            for questionnaire_id_and_version, questions in questionnaire_to_questions.iteritems(
            ):
                if questionnaire_id_and_version != consent_questionnaire_id_and_version:
                    _submit_questionnaire_response(
                        client, participant_id, questionnaire_id_and_version,
                        questions, answer_map)
            logging.info('%s created from row %d (%r %r).', participant_id,
                         reader.line_num, row['first_name'], row['last_name'])
            num_participants += 1
    logging.info('%d participants imported.' % num_participants)


if __name__ == '__main__':
    configure_logging()
    parser = get_parser()
    parser.add_argument(
        '--file',
        help='Path to the CSV file containing the participant data.',
        default=HEALTHPRO_PARTICIPANTS_FILE)
    parser.add_argument(
        '--instance',
        type=str,
        help='The instance to hit, defaults to http://localhost:8080',
        default='http://localhost:8080')
    parser.add_argument('--creds_file',
                        type=str,
                        help='Path to credentials JSON file.')
    main(parser.parse_args())
コード例 #2
0
"""Calls the API which imports the latest version of the codebook."""

import logging
import sys

from client import Client
from main_util import configure_logging, get_parser


def import_codebook(client):
    logging.info('Requesting import of latest codebook in %s.',
                 client.args.project)
    response = client.request_json('ImportCodebook', method='POST')
    logging.info(
        'Published version was v%(published_version)s, now active version is v%(active_version)s.'
        % response)
    success = True
    for error in response.get('error_messages', []):
        logging.error(error)
        success = False
    for status in response.get('status_messages', []):
        logging.info(status)
    return success


if __name__ == '__main__':
    configure_logging()
    if not import_codebook(Client(parser=get_parser())):
        sys.exit(1)