Exemplo n.º 1
0
    def run_transport(self):
        cmd = self.generate_rsync_command()
        logger.info('Running %s: %s', self.fileset.friendly_name,
                    argsjoin(cmd))

        # Close all DB connections before continuing with the rsync
        # command. Since it may take a while, the connection could get
        # dropped and we'd have issues later on.
        connections.close_all()

        stderr = []
        try:
            output = check_output(cmd, return_stderr=stderr).decode('utf-8')
            returncode = 0
        except CalledProcessError as e:
            returncode, output = e.returncode, e.output
            errstr = RSYNC_EXITCODES.get(returncode, 'Return code not matched')
            logging.warning('code: %s\nmsg: %s\nexception: %s', returncode,
                            errstr, str(e))
            if returncode not in RSYNC_HARMLESS_EXITCODES:
                raise

        logger.info(
            'Rsync exited with code %s for %s:'
            '\n\n(stdout)\n\n%s\n(stderr)\n\n%s', returncode,
            self.fileset.friendly_name, output,
            b'\n'.join(stderr).decode('utf-8', 'replace'))
Exemplo n.º 2
0
    def run_transport(self):
        # FIXME: duplicate code with transport_rsync.Config.run_transport()
        cmd = self.generate_cmd()
        env = self.generate_env()
        logger.info('Running %s: %s', self.fileset.friendly_name,
                    argsjoin(cmd))

        # Close all DB connections before continuing with the rsync
        # command. Since it may take a while, the connection could get
        # dropped and we'd have issues later on.
        connections.close_all()

        stderr = []
        try:
            # FIXME: do we want timeout handling here?
            output = check_output(cmd, env=env,
                                  return_stderr=stderr).decode('utf-8')
        except CalledProcessError as e:
            logging.warning('Failure during exec %r: %s', argsjoin(cmd),
                            str(e))
            raise

        logger.info(
            'Exec success for %s transport:\n\n(stdout)\n\n%s\n(stderr)\n\n%s',
            self.fileset.friendly_name, output,
            b'\n'.join(stderr).decode('utf-8', 'replace'))
Exemplo n.º 3
0
 def __perform_system_command(self, cmd):
     """
     Do exec command, expect 0 return value, convert output to utf-8.
     """
     try:
         output = check_output(cmd)
     except CalledProcessError as e:
         logger.info('Non-zero exit after cmd {!r}: {}'.format(cmd, e))
         raise
     return output.decode('utf-8')  # expect valid ascii/utf-8