当前位置: 首页>>代码示例>>Python>>正文


Python LOG.info方法代码示例

本文整理汇总了Python中twindb_backup.LOG.info方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.info方法的具体用法?Python LOG.info怎么用?Python LOG.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twindb_backup.LOG的用法示例。


在下文中一共展示了LOG.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: storage_server

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def storage_server(docker_client, container_network):

    bootstrap_script = '/twindb-backup/support/bootstrap/storage_server.sh'
    container = get_container(
        'storage_server',
        docker_client,
        container_network,
        bootstrap_script=bootstrap_script,
        image="centos:centos7",
        last_n=2
    )

    timeout = time.time() + 30 * 60

    while time.time() < timeout:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        if sock.connect_ex((container['ip'], 22)) == 0:
            break
        time.sleep(1)

    yield container

    if container:
        LOG.info('Removing container %s', container['Id'])
        docker_client.api.remove_container(container=container['Id'],
                                           force=True)
开发者ID:twindb,项目名称:backup,代码行数:28,代码来源:conftest.py

示例2: restore_mysql

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def restore_mysql(ctx, dst, backup_copy, cache):
    """Restore from mysql backup"""
    LOG.debug('mysql: %r', ctx.obj['twindb_config'])

    if not backup_copy:
        LOG.info('No backup copy specified. Choose one from below:')
        list_available_backups(ctx.obj['twindb_config'])
        exit(1)

    try:
        ensure_empty(dst)

        incomplete_copy = MySQLCopy(
            path=backup_copy
        )
        dst_storage = ctx.obj['twindb_config'].destination(
            backup_source=incomplete_copy.host
        )
        mysql_status = MySQLStatus(dst=dst_storage)

        copies = [
            cp for cp in mysql_status if backup_copy.endswith(cp.name)
        ]
        try:
            copy = copies.pop(0)
        except IndexError:
            raise TwinDBBackupError(
                'Can not find copy %s in MySQL status. '
                'Inspect output of `twindb-backup status` and verify '
                'that correct copy is specified.'
                % backup_copy
            )
        if copies:
            raise TwinDBBackupError(
                'Multiple copies match pattern %s. Make sure you give unique '
                'copy name for restore.'
            )

        if cache:
            restore_from_mysql(
                ctx.obj['twindb_config'],
                copy,
                dst,
                cache=Cache(cache)
            )
        else:
            restore_from_mysql(ctx.obj['twindb_config'], copy, dst)

    except (TwinDBBackupError, CacheException) as err:
        LOG.error(err)
        LOG.debug(traceback.format_exc())
        exit(1)
    except (OSError, IOError) as err:
        LOG.error(err)
        LOG.debug(traceback.format_exc())
        exit(1)
开发者ID:twindb,项目名称:backup,代码行数:58,代码来源:cli.py

示例3: test_get_stream

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def test_get_stream(gs):
    status = MySQLStatus(dst=gs)
    copy = status['master1/daily/mysql/mysql-2019-04-04_05_29_05.xbstream.gz']

    with gs.get_stream(copy) as stream:
        LOG.debug('starting reading from pipe')
        content = stream.read()
        LOG.debug('finished reading from pipe')
    assert len(content), 'Failed to read from GS'
    LOG.info('Read %d bytes', len(content))
开发者ID:twindb,项目名称:backup,代码行数:12,代码来源:test_get_stream.py

示例4: _print_binlog

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def _print_binlog(dst):
    dst_files = dst.list_files(
        dst.remote_path,
        pattern='/binlog/',
        recursive=True,
        files_only=True
    )
    if dst_files:
        LOG.info('Binary logs:')
        for copy in dst_files:
            print(copy)
开发者ID:twindb,项目名称:backup,代码行数:13,代码来源:ls.py

示例5: share_backup

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def share_backup(ctx, s3_url):
    """Share backup copy for download"""
    if not s3_url:
        LOG.info('No backup copy specified. Choose one from below:')
        list_available_backups(ctx.obj['twindb_config'])
        exit(1)
    try:
        share(ctx.obj['twindb_config'], s3_url)
    except TwinDBBackupError as err:
        LOG.error(err)
        exit(1)
