Mercurial > hg > orthanc
annotate OrthancServer/Resources/Samples/Python/DeleteAllStudies.py @ 4125:06b70f1063c0 framework-gpl
archive branch with GPL-licensed Orthanc framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 20:27:16 +0200 |
parents | d25f4c0fa160 |
children | d9473bd5ed43 |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3172
diff
changeset
|
7 # Copyright (C) 2017-2020 Osimis S.A., Belgium |
3172
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 # |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 # 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
|
10 # 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
|
11 # 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
|
12 # License, or (at your option) any later version. |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 # |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 # 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
|
15 # WITHOUT ANY WARRANTY; without even the implied warranty of |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 # 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
|
17 # General Public License for more details. |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 # |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 # 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
|
20 # 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
|
21 |
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 import os |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 import os.path |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 import sys |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 import RestToolbox |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 def PrintHelp(): |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 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
|
31 print('Usage: %s <URL>\n' % sys.argv[0]) |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 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
|
33 exit(-1) |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 if len(sys.argv) != 2: |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 PrintHelp() |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 URL = sys.argv[1] |
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 for study in RestToolbox.DoGet('%s/studies' % URL): |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 print('Removing study: %s' % study) |
b626fefdb507
Resources/Samples/Python/DeleteAllStudies.py
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 RestToolbox.DoDelete('%s/studies/%s' % (URL, study)) |