<commit_before># Copyright (c) 2017 Intel Corporation
#
# 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.

import ast
import json
import logging
import os
import shutil
import sys

from time import sleep
from kubernetes.client.rest import ApiException as K8sApiException
from . import custom_resource
from . import config, third_party
from . import reconcile
from . import discover
from . import k8s


def uninstall(install_dir, conf_dir):
    delete_cmk_pod("cmk-init-install-discover-pod")
    delete_cmk_pod("cmk-reconcile-nodereport-ds")

    remove_all_report()

    check_remove_conf_dir(conf_dir)

    remove_node_label()
    remove_node_taint()
    remove_node_cmk_oir()

    remove_binary(install_dir)


def remove_binary(install_dir):
    remove_file = os.path.join(install_dir, "cmk")
    try:
        os.remove(remove_file)
        logging.info("cmk binary from \"{}\" removed successfully.".format(
            install_dir))
    except FileNotFoundError as err:
        logging.warning("Could not found cmk binary in "
                        "\"{}\".".format(install_dir))
        logging.warning("Wrong path or file has already been removed.")
        sys.exit(0)


def remove_all_report():
    version_major, version_minor = k8s.get_kubelet_version(None)

    if version_major == 1 and version_minor >= 7:
        remove_report_crd("cmk-nodereport", ["cmk-nr"])
        remove_report_crd("cmk-reconcilereport", ["cmk-rr"])

    else:
        remove_report_tpr("Nodereport")
        remove_report_tpr("Reconcilereport")
<commit_msg>Remove label as last step (#173)<commit_after># Copyright (c) 2017 Intel Corporation
#
# 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.

import ast
import json
import logging
import os
import shutil
import sys

from time import sleep
from kubernetes.client.rest import ApiException as K8sApiException
from . import custom_resource
from . import config, third_party
from . import reconcile
from . import discover
from . import k8s


def uninstall(install_dir, conf_dir):
    delete_cmk_pod("cmk-init-install-discover-pod")
    delete_cmk_pod("cmk-reconcile-nodereport-ds")

    remove_all_report()

    check_remove_conf_dir(conf_dir)

    remove_node_taint()
    remove_node_cmk_oir()

    remove_binary(install_dir)

    remove_node_label()


def remove_binary(install_dir):
    remove_file = os.path.join(install_dir, "cmk")
    try:
        os.remove(remove_file)
        logging.info("cmk binary from \"{}\" removed successfully.".format(
            install_dir))
    except FileNotFoundError as err:
        logging.warning("Could not found cmk binary in "
                        "\"{}\".".format(install_dir))
        logging.warning("Wrong path or file has already been removed.")
        sys.exit(0)


def remove_all_report():
    version_major, version_minor = k8s.get_kubelet_version(None)

    if version_major == 1 and version_minor >= 7:
        remove_report_crd("cmk-nodereport", ["cmk-nr"])
        remove_report_crd("cmk-reconcilereport", ["cmk-rr"])

    else:
        remove_report_tpr("Nodereport")
        remove_report_tpr("Reconcilereport")

{'fraction_non_alphanumeric': 0.08942495126705653, 'fraction_numerical': 0.007553606237816764, 'mean_word_length': 3.659477866061294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5479414', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1192, 'n_words': 373}