Skip to content

Commit 27b5c78

Browse files
committed
Use new session utility functions in cli
1 parent 094b583 commit 27b5c78

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/dicomweb_client/cli.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515

1616
from dicomweb_client.api import DICOMwebClient, load_json_dataset
1717
from dicomweb_client.log import configure_logging
18-
from dicomweb_client.session_utils import create_session_from_user_pass, \
19-
add_certs_to_session
18+
from dicomweb_client.session_utils import (
19+
create_session,
20+
create_session_from_user_pass,
21+
add_certs_to_session,
22+
)
2023

2124
logger = logging.getLogger(__name__)
2225

@@ -646,19 +649,22 @@ def main():
646649
parser = _get_parser()
647650
args = parser.parse_args()
648651

652+
configure_logging(args.logging_verbosity)
653+
649654
if args.username:
650655
if not args.password:
651656
message = 'Enter password for user "{0}": '.format(args.username)
652657
args.password = getpass.getpass(message)
658+
session = create_session_from_user_pass(args.username, args.password)
659+
else:
660+
session = create_session()
653661

654-
configure_logging(args.logging_verbosity)
655662
try:
656-
session = create_session_from_user_pass(args.username, args.password)
657663
session = add_certs_to_session(session, args.ca_bundle, args.cert)
664+
session = add_headers_to_session(session, headers=_create_headers(args))
658665
client = DICOMwebClient(
659666
args.url,
660667
session=session,
661-
headers=_create_headers(args),
662668
chunk_size=args.chunk_size
663669
)
664670
args.func(client, args)

0 commit comments

Comments
 (0)