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


Python LOG.debug方法代码示例

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


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

示例1: revert_stream

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
    def revert_stream(self):
        """
        Un-Apply modifier and return output stream.
        The Base modifier does nothing, so it will return the input stream
        without modifications

        :return: output stream handle
        """
        with self._input as input_stream:
            LOG.debug('Running %s', ' '.join(self._unmodifier_cmd))
            proc = Popen(
                self._unmodifier_cmd,
                stdin=input_stream,
                stdout=PIPE,
                stderr=PIPE
            )
            yield proc.stdout

            _, cerr = proc.communicate()
            if proc.returncode:
                msg = '%s exited with non-zero code.' \
                      % ' '.join(self._unmodifier_cmd)
                LOG.error(msg)
                LOG.error(cerr)
                raise ModifierException(msg)
开发者ID:twindb,项目名称:backup,代码行数:27,代码来源:base.py

示例2: run_command

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
def run_command(command, ok_non_zero=False):
    """
    Run shell command locally

    :param command: Command to run
    :type command: list
    :param ok_non_zero: Don't consider non-zero exit code as an error.
    :type ok_non_zero: bool
    :return: file object with stdout as generator to use with ``with``
    """
    try:
        LOG.debug('Running %s', " ".join(command))
        proc = Popen(command, stderr=PIPE, stdout=PIPE)

        yield proc.stdout

        _, cerr = proc.communicate()

        if proc.returncode and not ok_non_zero:
            LOG.error('Command %s exited with error code %d',
                      ' '.join(command),
                      proc.returncode)
            LOG.error(cerr)
            exit(1)
        else:
            LOG.debug('Exited with zero code')

    except OSError as err:
        LOG.error('Failed to run %s',
                  ' '.join(command))
        LOG.error(err)
        exit(1)
开发者ID:twindb,项目名称:backup,代码行数:34,代码来源:util.py

示例3: setup_slave

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
    def setup_slave(self, master_info):  # noqa # pylint: disable=too-many-arguments
        """
        Change master

        :param master_info: Master details.
        :type master_info: MySQLMasterInfo

        """
        try:
            with self._cursor() as cursor:
                query = "CHANGE MASTER TO " \
                        "MASTER_HOST = '{master}', " \
                        "MASTER_USER = '{user}', " \
                        "MASTER_PORT = {port}, " \
                        "MASTER_PASSWORD = '{password}', " \
                        "MASTER_LOG_FILE = '{binlog}', " \
                        "MASTER_LOG_POS = {binlog_pos}"\
                    .format(
                        master=master_info.host,
                        user=master_info.user,
                        password=master_info.password,
                        binlog=master_info.binlog,
                        binlog_pos=master_info.binlog_position,
                        port=master_info.port
                    )
                cursor.execute(query)
                cursor.execute("START SLAVE")
            return True
        except pymysql.Error as err:
            LOG.debug(err)
            return False
开发者ID:twindb,项目名称:backup,代码行数:33,代码来源:remote_mysql_source.py

示例4: backup_files

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
def backup_files(run_type, config):
    """Backup local directories

    :param run_type: Run type
    :type run_type: str
    :param config: Configuration
    :type config: TwinDBBackupConfig
    """
    backup_start = time.time()
    try:
        for directory in config.backup_dirs:
            LOG.debug('copying %s', directory)
            src = FileSource(directory, run_type)
            dst = config.destination()
            _backup_stream(config, src, dst)
            src.apply_retention_policy(dst, config, run_type)
    except (
            DestinationError,
            SourceError,
            SshClientException
    ) as err:
        raise OperationError(err)
    export_info(config, data=time.time() - backup_start,
                category=ExportCategory.files,
                measure_type=ExportMeasureType.backup)
开发者ID:twindb,项目名称:backup,代码行数:27,代码来源:backup.py

