Mercurial > hg > orthanc
annotate Resources/Samples/Python/DeleteAllStudies.py @ 3794:08ee586e2b01
fix address
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 26 Mar 2020 15:53:54 +0100 |
parents | 94f4a18a79cc |
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 |
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)) |