<commit_before># Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from functools import partial
import os

from io import BytesIO
from karbor.common import constants
from karbor import exception
from karbor.services.protection.client_factory import ClientFactory
from karbor.services.protection import protection_plugin
from karbor.services.protection.protection_plugins.image \
    import image_plugin_schemas as image_schemas
from karbor.services.protection.protection_plugins import utils
from oslo_config import cfg
from oslo_log import log as logging


image_backup_opts = [
    cfg.IntOpt('backup_image_object_size',
               default=65536*10,
               help='The size in bytes of instance image objects. '
                    'The value must be a multiple of 65536('
                    'the size of image\'s chunk).'),
    cfg.IntOpt('poll_interval', default=10,
               help='Poll interval for image status'),
]

LOG = logging.getLogger(__name__)


def get_image_status(glance_client, image_id):
    LOG.debug('Polling image (image_id: %s)', image_id)
    try:
        status = glance_client.images.get(image_id)<commit_msg>Fix getting image status error<commit_after># Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from functools import partial
import os

from io import BytesIO
from karbor.common import constants
from karbor import exception
from karbor.services.protection.client_factory import ClientFactory
from karbor.services.protection import protection_plugin
from karbor.services.protection.protection_plugins.image \
    import image_plugin_schemas as image_schemas
from karbor.services.protection.protection_plugins import utils
from oslo_config import cfg
from oslo_log import log as logging


image_backup_opts = [
    cfg.IntOpt('backup_image_object_size',
               default=65536*10,
               help='The size in bytes of instance image objects. '
                    'The value must be a multiple of 65536('
                    'the size of image\'s chunk).'),
    cfg.IntOpt('poll_interval', default=10,
               help='Poll interval for image status'),
]

LOG = logging.getLogger(__name__)


def get_image_status(glance_client, image_id):
    LOG.debug('Polling image (image_id: %s)', image_id)
    try:
        image = glance_client.images.get(image_id)
        status = image.get('status')
{'fraction_non_alphanumeric': 0.06896551724137931, 'fraction_numerical': 0.010610079575596816, 'mean_word_length': 3.495364238410596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2373481', 'n_tokens_mistral': 925, 'n_tokens_neox': 883, 'n_words': 343}