示例5: disable_wsrep_desync

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
    def disable_wsrep_desync(self):
        """
        Wait till wsrep_local_recv_queue is zero
        and disable wsrep_local_recv_queue then
        """
        max_time = time.time() + 900
        try:
            with self.get_connection() as connection:
                with connection.cursor() as cursor:
                    while time.time() < max_time:
                        cursor.execute("SHOW GLOBAL STATUS LIKE "
                                       "'wsrep_local_recv_queue'")

                        res = {r['Variable_name'].lower(): r['Value'].lower()
                               for r in cursor.fetchall()}

                        if not res.get('wsrep_local_recv_queue'):
                            raise Exception('Unknown status variable '
                                            '"wsrep_local_recv_queue"')

                        if int(res['wsrep_local_recv_queue']) == 0:
                            break

                        time.sleep(1)

                    LOG.debug('Disabling wsrep_desync')
                    cursor.execute("SET GLOBAL wsrep_desync=OFF")
        except pymysql.Error as err:
            LOG.error(err)
开发者ID:twindb,项目名称:backup,代码行数:31,代码来源:mysql_source.py

示例6: backup_everything

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
def backup_everything(run_type, twindb_config, binlogs_only=False):
    """
    Run backup job

    :param run_type: hourly, daily, etc
    :type run_type: str
    :param twindb_config: ConfigParser instance
    :type twindb_config: TwinDBBackupConfig
    :param binlogs_only: If True copy only MySQL binary logs.
    :type binlogs_only: bool
    """
    set_open_files_limit()

    try:
        if not binlogs_only:
            backup_start = time.time()
            backup_files(run_type, twindb_config)
            backup_mysql(run_type, twindb_config)
            backup_binlogs(run_type, twindb_config)
            end = time.time()
            save_measures(backup_start, end)
        else:
            backup_binlogs(run_type, twindb_config)
    except ConfigParser.NoSectionError as err:
        LOG.debug(traceback.format_exc())
        LOG.error(err)
        exit(1)
开发者ID:twindb,项目名称:backup,代码行数:29,代码来源:backup.py

示例7: apply_backup

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
    def apply_backup(self, datadir):
        """
        Apply backup of destination server

        :param datadir: Path to datadir
        :return: Binlog file name and position
        :rtype: tuple
        :raise RemoteMySQLSourceError: if any error.
        """
        try:
            use_memory = "--use-memory %d" % int(self._mem_available() / 2)
        except OSError:
            use_memory = ""
        logfile_path = "/tmp/xtrabackup-apply-log.log"
        cmd = "sudo {xtrabackup} --prepare --apply-log-only " \
              "--target-dir {target_dir} {use_memory} " \
              "> {logfile} 2>&1" \
              "".format(
                  xtrabackup=self._xtrabackup,
                  target_dir=datadir,
                  use_memory=use_memory,
                  logfile=logfile_path
              )

        try:
            self._ssh_client.execute(cmd)
            self._ssh_client.execute("sudo chown -R mysql %s" % datadir)
            return self._get_binlog_info(datadir)
        except SshClientException as err:
            LOG.debug("Logfile is:")
            LOG.debug(self._ssh_client.get_text_content(logfile_path))
            raise RemoteMySQLSourceError(err)
开发者ID:twindb,项目名称:backup,代码行数:34,代码来源:remote_mysql_source.py

