<commit_before>#!/bin/python
from collections import namedtuple
import json
import os
import socket
import sys
from subprocess import check_output, CalledProcessError, check_call
import requests
import sh

# Append to existing env, to avoid losing PATH etc.
# Need to edit the path here since calicoctl loads client on import.
# TODO-PAT: This shouldn't be hardcoded
os.environ['ETCD_AUTHORITY'] = 'kubernetes-master:6666'

from calicoctl import container_add
from pycalico.datastore import IF_PREFIX
from pycalico.util import generate_cali_interface_name

calicoctl = sh.Command('/home/vagrant/calicoctl').bake(_env=os.environ)

ETCD_AUTHORITY_ENV = "ETCD_AUTHORITY"
PROFILE_LABEL = 'CALICO_PROFILE'
ETCD_PROFILE_PATH = '/calico/'
AllowRule = namedtuple('AllowRule', ['port', 'proto', 'source'])


class NetworkPlugin(object):
    def __init__(self):
        self.pod_name = None
        self.docker_id = None

    def create(self, args):
        """"Create a pod."""
        # Calicoctl only
        self.pod_name = args[3].replace('-', '_')
        self.docker_id = args[4]

        print('Configuring docker container %s' % self.docker_id)

        try:
            endpoint = self._configure_interface()
            self._configure_profile(endpoint)
        except CalledProcessError as e:
            print('Error code %d creating pod networking: %s\n%s' % (
                e.returncode, e.output, e))<commit_msg>Allow overriding of calicoctl path by env variable<commit_after>#!/bin/python
from collections import namedtuple
import json
import os
import socket
import sys
from subprocess import check_output, CalledProcessError, check_call
import requests
import sh

# Append to existing env, to avoid losing PATH etc.
# Need to edit the path here since calicoctl loads client on import.
# TODO-PAT: This shouldn't be hardcoded
os.environ['ETCD_AUTHORITY'] = 'kubernetes-master:6666'

from calicoctl import container_add
from pycalico.datastore import IF_PREFIX
from pycalico.util import generate_cali_interface_name

CALICOCTL_PATH = os.environ.get('CALICOCTL_PATH', '/home/vagrant/calicoctl')
calicoctl = sh.Command(CALICOCTL_PATH).bake(_env=os.environ)

ETCD_AUTHORITY_ENV = "ETCD_AUTHORITY"
PROFILE_LABEL = 'CALICO_PROFILE'
ETCD_PROFILE_PATH = '/calico/'
AllowRule = namedtuple('AllowRule', ['port', 'proto', 'source'])


class NetworkPlugin(object):
    def __init__(self):
        self.pod_name = None
        self.docker_id = None

    def create(self, args):
        """"Create a pod."""
        # Calicoctl only
        self.pod_name = args[3].replace('-', '_')
        self.docker_id = args[4]

        print('Configuring docker container %s' % self.docker_id)

        try:
            endpoint = self._configure_interface()
            self._configure_profile(endpoint)
        except CalledProcessError as e:
            print('Error code %d creating pod networking: %s\n%s' % (
                e.returncode, e.output, e))
{'fraction_non_alphanumeric': 0.0998980632008155, 'fraction_numerical': 0.004077471967380225, 'mean_word_length': 3.673015873015873, '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': '6201315', 'n_tokens_mistral': 925, 'n_tokens_neox': 886, 'n_words': 247}