开发者ID:twindb,项目名称:backup,代码行数:13,代码来源:cli.py

示例6: kill_children

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def kill_children():
    """
    Kill child process
    """
    for proc in multiprocessing.active_children():
        LOG.info('Terminating %r [%d] ...', proc, proc.pid)
        proc.terminate()
    parent = psutil.Process(os.getpid())
    for child in parent.children(recursive=True):
        LOG.info('Terminating process %r', child)
        child.kill()
开发者ID:twindb,项目名称:backup,代码行数:13,代码来源:util.py

示例7: create_bucket

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
    def create_bucket(self):
        """Creates the bucket in gcs that will store the backups.

        :raises GCSDestinationError: if failed to create the bucket.
        :raises GCSDestinationError: If authentication error.
        """
        try:
            self._gcs_client.create_bucket(bucket_name=self.bucket)

        except (GoogleAPIError, GoogleAuthError) as err:
            raise GCSDestinationError(err)

        LOG.info('Created bucket %s', self.bucket)
开发者ID:twindb,项目名称:backup,代码行数:15,代码来源:gcs.py

示例8: _print_media_type

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def _print_media_type(dst, media_type):
    for run_type in INTERVALS:
        pattern = "/%s/%s/" % (run_type, media_type)
        dst_files = dst.list_files(
            dst.remote_path,
            pattern=pattern,
            recursive=True,
            files_only=True
        )
        if dst_files:
            LOG.info('%s %s copies:', media_type, run_type)
            for copy in dst_files:
                print(copy)
开发者ID:twindb,项目名称:backup,代码行数:15,代码来源:ls.py

示例9: delete_bucket

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
    def delete_bucket(self, force=False):
        """Delete the bucket in gcs that was storing the backups.

        :param force: If the bucket is non-empty then delete the objects
            before deleting the bucket.
        :type force: bool
        :raise GCSDestinationError: if failed to delete the bucket.
        """
        try:
            self._bucket_obj.delete(force=force)

        except (GoogleAPIError, GoogleAuthError) as err:
            raise GCSDestinationError(err)

        LOG.info('Deleted bucket %s', self.bucket)
开发者ID:twindb,项目名称:backup,代码行数:17,代码来源:gcs.py

示例10: backup

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def backup(ctx, run_type, lock_file, binlogs_only):
    """Run backup job"""
    try:

        run_backup_job(
            ctx.obj['twindb_config'],
            run_type,
            lock_file=lock_file,
            binlogs_only=binlogs_only
        )
    except TwinDBBackupError as err:
        LOG.error(err)
        LOG.debug(traceback.format_exc())
        exit(1)

    except KeyboardInterrupt:
        LOG.info('Exiting...')
        kill_children()
        exit(1)
开发者ID:twindb,项目名称:backup,代码行数:21,代码来源:cli.py

示例11: restore_file

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
def restore_file(ctx, dst, backup_copy):
    """Restore from file backup"""
    LOG.debug('file: %r', ctx.obj['twindb_config'])

    if not backup_copy:
        LOG.info('No backup copy specified. Choose one from below:')
        list_available_backups(ctx.obj['twindb_config'])
        exit(1)

    try:
        ensure_empty(dst)
        copy = FileCopy(path=backup_copy)
        restore_from_file(ctx.obj['twindb_config'], copy, dst)
    except TwinDBBackupError as err:
        LOG.error(err)
        exit(1)
    except KeyboardInterrupt:
        LOG.info('Exiting...')
        kill_children()
        exit(1)
开发者ID:twindb,项目名称:backup,代码行数:22,代码来源:cli.py

