diff data_stores/kipper.py @ 2:269d246ce6d0 draft default tip

Uploaded
author damion
date Fri, 23 Oct 2015 17:53:29 -0400
parents 5c5027485f7d
children
line wrap: on
line diff
--- a/data_stores/kipper.py	Sun Aug 09 16:07:50 2015 -0400
+++ b/data_stores/kipper.py	Fri Oct 23 17:53:29 2015 -0400
@@ -936,12 +936,23 @@
 			
 		temp.close()
 		
+		import stat
+		
+		# TEST sort failure: set it so temp file is read only.
+		#mode = os.stat(temp.name)[stat.ST_MODE]
+		#os.chmod(temp.name,mode & ~0222)
+		
 		# Is this a consideration for natural sort in Python vs bash sort?:
 		# *** WARNING *** The locale specified by the environment affects sort order.
 		# Set LC_ALL=C to get the traditional sort order that uses native byte values.  
 		#-s stable; -f ignore case; V natural sort (versioning) ; -k column, -t tab delimiter
-		sort_a = subprocess.call(['sort', '-sfV', '-t\t', '-k1,1', '-o',temp.name, temp.name])
-
+		try:
+			subprocess.check_call(['sort', '-sfV', '-t\t', '-k1,1', '-o',temp.name, temp.name])
+		except subprocess.CalledProcessError as e:
+			stop_err("Error: Sort of import file could not be completed, sort() returned error code " + str(e.returncode) )
+		except OSError as e:
+			stop_err("Error: Sort of import file could not be completed, sort command or %s file not found?" % temp.name)
+			
 		return temp #Enables temp file name to be used by caller.