Mercurial > hg > orthanc
annotate OrthancServer/Resources/Samples/Python/DeleteAllStudies.py @ 5640:f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 21:19:57 +0200 |
parents | 48b8dae6dc77 |
children |
rev | line source |
---|---|
3172
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/python |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 # Orthanc - A Lightweight, RESTful DICOM Store |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 # Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
7 # Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
8 # Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
9 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3172
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 # |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 # This program is free software: you can redistribute it and/or |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 # modify it under the terms of the GNU General Public License as |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 # published by the Free Software Foundation, either version 3 of the |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 # License, or (at your option) any later version. |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 # |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 # This program is distributed in the hope that it will be useful, but |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 # WITHOUT ANY WARRANTY; without even the implied warranty of |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 # General Public License for more details. |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 # |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 # You should have received a copy of the GNU General Public License |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 import os |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 import os.path |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 import sys |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 import RestToolbox |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 def PrintHelp(): |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 print('Delete all the imaging studies that are stored in Orthanc\n') |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 print('Usage: %s <URL>\n' % sys.argv[0]) |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 print('Example: %s http://127.0.0.1:8042/\n' % sys.argv[0]) |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 exit(-1) |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 if len(sys.argv) != 2: |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 PrintHelp() |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 URL = sys.argv[1] |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 for study in RestToolbox.DoGet('%s/studies' % URL): |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 print('Removing study: %s' % study) |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 RestToolbox.DoDelete('%s/studies/%s' % (URL, study)) |