checkData.ipynb 5.0 KB

#load required libraries
import sys
import os
import chardet
import json
import re

#you should get nixSuite via git clone https://git0.fmf.uni-lj.si/studen/nixSuite.git
#if you don't put it to $HOME/software/src/, you should update the path
nixSuite=os.path.join(os.path.expanduser('~'),'software','src','nixSuite')
sys.path.append(os.path.join(nixSuite,'wrapper'))
import nixWrapper
nixWrapper.loadLibrary('labkeyInterface')
import labkeyInterface
import labkeyDatabaseBrowser
import labkeyFileBrowser

def connectDB(server):
    #check connectivity. This checks the configuration in $HOME/.labkey/network.json, 
    #where paths to certificates are stored
    net=labkeyInterface.labkeyInterface()
    fconfig=os.path.join(os.path.expanduser('~'),'.labkey','{}.json'.format(server))
    net.init(fconfig)
    #this reports the certificate used
    try:
        print('Using: {}'.format(net.connectionConfig['SSL']['user']))
    except KeyError:
        pass
    #This gets a deafult CSRF code; It should report user name plus a long string of random hex numbers
    net.getCSRF()
    db=labkeyDatabaseBrowser.labkeyDB(net)
    fb=labkeyFileBrowser.labkeyFileBrowser(net)
    return db,fb
loadLibrary
remoteSourcesURL https://git0.fmf.uni-lj.si/studen/nixSuite/raw/master/remoteResources/resources.json
{'labkeyInterface': {'url': 'https://git0.fmf.uni-lj.si/studen/labkeyInterface/archive/master.zip', 'branch': 'master', 'modules': []}, 'irAEMM': {'url': 'https://git0.fmf.uni-lj.si/studen/iraemm/archive/master.zip', 'branch': 'master', 'modules': ['iraemmBrowser']}, 'SlicerLabkeyExtension': {'url': 'https://git0.fmf.uni-lj.si/studen/SlicerLabkeyExtension/archive/SlicerExtensionIndex.zip', 'branch': 'SlicerExtensionIndex', 'modules': ['labkeyBrowser']}, 'limfomiPET': {'url': 'https://git0.fmf.uni-lj.si/studen/limfomiPET/archive/master.zip', 'branch': 'master', 'modules': ['imageBrowser']}, 'parseConfig': {'url': 'https://git0.fmf.uni-lj.si/studen/parseConfig/archive/master.zip', 'branch': 'master', 'modules': []}, 'orthancInterface': {'url': 'https://git0.fmf.uni-lj.si/studen/orthancInterface/archive/master.zip', 'branch': 'master', 'modules': []}}
{'url': 'https://git0.fmf.uni-lj.si/studen/labkeyInterface/archive/master.zip', 'branch': 'master', 'modules': []}
File  C:\Users\studen\temp\labkeyInterface.zip: True
#check if all entries from a list appear in the matching dataset
db=connectDB('onko-nix')[0]
project='limfomiPET/Study'
query='imageTransferReport'

dl=db.selectRows(project,'lists',query,[])

startWith=0
rows=dl['rows'][startWith:]
filterArray=['participantCode','imagingVisitId']
n=len(rows)+startWith
i=startWith
for r in rows:
    qfilter=[{'variable':x,'value':'{}'.format(r[x]),'oper':'eq'} for x in filterArray]
    ds=db.selectRows(project,'study',query,qfilter)
    d=[r[x] for x in filterArray]
    if len(ds['rows'])!=1:
        print('Got {} rows for {}/{}'.format(len(ds['rows']),d[0],d[1]))
        for q in ds['rows']:
            print(q)
        break
    i+=1
    if i%10 == 0:
        print('{}/{}'.format(i,n))
    #else:
    #    print('Found {}/{}'.format(d[0],d[1]))
    
User: andrej studen CSRF: f3f644c27eed6bbfdcb06953e8a71142
260/393
270/393
280/393
290/393
300/393
310/393
320/393
330/393
340/393
350/393
360/393
370/393
380/393
390/393