Index: trunk/ippToPsps/jython/fits.py
===================================================================
--- trunk/ippToPsps/jython/fits.py	(revision 38956)
+++ trunk/ippToPsps/jython/fits.py	(revision 38958)
@@ -8,5 +8,5 @@
 
 '''
-FITS file class, for reading silly headers and things
+FITS file class, for reading headers and things
 '''
 class Fits(object):
@@ -35,5 +35,5 @@
        #shutil.copy2(self.originalPath, self.localCopyPath)
 
-       # open the local copy and parse the ridiculou plain-text header
+       # open the local copy and parse the header
        #self.file = open(self.localCopyPath)
        self.file = open(self.originalPath)
@@ -45,24 +45,38 @@
        self.rewindToStart()
 
-
     '''
     Get md5sum for file 
     '''
     def getMd5sum(self):
-    	## memory inefficient all at once read but should be ok...
-    	md5 = hashlib.md5(open(self.originalPath,'rb').read())
-	return md5.hexdigest()
+        mode = "hashlib"
 
-    def getMd5sumShell(self):
-    	md5cmd = "md5sum %s" % (self.originalPath)
-	md5 = Popen(md5cmd, shell=True, stdout=PIPE).stdout.read()
-	return md5[0:32]
+        if mode == "hashlib":
+            ## memory-inefficient all-at-once read
+            ## XXX EAM: do we need to free the loaded file to prevent double-usage of memory
+            md5 = hashlib.md5(open(self.originalPath,'rb').read())
+            return md5.hexdigest()
 
-    def getMd5sumFile(self):
-    	## unclear if rb by default for file so maybe not best
-        md5 = hashlib.md5(self.file.read())
-	## if used, then need to move file pointer back to the start of the file for others to use
-	self.rewindToStart()
-        return md5.hexdigest()
+        if mode == "shell":
+            ## use external shell md5sum command: error handline needs to check the exit status
+            md5cmd = "md5sum %s" % (self.originalPath)
+            p = Popen(md5cmd, shell=True, stdout=PIPE)
+            p.wait()
+            if p.returncode < 0:
+                self.logger.errorPair("md5sum crashed: ", md5cmd)
+                os._exit(1)
+                
+            if p.returncode > 0:
+                self.logger.errorPair("md5sum error : ", md5cmd)
+                os._exit(1)
+
+            md5 = p.stdout.read()
+            return md5[0:32]
+
+        if mode == "file":
+            ## it is unclear if the open mode is 'rb' by default for file; this may fail otherwise
+            md5 = hashlib.md5(self.file.read())
+            ## if used, then need to move file pointer back to the start of the file for others to use
+            self.rewindToStart()
+            return md5.hexdigest()
 
     '''
