Mercurial > repos > greg > gene_family_aligner
comparison utils.py @ 56:f782812220e1 draft
Uploaded
author | greg |
---|---|
date | Thu, 05 Oct 2017 14:14:56 -0400 |
parents | ca7fb79c2eec |
children | 8d71c1dff476 |
comparison
equal
deleted
inserted
replaced
55:259901da9ed5 | 56:f782812220e1 |
---|---|
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) |