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


Python CompressionManager.check方法代码示例

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


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

示例1: BackupManager

# 需要导入模块: from barman.compression import CompressionManager [as 别名]
# 或者: from barman.compression.CompressionManager import check [as 别名]

#.........这里部分代码省略.........
            for tablespace in backup.tablespaces:
                rm_dir = os.path.join(tbs_dir, str(tablespace.oid))
                if os.path.exists(rm_dir):
                    _logger.debug("Deleting tablespace %s directory: %s" %
                                  (tablespace.name, rm_dir))
                    shutil.rmtree(rm_dir)

        pg_data = backup.get_data_directory()
        if os.path.exists(pg_data):
            _logger.debug("Deleting PGDATA directory: %s" % pg_data)
            shutil.rmtree(pg_data)

    def delete_wal(self, wal_info):
        """
        Delete a WAL segment, with the given WalFileInfo

        :param barman.infofile.WalFileInfo wal_info: the WAL to delete
        """

        try:
            os.unlink(wal_info.fullpath(self.server))
            try:
                os.removedirs(os.path.dirname(wal_info.fullpath(self.server)))
            except OSError:
                # This is not an error condition
                # We always try to remove the the trailing directories,
                # this means that hashdir is not empty.
                pass
        except OSError as e:
            output.warning('Ignoring deletion of WAL file %s '
                           'for server %s: %s',
                           wal_info.name, self.config.name, e)

    def check(self, check_strategy):
        """
        This function does some checks on the server.

        :param CheckStrategy check_strategy: the strategy for the management
             of the results of the various checks
        """
        # Check compression_setting parameter
        if self.config.compression and not self.compression_manager.check():
            check_strategy.result(self.config.name,
                                  'compression settings', False)
        else:
            status = True
            try:
                self.compression_manager.get_compressor()
            except CompressionIncompatibility as field:
                check_strategy.result(self.config.name,
                                      '%s setting' % field, False)
                status = False
            check_strategy.result(self.config.name,
                                  'compression settings', status)

        # Failed backups check
        failed_backups = self.get_available_backups((BackupInfo.FAILED,))
        status = len(failed_backups) == 0
        check_strategy.result(
            self.config.name,
            'failed backups',
            status,
            'there are %s failed backups' % (len(failed_backups,))
        )

        # Minimum redundancy checks
开发者ID:gcalacoci,项目名称:barman,代码行数:70,代码来源:backup.py

示例2: test_check_compression_none

# 需要导入模块: from barman.compression import CompressionManager [as 别名]
# 或者: from barman.compression.CompressionManager import check [as 别名]
 def test_check_compression_none(self):
     #prepare mock obj
     config_mock = mock.Mock()
     config_mock.compression = "custom"
     comp_manager = CompressionManager(config_mock)
     assert comp_manager.check() is True
开发者ID:huddler,项目名称:pgbarman,代码行数:8,代码来源:test_compressor.py

示例3: test_check_with_compression

# 需要导入模块: from barman.compression import CompressionManager [as 别名]
# 或者: from barman.compression.CompressionManager import check [as 别名]
 def test_check_with_compression(self):
     #prepare mock obj
     config_mock = mock.Mock()
     comp_manager = CompressionManager(config_mock)
     assert comp_manager.check('test_compression') is False
开发者ID:huddler,项目名称:pgbarman,代码行数:7,代码来源:test_compressor.py

示例4: BackupManager

# 需要导入模块: from barman.compression import CompressionManager [as 别名]
# 或者: from barman.compression.CompressionManager import check [as 别名]

#.........这里部分代码省略.........
                os.rename(xlogdb_new, fxlogdb.name)
        yield "Done"


    def build_script_env(self, backup_info, phase):
        """
        Prepare the environment for executing a script
        """
        previous_backup = self.get_previous_backup(backup_info.backup_id)
        env = {}
        env['BARMAN_BACKUP_DIR'] = backup_info.get_basebackup_directory()
        env['BARMAN_SERVER'] = self.config.name
        env['BARMAN_CONFIGURATION'] = self.config.config.config_file
        env['BARMAN_BACKUP_ID'] = backup_info.backup_id
        env['BARMAN_PREVIOUS_ID'] =  previous_backup.backup_id if previous_backup else ''
        env['BARMAN_PHASE'] = phase
        env['BARMAN_STATUS'] = backup_info.status
        env['BARMAN_ERROR'] = backup_info.error or ''
        env['BARMAN_VERSION'] = version.__version__
        return env

    def run_pre_backup_script(self, backup_info):
        '''
        Run the pre_backup_script if configured.
        This method must never throw any exception
        '''
        try:
            script = self.config.pre_backup_script
            if script:
                _logger.info("Attempt to run pre_backup_script: %s", script)
                cmd = Command(
                    script,
                    env_append=self.build_script_env(backup_info, 'pre'),
                    shell=True, check=False)
                ret = cmd()
                _logger.info("pre_backup_script returned %d", ret)
        except Exception:
            _logger.exception('Exception running pre_backup_script')

    def run_post_backup_script(self, backup_info):
        '''
        Run the post_backup_script if configured.
        This method must never throw any exception
        '''
        try:
            script = self.config.post_backup_script
            if script:
                _logger.info("Attempt to run post_backup_script: %s", script)
                cmd = Command(
                    script,
                    env_append=self.build_script_env(backup_info, 'post'),
                    shell=True, check=False)
                ret = cmd()
                _logger.info("post_backup_script returned %d", ret)
        except Exception:
            _logger.exception('Exception running post_backup_script')

    def backup(self):
        '''
        Performs a backup for the server
        '''
        _logger.debug("initialising backup information")
        backup_stamp = datetime.datetime.now()
        self.current_action = "starting backup"
        backup_info = None
        try:
开发者ID:klhochhalter,项目名称:barman,代码行数:70,代码来源:backup.py


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