]> Creatis software - gdcm.git/blob - gdcmPython/demo/load.py
0b13db8d9769904390fcd23907a3da573242e9ca
[gdcm.git] / gdcmPython / demo / load.py
1 import os, sys
2
3 ### Defaulting the path to the dictionaries
4 # WARNING: this needs to be done before importation of gdcm !
5 # FIXME: this needs to be put in a wrapper of the swig generated
6 #                       shadow classes (say Pygdcm.py?)
7 try:
8         os.environ["GDCM_DICT_PATH"]
9 except KeyError:
10         os.environ["GDCM_DICT_PATH"]="../../Dicts/"
11
12 ### When not properly installed (like in a cvs hierachy) try
13 #        to handle properly the import of gdcm
14 try:
15         import gdcm
16 except ImportError:
17         import sys, os
18         PreInstallPath = os.path.join(os.getcwd(), "..")
19         sys.path.append(PreInstallPath)
20         try:
21                 import gdcm
22         except ImportError,e:
23                 raise ImportError, "gdcm extension module not found"
24                 sys.exit()
25
26 ### Get filename from command line or default it
27 try:
28         FileName = sys.argv[1]
29 except IndexError:
30         FileName = os.path.join("..", "..", "Test", "test.acr")
31 if not os.path.isfile(FileName):
32         print "Cannot open file ", FileName
33         sys.exit()