<commit_before>#
#  Copyright (c) 2014, Facebook, Inc.
#  All rights reserved.
#
#  This source code is licensed under the BSD-style license found in the
#  LICENSE file in the root directory of this source tree. An additional grant
#  of patent rights can be found in the PATENTS file in the same directory.
#
#
import sys

from atcd.AtcdThriftHandlerTask import AtcdThriftHandlerTask

# Pyroute stuff
from pyroute2 import IPRoute
from pyroute2.netlink.rtnl import TC_H_ROOT
from pyroute2.netlink.rtnl import RTM_NEWTCLASS
from pyroute2.netlink.rtnl import RTM_DELTCLASS
from pyroute2.netlink.rtnl import RTM_NEWQDISC
from pyroute2.netlink.rtnl import RTM_DELQDISC
from pyroute2.netlink.rtnl import RTM_NEWTFILTER
from pyroute2.netlink.rtnl import RTM_DELTFILTER
from pyroute2.netlink import NetlinkError

# Atc thrift files
from atc_thrift.ttypes import ReturnCode
from atc_thrift.ttypes import TrafficControlRc


ETH_P_IP = 0x0800
PRIO = 1
HANDLE_MIN = 2
HANDLE_MAX = (2 ** 16) - 1


def int_to_classid(i):
    s = "{0:X}:{1:X}".format(i >> 16, 0xff & i)
    return s


class AtcdLinuxShaper(AtcdThriftHandlerTask):

    ID_MANAGER_ID_MIN = HANDLE_MIN
    ID_MANAGER_ID_MAX = HANDLE_MAX

    def initTask(self):
        self.ipr = IPRoute()
        super(AtcdLinuxShaper, self).initTask()

    def stop(self):
        self._release_ipr()

    def _release_ipr(self):
        self.ipr.release()

    def _links_lookup(self):
        try:
            self.lan['id'] = self.ipr.link_lookup(ifname=self.lan_name)[0]
            self.wan['id'] = self.ipr.link_lookup(ifname=self.wan_name)[0]
        except IndexError:<commit_msg>[pyroute2] use .close() instead of deprecated .release()<commit_after>#
#  Copyright (c) 2014, Facebook, Inc.
#  All rights reserved.
#
#  This source code is licensed under the BSD-style license found in the
#  LICENSE file in the root directory of this source tree. An additional grant
#  of patent rights can be found in the PATENTS file in the same directory.
#
#
import sys

from atcd.AtcdThriftHandlerTask import AtcdThriftHandlerTask

# Pyroute stuff
from pyroute2 import IPRoute
from pyroute2.netlink.rtnl import TC_H_ROOT
from pyroute2.netlink.rtnl import RTM_NEWTCLASS
from pyroute2.netlink.rtnl import RTM_DELTCLASS
from pyroute2.netlink.rtnl import RTM_NEWQDISC
from pyroute2.netlink.rtnl import RTM_DELQDISC
from pyroute2.netlink.rtnl import RTM_NEWTFILTER
from pyroute2.netlink.rtnl import RTM_DELTFILTER
from pyroute2.netlink import NetlinkError

# Atc thrift files
from atc_thrift.ttypes import ReturnCode
from atc_thrift.ttypes import TrafficControlRc


ETH_P_IP = 0x0800
PRIO = 1
HANDLE_MIN = 2
HANDLE_MAX = (2 ** 16) - 1


def int_to_classid(i):
    s = "{0:X}:{1:X}".format(i >> 16, 0xff & i)
    return s


class AtcdLinuxShaper(AtcdThriftHandlerTask):

    ID_MANAGER_ID_MIN = HANDLE_MIN
    ID_MANAGER_ID_MAX = HANDLE_MAX

    def initTask(self):
        self.ipr = IPRoute()
        super(AtcdLinuxShaper, self).initTask()

    def stop(self):
        self._release_ipr()

    def _release_ipr(self):
        self.ipr.close()

    def _links_lookup(self):
        try:
            self.lan['id'] = self.ipr.link_lookup(ifname=self.lan_name)[0]
            self.wan['id'] = self.ipr.link_lookup(ifname=self.wan_name)[0]
        except IndexError:
{'fraction_non_alphanumeric': 0.08371246587807098, 'fraction_numerical': 0.01910828025477707, 'mean_word_length': 3.885925925925926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6863978', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1165, 'n_words': 303}