comparison OrthancServer/Resources/Samples/Python/ArchiveAllPatients.py @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Resources/Samples/Python/ArchiveAllPatients.py@94f4a18a79cc
children d9473bd5ed43
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
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-2020 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('Download one ZIP archive for all the patients stored in Orthanc\n')
31 print('Usage: %s <URL> <Target>\n' % sys.argv[0])
32 print('Example: %s http://127.0.0.1:8042/ /tmp/Archive.zip\n' % sys.argv[0])
33 exit(-1)
34
35 if len(sys.argv) != 3:
36 PrintHelp()
37
38 URL = sys.argv[1]
39 TARGET = sys.argv[2]
40
41 patients = RestToolbox.DoGet('%s/patients' % URL)
42
43 print('Downloading ZIP...')
44 zipContent = RestToolbox.DoPost('%s/tools/create-archive' % URL, patients)
45
46 # Write the ZIP archive at the proper location
47 with open(TARGET, 'wb') as f:
48 f.write(zipContent)