Commit 11b87b24 authored by Franziska Koehn's avatar Franziska Koehn
Browse files

search-function extended. takes now different root-types and requests for given fields

parent 6dc0a173
......@@ -126,16 +126,14 @@ def download(result, dest_folder='', host=None, cb=(lambda *_: None), cb_args=()
def search_for_mrScanData(host, constraints, user, passw):
get_credentials(username=user, password=passw, force=True)
return search_for(host, 'xnat:mrScanData', constraints)
def search_for(host, root_element, constraints):
def search_for(host, root_element, constraints, result_fields, user, passw):
from pyxnat import Interface
from pyxnat.core import errors
from tempfile import mkdtemp
from httplib2 import ServerNotFoundError
get_credentials(username=user, password=passw, force=True)
user, passw = get_credentials()
......@@ -147,7 +145,7 @@ def search_for(host, root_element, constraints):
except IndexError:
return "ServerNotFoundError" #TODO Eigene Fehlerklasse
search_fields = [
main_fields = [
'xnat:mrSessionData/PROJECT', #project id
'xnat:mrSessionData/SUBJECT_ID', #subject id
'xnat:mrSessionData/SESSION_ID', #experiment id
......@@ -155,6 +153,8 @@ def search_for(host, root_element, constraints):
'xnat:mrScanData/TYPE', #scan type
search_fields = main_fields+result_fields
result = []
......@@ -35,7 +35,8 @@ class XnatSearchApp(gtk.Window):
def on_search_query(_, host, credentials, query):
import xnat_search
user, _, passw = credentials.partition(":")
query_results = xnat_search.search_for_mrScanData(host, query, user, passw)
query_results = xnat_search.search_for(host, 'xnat:mrScanData', query, requested_fields, user, passw)
xnat_search.HOST = host
#TODO catch errors
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment