<commit_before>import logging
import smc
from smc import SMCOperationFailure

logger = logging.getLogger(__name__)

#generic
def remove_element(name):
    removable = smc.search.get_element(name)
    if removable:
        logger.debug("Element: %s found and is of type: %s. Attempting to remove" % (name, removable['type']))
        try:
            smc.web_api.http_delete(removable['href']) #delete to href
            logger.info("Successfully removed host: %s" % name)
        except SMCOperationFailure, e:
            logger.error("Failed removing host: %s, msg: %s" % (name, e.msg))
    else:
        logger.info("No host named: %s, nothing to remove" % name)


if __name__ == '__main__':
    smc.web_api.login('http://172.18.1.150:8082', 'EiGpKD4QxlLJ25dbBEp20001')
    smc.remove_element('test-run')  #single fw
    smc.remove_element('ami2')      #single host
    smc.remove_element('anewgroup')      #group
    smc.web_api.logout()<commit_msg>logging fix<commit_after>import logging
import smc
from smc import SMCOperationFailure

logger = logging.getLogger(__name__)

#generic
def element(name, objtype=None):
    removable = smc.search.get_element(name, objtype)
    if removable:
        logger.debug("Element: %s found and is of type: %s. Attempting to remove" % (name, removable['type']))
        try:
            smc.web_api.http_delete(removable['href']) #delete to href
            logger.info("Successfully removed host: %s" % name)
        except SMCOperationFailure, e:
            logger.error("Failed removing host: %s, msg: %s" % (name, e.msg))
    else:
        logger.info("No element named: %s, nothing to remove" % name)


if __name__ == '__main__':
    smc.web_api.login('http://172.18.1.150:8082', 'EiGpKD4QxlLJ25dbBEp20001')
    
    smc.remove.element('test-run')  #single fw
    smc.remove.element('ami2')      #single host
    smc.remove.element('anewgroup')      #group
    
    smc.web_api.logout()
{'fraction_non_alphanumeric': 0.13126614987080104, 'fraction_numerical': 0.022739018087855296, 'mean_word_length': 3.254945054945055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1145230', 'n_tokens_mistral': 692, 'n_tokens_neox': 655, 'n_words': 150}