<commit_before>import logging

from akanda.router.drivers import base


LOG = logging.getLogger(__name__)


class RouteManager(base.Manager):
    EXECUTABLE = '/sbin/route'

    def __init__(self, root_helper='sudo'):
        super(RouteManager, self).__init__(root_helper)

    def update_default(self, config):
        for net in config.networks:
            if not net.is_external_network:
                continue

            for subnet in net.subnets:
                if subnet.gateway_ip:
                    self._set_default_gateway(subnet.gateway_ip)

    def _set_default_gateway(self, gateway_ip):
        version = '-inet'
        if gateway_ip.version == 6:
            version += '6'
        try:
            current = self.sudo('get', '-n', version, 'default')
        except:
            current = None

        if current and 'no such process' not in current.lower():
            return self.sudo('change', version, 'default', str(gateway_ip))
        else:
            return self.sudo('add', version, 'default', str(gateway_ip))
<commit_msg>fix order of args to route command<commit_after>import logging

from akanda.router.drivers import base


LOG = logging.getLogger(__name__)


class RouteManager(base.Manager):
    EXECUTABLE = '/sbin/route'

    def __init__(self, root_helper='sudo'):
        super(RouteManager, self).__init__(root_helper)

    def update_default(self, config):
        for net in config.networks:
            if not net.is_external_network:
                continue

            for subnet in net.subnets:
                if subnet.gateway_ip:
                    self._set_default_gateway(subnet.gateway_ip)

    def _set_default_gateway(self, gateway_ip):
        version = '-inet'
        if gateway_ip.version == 6:
            version += '6'
        try:
            current = self.sudo('-n', 'get', version, 'default')
        except:
            current = None

        if current and 'no such process' not in current.lower():
            return self.sudo('change', version, 'default', str(gateway_ip))
        else:
            return self.sudo('add', version, 'default', str(gateway_ip))

{'fraction_non_alphanumeric': 0.10359309379374708, 'fraction_numerical': 0.0018665422305179655, 'mean_word_length': 2.24357034795764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5144117', 'n_tokens_mistral': 644, 'n_tokens_neox': 603, 'n_words': 154}