comparison DownloadFiles.py @ 3:fe42761670f1 draft default tip

Uploaded
author geert-vandeweyer
date Tue, 25 Mar 2014 13:15:25 -0400
parents 837fafa672d2
children
comparison
equal deleted inserted replaced
2:837fafa672d2 3:fe42761670f1
37 storedir="%s/%s/%s/" %(ftpdirconfig,useremail,date) 37 storedir="%s/%s/%s/" %(ftpdirconfig,useremail,date)
38 else: 38 else:
39 storedir="%s/%s/%s/" %(ftpdirconfig,useremail,folder) 39 storedir="%s/%s/%s/" %(ftpdirconfig,useremail,folder)
40 subdir = folder 40 subdir = folder
41 if not os.path.exists(ftpdir): 41 if not os.path.exists(ftpdir):
42 os.makedirs(ftpdir) 42 try:
43 os.makedirs(ftpdir)
44 except:
45 stop_err("User dir on FTP could not be created: %s" % (ftpdir))
43 if not os.path.exists(storedir): 46 if not os.path.exists(storedir):
44 os.makedirs(storedir) 47
48 try:
49 os.makedirs(storedir)
50 except:
51 stop_err("Target dir could not be created: %s" % (storedir))
45 52
46 while filecounter < len(sys.argv): 53 while filecounter < len(sys.argv):
47 inp = sys.argv[filecounter] 54 inp = sys.argv[filecounter]
48 name = sys.argv[(filecounter+1)] 55 name = sys.argv[(filecounter+1)]
49 name = name.replace(':','_') 56 name = name.replace(':','_')
50 name = name.replace(' ','_') 57 name = name.replace(' ','_')
51 name = name.replace('@','_AT_') 58 name = name.replace('@','_AT_')
52 ext = sys.argv[(filecounter+2)] 59 ext = sys.argv[(filecounter+2)]
53 # copy files to tmp dir & filenames 60 # copy files to tmp dir & filenames
54 os.system("cp '%s' '%s/%s.%s'" %(inp, storedir,name,ext)) 61 try:
62 os.system("cp '%s' '%s/%s.%s'" %(inp, storedir,name,ext))
63 except:
64 stop_err("Copy failed for target file : %s/%s.%s. Command was\ncp '%s' '%s/%s.%s'" % (storedir,name,ext,inp,storedir,name,ext))
55 ## gzip if fastq/fastqsanger/vcf 65 ## gzip if fastq/fastqsanger/vcf
56 if ( ext == "fastq" or ext == "fastqsanger" or ext == "vcf" or ext == "sam" or ext == "txt"): 66 if ( ext == "fastq" or ext == "fastqsanger" or ext == "vcf" or ext == "sam" or ext == "txt"):
57 os.system("gzip -9 '%s/%s.%s'" %(storedir,name,ext)) 67 try:
68 os.system("gzip -9 '%s/%s.%s'" %(storedir,name,ext))
69 except:
70 stop_err("Compression of %s/%s.%s failed." % (storedir,name,ext))
58 fout.write("<li>%s.%s</li>" %(name,ext)) 71 fout.write("<li>%s.%s</li>" %(name,ext))
59 filecounter +=3 72 filecounter +=3
60 73
61 fout.write("</ol></p>") 74 fout.write("</ol></p>")
62 fout.write("<p>Info: Files written to the '%s' subdirectory in your FTP account</p></body></html>" %(subdir)) 75 fout.write("<p>Info: Files written to the '%s' subdirectory in your FTP account</p></body></html>" %(subdir))