Mercurial > hg > orthanc-ohif
annotate Resources/ClearMetadataCache.py @ 44:9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 03 May 2024 13:02:51 +0200 |
parents | |
children |
rev | line source |
---|---|
44
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python3 |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 import argparse |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 import requests |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 parser = argparse.ArgumentParser(description = 'Clear the cache of the OHIF plugin (for "dicom-json" data source).') |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 parser.add_argument('--url', |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 default = 'http://localhost:8042', |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 help = 'URL to the REST API of the Orthanc server') |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 parser.add_argument('--username', |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 default = 'orthanc', |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 help = 'Username to the REST API') |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 parser.add_argument('--password', |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 default = 'orthanc', |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 help = 'Password to the REST API') |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 args = parser.parse_args() |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 auth = requests.auth.HTTPBasicAuth(args.username, args.password) |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 METADATA = '4202' |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 for instance in requests.get('%s/instances' % args.url, auth=auth).json(): |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 if METADATA in requests.get('%s/instances/%s/metadata' % (args.url, instance), auth=auth).json(): |
9afd691bfb74
added tags: RescaleIntercept, RescaleSlope, and NumberOfFrames
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 requests.delete('%s/instances/%s/metadata/%s' % (args.url, instance, METADATA), auth=auth) |