示例8: test_get_stream

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [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

示例9: set_open_files_limit

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
def set_open_files_limit():
    """Detect maximum supported number of open file and set it"""
    max_files = getrlimit(RLIMIT_NOFILE)[0]
    while True:
        try:
            setrlimit(RLIMIT_NOFILE, (max_files, max_files))
            max_files += 1
        except ValueError:
            break
    LOG.debug('Setting max files limit to %d', max_files)
开发者ID:twindb,项目名称:backup,代码行数:12,代码来源:backup.py

示例10: _update_backup_info

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
    def _update_backup_info(self, stderr_file):
        """Update backup_info from stderr"""

        LOG.debug('xtrabackup error log file %s',
                  stderr_file.name)
        self._backup_info.lsn = self._get_lsn(stderr_file.name)
        self._backup_info.binlog_coordinate = self.get_binlog_coordinates(
            stderr_file.name
        )
        os.unlink(stderr_file.name)
开发者ID:twindb,项目名称:backup,代码行数:12,代码来源:mysql_source.py

示例11: save

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
    def save(self, handler, filepath):
        """
        Read from handler and save it to Amazon S3

        :param filepath: save backup copy in a file with this name
        :param handler: stdout handler from backup source
        """
        with handler as file_obj:
            ret = self._upload_object(file_obj, filepath)
            LOG.debug('Returning code %d', ret)
开发者ID:twindb,项目名称:backup,代码行数:12,代码来源:s3.py

示例12: clone_config

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
    def clone_config(self, dst):
        """
        Clone config to destination server

        :param dst: Destination server
        :type dst: Ssh
        """
        cfg_path = self._get_root_my_cnf()
        LOG.debug("Root my.cnf is: %s", cfg_path)
        self._save_cfg(dst, cfg_path)
开发者ID:twindb,项目名称:backup,代码行数:12,代码来源:remote_mysql_source.py

示例13: verify_mysql_backup

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
def verify_mysql_backup(twindb_config, dst_path, backup_file, hostname=None):
    """
    Restore mysql backup and measure time

    :param hostname:
    :param backup_file:
    :param dst_path:
    :param twindb_config: tool configuration
    :type twindb_config: TwinDBBackupConfig

    """
    dst = twindb_config.destination(backup_source=hostname)
    status = MySQLStatus(dst=dst)
    copy = None

    if backup_file == "latest":
        copy = status.latest_backup
    else:
        for copy in status:
            if backup_file.endswith(copy.key):
                break
    if copy is None:
        return json.dumps({
            'backup_copy': backup_file,
            'restore_time': 0,
            'success': False
        }, indent=4, sort_keys=True)
    start_restore_time = time.time()
    success = True
    tmp_dir = tempfile.mkdtemp()

    try:

        LOG.debug('Verifying backup copy in %s', tmp_dir)
        restore_from_mysql(twindb_config, copy, dst_path, tmp_dir)
        edit_backup_my_cnf(dst_path)

    except (TwinDBBackupError, OSError, IOError) as err:

        LOG.error(err)
        LOG.debug(traceback.format_exc())
        success = False

    finally:

        shutil.rmtree(tmp_dir, ignore_errors=True)

    end_restore_time = time.time()
    restore_time = end_restore_time - start_restore_time
    return json.dumps({
        'backup_copy': copy.key,
        'restore_time': restore_time,
        'success': success
    }, indent=4, sort_keys=True)
开发者ID:twindb,项目名称:backup,代码行数:56,代码来源:verify.py

示例14: bucket_name

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
def bucket_name():
    travis_job_number = os.environ.get('TRAVIS_JOB_NUMBER')
    LOG.debug('TRAVIS_JOB_NUMBER=%s' % travis_job_number)

    number = random.randint(0, 1000000)
    LOG.debug('Default job number %d' % number)

    if travis_job_number:
        bucket = 'twindb-backup-test-travis-%s' % travis_job_number
    else:
        bucket = 'twindb-backup-test-travis-%d' % number

    return '%s-%s' % (bucket, time.time())
开发者ID:twindb,项目名称:backup,代码行数:15,代码来源:conftest.py

示例15: candidate_parent

# 需要导入模块: from twindb_backup import LOG [as 别名]
# 或者: from twindb_backup.LOG import debug [as 别名]
    def candidate_parent(self, run_type):
        """
        Find a backup copy that can be a parent

        :param run_type: See :func:`~get_backup_type`.
        :return: Backup copy or None
        :rtype: MySQLCopy
        """
        full_backup_index = INTERVALS.index(run_type)
        LOG.debug('Looking a parent candidate for %s run', run_type)
        for i in xrange(full_backup_index, len(INTERVALS)):
            period_copies = getattr(self, INTERVALS[i])
            LOG.debug(
                'Checking %d %s copies',
                len(period_copies),
                INTERVALS[i]
            )
            for _, value in period_copies.iteritems():
                try:
                    if value.type == 'full':
                        LOG.debug('Found parent %r', value)
                        return value
                except KeyError:
                    return None
        LOG.debug('No eligible parents')
        return None
开发者ID:twindb,项目名称:backup,代码行数:28,代码来源:mysql_status.py


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