Пример #1
0
        raise ValueError("Collision among the %s field." % key)
    return result[0]


if __name__ == '__main__':
    xnat_url = 'http://masi.vuse.vanderbilt.edu/xnat'

    api_key = rc_keys['vuiis-projectapp']
    """ Initialize redcap project with url and key"""
    rc_project = redcap.Project('https://redcap.vanderbilt.edu/api/', api_key)
    fields_of_interest = ['request_number', 'principal_investigator',
                        'project_title', 'project_description', 'email']
    project_data = rc_project.export_records(fields=fields_of_interest)
    
    """ Initialize the XNAT interface """
    admin_xnat = xutil.xnat()
    
    """ Grab all existing project IDs """
    existing_projects = admin_xnat.select.projects().get('id')
    
    """ Grab all projects (with proper request codes) in redcap """
    all_project_ids = [p['request_number'] for p in project_data if len(p['request_number']) > 0]
    
    """ Find the project ids not currently in xnat """
    projects_to_insert = list(set(all_project_ids) - set(existing_projects))
    
    
    pis = []
    print("%s: %d project(s) to be imported..." % (time.strftime('%Y-%m-%d %H:%M'), len(projects_to_insert)))
    for project_id in projects_to_insert:
    
Пример #2
0
    body += "End disk usage \n\n"

    """ DCM Relay Error files """
    body += "Begin Error files...\n"
    for err in glob(os.path.expanduser('~/dcmrelay/*.err')):
        text_lines = []
        text_lines.append("Begin %s..." % err)
        out, _ = tail(err, n=20)
        text_lines.append(out)
        text_lines.append("End %s.\n\n" % err)
        body += '\n'.join(text_lines)
    body += "End Error files.\n"

    """ Xnat statistics """
    body += "XNAT system statistics...\n"
    x = xnat()
    body += "# users: %d\n" % len(x.manage.users())
    all_projs = x.select.projects().get()
    body += "# projects: %d\n" % len(all_projs)
    #  There's probably a better way to do this, but for now...
    all_sessions = []
    for p in all_projs:
        proj = x.select.project(p)
        all_sessions.extend(proj.experiments().get())
    body += "# sessions: %d\n" % len(all_sessions)
    #  We could go deeper into database if we wanted...

    body += "Finish at %s" % time.strftime('%H:%M:%S')
    to = ['*****@*****.**', '*****@*****.**']
    sub = "XNAT Health Check %s" % time.strftime('%a %d %b %Y %H:%M')
    mail(to=to, subject=sub, body=body)
Пример #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-


from xnat import util

if __name__ == '__main__':
    x = util.xnat()
    
    all_projs = x.select.projects().get()
    
    print('\n'.join(all_projs))