本文整理汇总了Python中dax.XnatUtils.list_experiments方法的典型用法代码示例。如果您正苦于以下问题:Python XnatUtils.list_experiments方法的具体用法?Python XnatUtils.list_experiments怎么用?Python XnatUtils.list_experiments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dax.XnatUtils
的用法示例。
在下文中一共展示了XnatUtils.list_experiments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_args
# 需要导入模块: from dax import XnatUtils [as 别名]
# 或者: from dax.XnatUtils import list_experiments [as 别名]
p.add_argument('-c', '--cred', dest='password',
help='Database username password', required=True)
return p.parse_args()
if __name__ == '__main__':
ARGS = parse_args()
# Try to connect and exit if we catch the most common OperationalError
# will add more as they are encountered.
try:
conn = psycopg2.connect(dbname=ARGS.dbname,
password=ARGS.password, user=ARGS.user)
except OperationalError as operr:
print "FATAL: Caught an OperationalError. Please check your dbname, " \
"host ip address, username, and password"
sys.exit(1)
cur = conn.cursor()
XNAT = XnatUtils.get_interface()
PROJECTS = XNAT.select('/projects').get()
for PROJECT in PROJECTS:
sessions = XnatUtils.list_experiments(XNAT, PROJECT)
for session in sessions:
if '-x-' in session['session_label']:
sys.stdout.write('Found corrupt assessors %s for project %s\n' % (session['session_label'],
PROJECT))
cur.execute("""DELETE FROM xnat_experimentdata where label=(%s)""",(session['session_label'],))
conn.commit()
XNAT.disconnect()
conn.close()