Mercurial > repos > greg > gene_family_integrator
comparison utils.py @ 27:346dc0d9af6f draft
Uploaded
author | greg |
---|---|
date | Thu, 05 Oct 2017 14:21:14 -0400 |
parents | 4234f6791a4a |
children | 58cbad7dc6d1 |
comparison
equal
deleted
inserted
replaced
26:b91bf5a51d38 | 27:346dc0d9af6f |
---|---|
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, copy=False): | 30 def move_directory_files(source_dir, destination_dir, copy=False, remove_source_dir=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 if copy: | 37 if copy: |
38 shutil.copy(source_entry, destination_directory) | 38 shutil.copy(source_entry, destination_directory) |
39 else: | 39 else: |
40 shutil.move(source_entry, destination_directory) | 40 shutil.move(source_entry, destination_directory) |
41 if remove_source_dir: | |
42 os.rmdir(source_directory) | |
41 | 43 |
42 | 44 |
43 def run_command(cmd): | 45 def run_command(cmd): |
44 fstderr, fherr, fstdout, fhout = get_response_buffers() | 46 fstderr, fherr, fstdout, fhout = get_response_buffers() |
45 proc = subprocess.Popen(args=cmd, stderr=fherr, stdout=fhout, shell=True) | 47 proc = subprocess.Popen(args=cmd, stderr=fherr, stdout=fhout, shell=True) |