Selaa lähdekoodia

Making sure *nix systems are running with shell=False

NIX User 5 vuotta sitten
vanhempi
commit
7702abbf22
1 muutettua tiedostoa jossa 13 lisäystä ja 3 poistoa
  1. 13 3
      DICOMtools/loadDicom.py

+ 13 - 3
DICOMtools/loadDicom.py

@@ -415,15 +415,25 @@ def isDicom(file):
     return dt=='DICM'
     return dt=='DICM'
 
 
 
 
-def dicomValue(file,tag,seqTag=None,shell=False):
+def dicomValue(fileName,tag,seqTag=None,shell=False):
     #query dicom value of file using dcmdump (DCMTK routine)
     #query dicom value of file using dcmdump (DCMTK routine)
+
+    #shell must be false for *nix
+    if os.name=="posix":
+        shell=False
+
+    debug=False
     dcmdump=os.path.join(os.environ['SLICER_HOME'],"bin","dcmdump")
     dcmdump=os.path.join(os.environ['SLICER_HOME'],"bin","dcmdump")
+    
     try:
     try:
-        out=subprocess.check_output([dcmdump,'+p','+P',tag,file],shell=shell)
+        if debug:
+            print("Calling {}".format(dcmdump))
+        out=subprocess.check_output([dcmdump,'+p','+P',tag,fileName],shell=shell)
+        if debug:
+            print("Got {}".format(out))
     except subprocess.CalledProcessError as e:
     except subprocess.CalledProcessError as e:
         return None
         return None
     
     
-    debug=False
     
     
     if debug:
     if debug:
         print("Tag {} Line '{}'").format(tag,out)
         print("Tag {} Line '{}'").format(tag,out)