Mercurial > repos > greg > gene_family_phylogeny_builder
comparison utils.py @ 28:62fe699992a5 draft
Uploaded
author | greg |
---|---|
date | Fri, 12 May 2017 14:13:56 -0400 |
parents | a9d8e2ee41f6 |
children | ae78488e9793 |
comparison
equal
deleted
inserted
replaced
27:6374c987b4a8 | 28:62fe699992a5 |
---|---|
25 fstdout = os.path.join(os.getcwd(), FSTDOUT) | 25 fstdout = os.path.join(os.getcwd(), FSTDOUT) |
26 fhout = open(fstdout, 'wb') | 26 fhout = open(fstdout, 'wb') |
27 return fstderr, fherr, fstdout, fhout | 27 return fstderr, fherr, fstdout, fhout |
28 | 28 |
29 | 29 |
30 def move_directory_files(source_dir, destination_dir): | 30 def move_directory_files(source_dir, destination_dir, copy=False): |
31 source_directory = os.path.abspath(source_dir) | 31 source_directory = os.path.abspath(source_dir) |
32 destination_directory = os.path.abspath(destination_dir) | 32 destination_directory = os.path.abspath(destination_dir) |
33 if not os.path.isdir(destination_directory): | 33 if not os.path.isdir(destination_directory): |
34 os.makedirs(destination_directory) | 34 os.makedirs(destination_directory) |
35 for dir_entry in os.listdir(source_directory): | 35 for dir_entry in os.listdir(source_directory): |
36 source_entry = os.path.join(source_directory, dir_entry) | 36 source_entry = os.path.join(source_directory, dir_entry) |
37 shutil.move(source_entry, destination_directory) | 37 if copy: |
38 shutil.copy(source_entry, destination_directory) | |
39 else: | |
40 shutil.move(source_entry, destination_directory) | |
38 | 41 |
39 | 42 |
40 def run_command(cmd): | 43 def run_command(cmd): |
41 fstderr, fherr, fstdout, fhout = get_response_buffers() | 44 fstderr, fherr, fstdout, fhout = get_response_buffers() |
42 proc = subprocess.Popen(args=cmd, stderr=fherr, stdout=fhout, shell=True) | 45 proc = subprocess.Popen(args=cmd, stderr=fherr, stdout=fhout, shell=True) |