annotate OrthancServer/Resources/Samples/Python/DeleteAllStudies.py @ 5491:42e6593aa78e

fix for Stone
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jan 2024 07:21:50 +0100
parents 48b8dae6dc77
children f7adfb22e20e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
7 # Copyright (C) 2017-2024 Osimis S.A., Belgium
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
8 # 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
9 #
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # 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
11 # 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
12 # 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
13 # License, or (at your option) any later version.
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 #
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # 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
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # 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
18 # General Public License for more details.
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 #
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 # 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
21 # 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
22
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 import os
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 import os.path
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 import sys
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 import RestToolbox
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 def PrintHelp():
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 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
32 print('Usage: %s <URL>\n' % sys.argv[0])
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 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
34 exit(-1)
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 if len(sys.argv) != 2:
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 PrintHelp()
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 URL = sys.argv[1]
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 for study in RestToolbox.DoGet('%s/studies' % URL):
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 print('Removing study: %s' % study)
b626fefdb507 Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 RestToolbox.DoDelete('%s/studies/%s' % (URL, study))