diff DownloadFiles.py @ 3:fe42761670f1 draft default tip

Uploaded
author geert-vandeweyer
date Tue, 25 Mar 2014 13:15:25 -0400
parents 837fafa672d2
children
line wrap: on
line diff
--- a/DownloadFiles.py	Tue May 07 09:02:02 2013 -0400
+++ b/DownloadFiles.py	Tue Mar 25 13:15:25 2014 -0400
@@ -39,9 +39,16 @@
 	    storedir="%s/%s/%s/" %(ftpdirconfig,useremail,folder)
 	    subdir = folder
     if not os.path.exists(ftpdir):
-    	os.makedirs(ftpdir)
+    	try:
+		os.makedirs(ftpdir)
+	except:
+		stop_err("User dir on FTP could not be created: %s" % (ftpdir))
     if not os.path.exists(storedir):
-    	os.makedirs(storedir)
+    	
+	try:
+		os.makedirs(storedir)
+	except:
+		stop_err("Target dir could not be created: %s" % (storedir))
 	
     while filecounter < len(sys.argv):
 	inp = sys.argv[filecounter]
@@ -51,10 +58,16 @@
 	name = name.replace('@','_AT_')
 	ext = sys.argv[(filecounter+2)]
 	# copy files to tmp dir & filenames
-	os.system("cp '%s' '%s/%s.%s'" %(inp, storedir,name,ext))
+	try:
+		os.system("cp '%s' '%s/%s.%s'" %(inp, storedir,name,ext))
+	except:
+		stop_err("Copy failed for target file : %s/%s.%s. Command was\ncp '%s' '%s/%s.%s'" % (storedir,name,ext,inp,storedir,name,ext))
 	## gzip if fastq/fastqsanger/vcf
 	if ( ext == "fastq" or ext == "fastqsanger" or ext == "vcf" or ext == "sam" or ext == "txt"): 
-		os.system("gzip -9 '%s/%s.%s'" %(storedir,name,ext))
+		try:
+			os.system("gzip -9 '%s/%s.%s'" %(storedir,name,ext))
+		except:
+			stop_err("Compression of %s/%s.%s failed." % (storedir,name,ext))
 	fout.write("<li>%s.%s</li>" %(name,ext))
 	filecounter +=3