comparison Resources/Samples/Python/DeleteAllStudies.py @ 3172:b626fefdb507

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