def stage_output(self):
        """Copy data products to final output directory."""

        if self.workdir == self.outdir:
            return
        elif not os.path.isdir(self.workdir):
            self.logger.error('Working directory does not exist.')
            return

        regex = self.config['fileio']['outdir_regex']
        savefits = self.config['fileio']['savefits']
        files = os.listdir(self.workdir)
        self.logger.info('Staging files to %s', self.outdir)

        fitsfiles = []
        for c in self.components:
            for f in c.files.values():

                if f is None:
                    continue

                fitsfiles += [os.path.basename(f)]

        for f in files:

            wpath = os.path.join(self.workdir, f)
            opath = os.path.join(self.outdir, f)

            if not utils.match_regex_list(regex, os.path.basename(f)):
                continue
            if os.path.isfile(opath) and filecmp.cmp(wpath, opath, False):
                continue
            if not savefits and f in fitsfiles:
                continue


            self.logger.debug('Copying ' + f)
            self.logger.info('Copying ' + f)
            shutil.copy(wpath, self.outdir)

        self.logger.info('Finished.')
def stage_output ( self ) : if self . workdir == self . outdir : return elif not os . path . isdir ( self . workdir ) : self . logger . error ( 'Working directory does not exist.' ) return regex = self . config [ 'fileio' ] [ 'outdir_regex' ] savefits = self . config [ 'fileio' ] [ 'savefits' ] files = os . listdir ( self . workdir ) self . logger . info ( 'Staging files to %s' , self . outdir ) fitsfiles = [ ] for c in self . components : for f in c . files . values ( ) : if f is None : continue fitsfiles += [ os . path . basename ( f ) ] for f in files : wpath = os . path . join ( self . workdir , f ) opath = os . path . join ( self . outdir , f ) if not utils . match_regex_list ( regex , os . path . basename ( f ) ) : continue if os . path . isfile ( opath ) and filecmp . cmp ( wpath , opath , False ) : continue if not savefits and f in fitsfiles : continue self . logger . debug ( 'Copying ' + f ) self . logger . info ( 'Copying ' + f ) shutil . copy ( wpath , self . outdir ) self . logger . info ( 'Finished.' )
Copy data products to final output directory.