示例12: clone

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
    def clone(self, dest_host, port, compress=False):
        """
        Send backup to destination host

        :param dest_host: Destination host
        :type dest_host: str
        :param port: Port to sending backup
        :type port: int
        :param compress: If True compress stream
        :type compress: bool
        :raise RemoteMySQLSourceError: if any error
        """
        retry = 1
        retry_time = 2
        error_log = "/tmp/{src}_{src_port}-{dst}_{dst_port}.log".format(
            src=self._ssh_client.host,
            src_port=self._ssh_client.port,
            dst=dest_host,
            dst_port=port
        )
        if compress:
            compress_cmd = "| gzip -c - "
        else:
            compress_cmd = ""

        cmd = "bash -c \"sudo %s " \
              "--stream=xbstream " \
              "--host=127.0.0.1 " \
              "--backup " \
              "--target-dir ./ 2> %s" \
              " %s | ncat %s %d --send-only\"" \
              % (self._xtrabackup, error_log, compress_cmd, dest_host, port)
        while retry < 3:
            try:
                return self._ssh_client.execute(cmd)
            except SshClientException as err:
                LOG.warning(err)
                LOG.info('Will try again in after %d seconds', retry_time)
                time.sleep(retry_time)
                retry_time *= 2
                retry += 1
开发者ID:twindb,项目名称:backup,代码行数:43,代码来源:remote_mysql_source.py

示例13: delete_bucket

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
    def delete_bucket(self, force=False):
        """Delete the bucket in s3 that was storing the backups.

        :param force: If the bucket is non-empty then delete the objects
            before deleting the bucket.
        :type force: bool
        :raise S3DestinationError: if failed to delete the bucket.
        """
        bucket_exists = True

        try:
            self.s3_client.head_bucket(Bucket=self._bucket)
        except ClientError as err:
            # We come here meaning we did not find the bucket
            if err.response['ResponseMetadata']['HTTPStatusCode'] == 404:
                bucket_exists = False
            else:
                raise

        if bucket_exists:
            LOG.info('Deleting bucket %s', self._bucket)

            if force:
                LOG.info('Deleting the objects in the bucket %s', self._bucket)
                self.delete_all_objects()

            response = self.s3_client.delete_bucket(Bucket=self._bucket)
            self.validate_client_response(response)

            LOG.info('Bucket %s successfully deleted', self._bucket)

        return True
开发者ID:twindb,项目名称:backup,代码行数:34,代码来源:s3.py

示例14: _get_file_content

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
    def _get_file_content(self, path):
        attempts = 10  # up to 1024 seconds
        sleep_time = 2
        while sleep_time <= 2**attempts:
            try:
                response = self.s3_client.get_object(
                    Bucket=self._bucket,
                    Key=path
                )
                self.validate_client_response(response)

                content = response['Body'].read()
                return content
            except ClientError as err:
                LOG.warning('Failed to read s3://%s/%s', self._bucket, path)
                LOG.warning(err)
                LOG.info('Will try again in %d seconds', sleep_time)
                time.sleep(sleep_time)
                sleep_time *= 2
        msg = 'Failed to read s3://%s/%s after %d attempts' \
              % (self._bucket, path, attempts)
        raise OperationError(msg)
开发者ID:twindb,项目名称:backup,代码行数:24,代码来源:s3.py

示例15: create_bucket

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import info [as 别名]
    def create_bucket(self):
        """Creates the bucket in s3 that will store the backups.

        :raise S3DestinationError: if failed to create the bucket.
        """
        bucket_exists = True

        try:
            self.s3_client.head_bucket(Bucket=self._bucket)
        except ClientError as err:
            # We come here meaning we did not find the bucket
            if err.response['ResponseMetadata']['HTTPStatusCode'] == 404:
                bucket_exists = False
            else:
                raise

        if not bucket_exists:
            LOG.info('Created bucket %s', self._bucket)
            response = self.s3_client.create_bucket(Bucket=self._bucket)
            self.validate_client_response(response)

        return True
开发者ID:twindb,项目名称:backup,代码行数:24,代码来源:s3.py


注:本文中的twindb_backup.LOG.info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。