Ensure that the sequencing run is completed, and then copy the directory to :self.path

def fastqlinker(self):
        """Ensure that the sequencing run is completed, and then copy the directory to :self.path"""
        # Module-specific imports
        import time
        import re
        import shutil
        import errno
        # Glob for .gz files in the appropriate subfolder of :miseqfolder. Discard 'Undetermined' files
        gzfiles = [gzfile for gzfile in glob('{}Data/Intensities/BaseCalls/*.gz'.format(self.miseqfolder))
                   if "Undetermined" not in gzfile]
        # While loop to wait until run is complete - two .gz files are created for each sample
        while len(gzfiles) < 2 * self.samplecount:
            printtime('Waiting for run to finish. Currently, {} out of a total of {} fastq.gz files '
                      'have been created'.format(len(gzfiles), 2 * self.samplecount), self.start)
            # Sleep for five minutes
            time.sleep(300)
            # Check the number of .gz files again
            gzfiles = [gzfile for gzfile in glob('{}Data/Intensities/BaseCalls/*.gz'.format(self.miseqfolder))
                       if "Undetermined" not in gzfile]
        # Iterate through each .gz file
        for gzfile in sorted(gzfiles):
            # Extract the strain name from the .gz file
            filename = re.split("_S\d+_L001", os.path.basename(gzfile))[0]
            # Make the outputdir variable
            outputdir = '{}{}'.format(self.path, filename)
            make_path(outputdir)
            # Don't link the files if they have already been linked
            if len(glob('{}/*fastq*'.format(outputdir))) < self.numreads:
                try:
                    # Link the .gz files to :self.path/:filename
                    os.symlink(gzfile, '{}/{}'.format(outputdir, os.path.basename(gzfile)))
                # Except os errors
                except OSError as exception:
                    # If there is an exception other than the file exists, raise it
                    if exception.errno != errno.EEXIST:
                        raise
        # Add the location/name of the fastq files to the metadata object
        for sample in self.metadata.runmetadata.samples:
            # Find any fastq files with the sample name
            fastqfiles = sorted(glob('{}{}/{}*.fastq*'.format(self.path, sample.name, sample.name)))
            fastqfiles = [fastq for fastq in fastqfiles if 'trimmed' not in fastq]
            # Update the metadata with the path/name of the fastq files
            sample.general.fastqfiles = fastqfiles
        # Copy the GenerateFASTQRunStatistics.xml, RunInfo.xml, and SampleSheet.csv to self.path
        map(lambda x: shutil.copyfile('{}/{}'.format(self.miseqfolder, x), '{}{}'.format(self.path, x))
            # Don't copy if the file is already present
            if not os.path.isfile('{}{}'.format(self.path, x)) else x,
            # List of the files of interest
            ['GenerateFASTQRunStatistics.xml', 'RunInfo.xml', 'SampleSheet.csv'])