generated from FNNDSC/python-chrisapp-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chris_pacs_service.py
36 lines (30 loc) · 1.04 KB
/
chris_pacs_service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
from chrisclient import request
from loguru import logger
import sys
LOG = logger.debug
logger_format = (
"<green>{time:YYYY-MM-DD HH:mm:ss}</green> │ "
"<level>{level: <5}</level> │ "
"<yellow>{name: >28}</yellow>::"
"<cyan>{function: <30}</cyan> @"
"<cyan>{line: <4}</cyan> ║ "
"<level>{message}</level>"
)
logger.remove()
logger.add(sys.stderr, format=logger_format)
class PACSClient(object):
def __init__(self, url: str, username: str, password: str):
self.cl = request.Request(username, password)
self.pacs_series_search_url = f"{url}search/"
def get_pacs_files(self, params: dict):
l_dir_path = set()
resp = self.cl.get(self.pacs_series_search_url,params)
LOG(resp)
for item in resp.items:
for link in item.links:
folder = self.cl.get(link.href)
for item_folder in folder.items:
path = item_folder.data.path.value
l_dir_path.add(path)
return ','.join(l_dir_path)