<commit_before>"""
Copyright 2017-present, Airbnb Inc.

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.
"""
from abc import ABCMeta, abstractmethod
from collections import namedtuple
import json
import os
import tempfile
import requests
import urllib3

import boto3
from botocore.exceptions import ClientError

from stream_alert.alert_processor import LOGGER

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
OutputProperty = namedtuple('OutputProperty',
                            'description, value, input_restrictions, mask_input, cred_requirement')
OutputProperty.__new__.__defaults__ = ('', '', {' ', ':'}, False, False)

class OutputRequestFailure(Exception):
    """OutputRequestFailure handles any HTTP failures"""

class StreamAlertOutput(object):
    """Class to be used as a decorator to register all OutputDispatcher subclasses"""
    _outputs = {}

    def __new__(cls, output):
        StreamAlertOutput._outputs[output.__service__] = output
        return output

    @classmethod
    def create_dispatcher(cls, service, region, function_name, config):
        """Returns the subclass that should handle this particular service

        Args:
            service (str): The service identifier for this output
            region (str): The AWS region to use for some output types
            function_name (str): The invoking AWS Lambda function name
            config (dict): The loaded output configuration dict

        Returns:
            OutputDispatcher: Subclass of OutputDispatcher to use for sending alerts
        """
        dispatcher = cls.get_dispatcher(service)
        if not dispatcher:
            return False

        return dispatcher(region, function_name, config)

    @classmethod
    def get_dispatcher(cls, service):
        """Returns the subclass that should handle this particular service

        Args:
            service (str): The service identifier for this output

        Returns:
            OutputDispatcher: Subclass of OutputDispatcher to use for sending alerts
        """
        try:
            return cls._outputs[service]
        except KeyError:
            LOGGER.error('Designated output service [%s] does not exist', service)

    @classmethod
    def get_all_outputs(cls):
        """Return a copy of the cache containing all of the output subclasses

        Returns:
            dict: Cached dictionary of all registered StreamAlertOutputs where
                the key is the service and the value is the class object
        """
        return cls._outputs.copy()

class OutputDispatcher(object):
    """OutputDispatcher is the base class to handle routing alerts to outputs

    Public methods:
        get_secrets_bucket_name: returns the name of the s3 bucket for secrets that
            includes a unique prefix
        output_cred_name: the name that is used to store the credentials both on s3
            and locally on disk in tmp
        get_config_service: the name of the service used by the config to store any
            configured outputs for this service. implemented by some subclasses, but
            subclass is not required to implement
        format_output_config: returns a formatted version of the outputs configuration
            that is to be written to disk
        get_user_defined_properties: returns any properties for this output that must be
            provided by the user. must be implemented by subclasses
        dispatch: handles the actual sending of alerts to the configured service. must
            be implemented by subclass
    """
    __metaclass__ = ABCMeta
    __service__ = NotImplemented

    # _DEFAULT_REQUEST_TIMEOUT indicates how long the requests library will wait before timing
    # out for both get and post requests. This applies to both connection and read timeouts
    _DEFAULT_REQUEST_TIMEOUT = 3.05

    def __init__(self, region, function_name, config):
        self.region = region
        self.secrets_bucket = self._get_secrets_bucket_name(function_name)
        self.config = config

    @staticmethod
    def _local_temp_dir():
        """Get the local tmp directory for caching the encrypted service credentials

        Returns:
            str: local path for stream_alert_secrets tmp directory
        """
        temp_dir = os.path.join(tempfile.gettempdir(), "stream_alert_secrets")

        # Check if this item exists as a file, and remove it if it does
        if os.path.isfile(temp_dir):
            os.remove(temp_dir)

        # Create the folder on disk to store the credentials temporarily
        if not os.path.exists(temp_dir):
            os.makedirs(temp_dir)

        return temp_dir

    def _load_creds(self, descriptor):
        """First try to load the credentials from /tmp and then resort to pulling
        the credentials from S3 if they are not cached locally

        Args:
            descriptor (str): unique identifier used to look up these credentials

        Returns:
            dict: the loaded credential info needed for sending alerts to this service
                or None if nothing gets loaded
        """
        local_cred_location = os.path.join(self._local_temp_dir(),
                                           self.output_cred_name(descriptor))

        # Creds are not cached locally, so get the encrypted blob from s3
        if not os.path.exists(local_cred_location):
            if not self._get_creds_from_s3(local_cred_location, descriptor):
                return

        # Open encrypted credential file
        with open(local_cred_location, 'rb') as cred_file:
            enc_creds = cred_file.read()

        # Get the decrypted credential json from kms and load into dict
        # This could be None if the kms decryption fails, so check it
        decrypted_creds = self._kms_decrypt(enc_creds)
        if not decrypted_creds:
            return

        creds_dict = json.loads(decrypted_creds)

        # Add any of the hard-coded default output props to this dict (ie: url)
        defaults = self._get_default_properties()
        if defaults:
            creds_dict.update(defaults)

        return creds_dict

    @classmethod
    def _get_secrets_bucket_name(cls, function_name):
        """Returns the streamalerts secrets s3 bucket name"""
        prefix = function_name.split('_')[0]
        return '.'.join([prefix, 'streamalert', 'secrets'])

    def _get_creds_from_s3(self, cred_location, descriptor):
        """Pull the encrypted credential blob for this service and destination from s3

        Args:
            cred_location (str): The tmp path on disk to to store the encrypted blob
            descriptor (str): Service destination (ie: slack channel, pd integration)

        Returns:
            bool: True if download of creds from s3 was a success
        """
        try:
            if not os.path.exists(os.path.dirname(cred_location)):
                os.makedirs(os.path.dirname(cred_location))

            client = boto3.client('s3', region_name=self.region)
            with open(cred_location, 'wb') as cred_output:
                client.download_fileobj(self.secrets_bucket,
                                        self.output_cred_name(descriptor),
                                        cred_output)

            return True
        except ClientError as err:
            LOGGER.exception('credentials for \'%s\' could not be downloaded '
                             'from S3: %s', self.output_cred_name(descriptor),
                             err.response)

    def _kms_decrypt(self, data):
        """Decrypt data with AWS KMS.

        Args:
            data (str): An encrypted ciphertext data blob

        Returns:
            str: Decrypted json string
        """
        try:
            client = boto3.client('kms', region_name=self.region)
            response = client.decrypt(CiphertextBlob=data)
            return response['Plaintext']
        except ClientError as err:
            LOGGER.error('an error occurred during credentials decryption: %s', err.response)

    def _log_status(self, success):
        """Log the status of sending the alerts

        Args:
            success (bool): Indicates if the dispatching of alerts was successful
        """
        if success:
            LOGGER.info('Successfully sent alert to %s', self.__service__)
        else:
            LOGGER.error('Failed to send alert to %s', self.__service__)

        return bool(success)

    @classmethod
    def _get_request(cls, url, params=None, headers=None, verify=True):
        """Method to return the json loaded response for this GET request

        Args:
            url (str): Endpoint for this request
            params (dict): Payload to send with this request
            headers (dict): Dictionary containing request-specific header parameters
            verify (bool): Whether or not the server's SSL certificate should be verified
        Returns:
            dict: Contains the http response object
        """
        return requests.get(url, headers=headers, params=params,
                            verify=verify, timeout=cls._DEFAULT_REQUEST_TIMEOUT)

    @classmethod
    def _post_request(cls, url, data=None, headers=None, verify=True):
        """Method to return the json loaded response for this POST request

        Args:
            url (str): Endpoint for this request
            data (dict): Payload to send with this request
            headers (dict): Dictionary containing request-specific header parameters
            verify (bool): Whether or not the server's SSL certificate should be verified
        Returns:
            dict: Contains the http response object
        """
        return requests.post(url, headers=headers, json=data,
                             verify=verify, timeout=cls._DEFAULT_REQUEST_TIMEOUT)

    @classmethod
    def _check_http_response(cls, response):
        """Method for checking for a valid HTTP response code

        Args:
            response (requests.Response): Response object from requests

        Returns:
            bool: Indicator of whether or not this request was successful
        """
        success = response is not None and (200 <= response.status_code <= 299)
        if not success:
            LOGGER.error('Encountered an error while sending to %s:\n%s',
                         cls.__service__,
                         response.content)
        return success

    @classmethod
    def _get_default_properties(cls):
        """Base method for retrieving properties that should be hard-coded for this
        output service integration. This could include information such as a static
        url used for sending the alerts to this service, a static port, or other
        non-sensitive information.

        If information of this sort is needed, this should be overridden in output subclasses.

        NOTE: This should not contain any sensitive or use-case specific data. Information
        such as this should be retrieved from the user using `get_user_defined_properties()`
        so the user is prompted for the sensitive information at configuration time and said
        information is then sent to kms for encryption and s3 for storage.

        Returns:
            dict: Contains various default items for this output (ie: url)
        """
        pass

    def output_cred_name(self, descriptor):
        """Formats the output name for this credential by combining the service
        and the descriptor.

        Args:
            descriptor (str): Service destination (ie: slack channel, pd integration)

        Returns:
            str: Formatted credential name (ie: slack_ryandchannel)
        """
        cred_name = str(self.__service__)

        # should descriptor be enforced in all rules?
        if descriptor:
            cred_name = '{}/{}'.format(cred_name, descriptor)

        return cred_name

    @classmethod
    def format_output_config(cls, service_config, values):
        """Add this descriptor to the list of descriptor this service
           If the service doesn't exist, a new entry is added to an empty list

        Args:
            service_config (dict): Loaded configuration as a dictionary
            values (OrderedDict): Contains various OutputProperty items
        Returns:
            [list<string>] List of descriptors for this service
        """
        return service_config.get(cls.__service__, []) + [values['descriptor'].value]

    @classmethod
    @abstractmethod
    def get_user_defined_properties(cls):
        """Base method for retrieving properties that must be asssigned by the user when
        configuring a new output for this service. This should include any information that
        is sensitive or use-case specific. For intance, if the url needed for this integration
        is unique to your situation, it should be supplied here.

        If information of this sort is needed, it should be added to the method that
        overrides this one in the subclass.

        At the very minimum, subclass functions should return an OrderedDict that contains
        the key 'descriptor' with a description of the integration being configured

        Returns:
            OrderedDict: Contains various OutputProperty items
        """

    @abstractmethod
    def dispatch(self, **kwargs):
        """Send alerts to the given service. This base class just
            logs an error if not implemented on the inheriting class

        Args:
            **kwargs: consists of any combination of the following items:
                descriptor (str): Service descriptor (ie: slack channel, pd integration)
                rule_name (str): Name of the triggered rule
                alert (dict): Alert relevant to the triggered rule
        """
<commit_msg>[lambda][alert] fixing small bug where method should be classmethod<commit_after>"""
Copyright 2017-present, Airbnb Inc.

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.
"""
from abc import ABCMeta, abstractmethod
from collections import namedtuple
import json
import os
import tempfile
import requests
import urllib3

import boto3
from botocore.exceptions import ClientError

from stream_alert.alert_processor import LOGGER

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
OutputProperty = namedtuple('OutputProperty',
                            'description, value, input_restrictions, mask_input, cred_requirement')
OutputProperty.__new__.__defaults__ = ('', '', {' ', ':'}, False, False)

class OutputRequestFailure(Exception):
    """OutputRequestFailure handles any HTTP failures"""

class StreamAlertOutput(object):
    """Class to be used as a decorator to register all OutputDispatcher subclasses"""
    _outputs = {}

    def __new__(cls, output):
        StreamAlertOutput._outputs[output.__service__] = output
        return output

    @classmethod
    def create_dispatcher(cls, service, region, function_name, config):
        """Returns the subclass that should handle this particular service

        Args:
            service (str): The service identifier for this output
            region (str): The AWS region to use for some output types
            function_name (str): The invoking AWS Lambda function name
            config (dict): The loaded output configuration dict

        Returns:
            OutputDispatcher: Subclass of OutputDispatcher to use for sending alerts
        """
        dispatcher = cls.get_dispatcher(service)
        if not dispatcher:
            return False

        return dispatcher(region, function_name, config)

    @classmethod
    def get_dispatcher(cls, service):
        """Returns the subclass that should handle this particular service

        Args:
            service (str): The service identifier for this output

        Returns:
            OutputDispatcher: Subclass of OutputDispatcher to use for sending alerts
        """
        try:
            return cls._outputs[service]
        except KeyError:
            LOGGER.error('Designated output service [%s] does not exist', service)

    @classmethod
    def get_all_outputs(cls):
        """Return a copy of the cache containing all of the output subclasses

        Returns:
            dict: Cached dictionary of all registered StreamAlertOutputs where
                the key is the service and the value is the class object
        """
        return cls._outputs.copy()

class OutputDispatcher(object):
    """OutputDispatcher is the base class to handle routing alerts to outputs

    Public methods:
        get_secrets_bucket_name: returns the name of the s3 bucket for secrets that
            includes a unique prefix
        output_cred_name: the name that is used to store the credentials both on s3
            and locally on disk in tmp
        get_config_service: the name of the service used by the config to store any
            configured outputs for this service. implemented by some subclasses, but
            subclass is not required to implement
        format_output_config: returns a formatted version of the outputs configuration
            that is to be written to disk
        get_user_defined_properties: returns any properties for this output that must be
            provided by the user. must be implemented by subclasses
        dispatch: handles the actual sending of alerts to the configured service. must
            be implemented by subclass
    """
    __metaclass__ = ABCMeta
    __service__ = NotImplemented

    # _DEFAULT_REQUEST_TIMEOUT indicates how long the requests library will wait before timing
    # out for both get and post requests. This applies to both connection and read timeouts
    _DEFAULT_REQUEST_TIMEOUT = 3.05

    def __init__(self, region, function_name, config):
        self.region = region
        self.secrets_bucket = self._get_secrets_bucket_name(function_name)
        self.config = config

    @staticmethod
    def _local_temp_dir():
        """Get the local tmp directory for caching the encrypted service credentials

        Returns:
            str: local path for stream_alert_secrets tmp directory
        """
        temp_dir = os.path.join(tempfile.gettempdir(), "stream_alert_secrets")

        # Check if this item exists as a file, and remove it if it does
        if os.path.isfile(temp_dir):
            os.remove(temp_dir)

        # Create the folder on disk to store the credentials temporarily
        if not os.path.exists(temp_dir):
            os.makedirs(temp_dir)

        return temp_dir

    def _load_creds(self, descriptor):
        """First try to load the credentials from /tmp and then resort to pulling
        the credentials from S3 if they are not cached locally

        Args:
            descriptor (str): unique identifier used to look up these credentials

        Returns:
            dict: the loaded credential info needed for sending alerts to this service
                or None if nothing gets loaded
        """
        local_cred_location = os.path.join(self._local_temp_dir(),
                                           self.output_cred_name(descriptor))

        # Creds are not cached locally, so get the encrypted blob from s3
        if not os.path.exists(local_cred_location):
            if not self._get_creds_from_s3(local_cred_location, descriptor):
                return

        # Open encrypted credential file
        with open(local_cred_location, 'rb') as cred_file:
            enc_creds = cred_file.read()

        # Get the decrypted credential json from kms and load into dict
        # This could be None if the kms decryption fails, so check it
        decrypted_creds = self._kms_decrypt(enc_creds)
        if not decrypted_creds:
            return

        creds_dict = json.loads(decrypted_creds)

        # Add any of the hard-coded default output props to this dict (ie: url)
        defaults = self._get_default_properties()
        if defaults:
            creds_dict.update(defaults)

        return creds_dict

    @classmethod
    def _get_secrets_bucket_name(cls, function_name):
        """Returns the streamalerts secrets s3 bucket name"""
        prefix = function_name.split('_')[0]
        return '.'.join([prefix, 'streamalert', 'secrets'])

    def _get_creds_from_s3(self, cred_location, descriptor):
        """Pull the encrypted credential blob for this service and destination from s3

        Args:
            cred_location (str): The tmp path on disk to to store the encrypted blob
            descriptor (str): Service destination (ie: slack channel, pd integration)

        Returns:
            bool: True if download of creds from s3 was a success
        """
        try:
            if not os.path.exists(os.path.dirname(cred_location)):
                os.makedirs(os.path.dirname(cred_location))

            client = boto3.client('s3', region_name=self.region)
            with open(cred_location, 'wb') as cred_output:
                client.download_fileobj(self.secrets_bucket,
                                        self.output_cred_name(descriptor),
                                        cred_output)

            return True
        except ClientError as err:
            LOGGER.exception('credentials for \'%s\' could not be downloaded '
                             'from S3: %s', self.output_cred_name(descriptor),
                             err.response)

    def _kms_decrypt(self, data):
        """Decrypt data with AWS KMS.

        Args:
            data (str): An encrypted ciphertext data blob

        Returns:
            str: Decrypted json string
        """
        try:
            client = boto3.client('kms', region_name=self.region)
            response = client.decrypt(CiphertextBlob=data)
            return response['Plaintext']
        except ClientError as err:
            LOGGER.error('an error occurred during credentials decryption: %s', err.response)

    def _log_status(self, success):
        """Log the status of sending the alerts

        Args:
            success (bool): Indicates if the dispatching of alerts was successful
        """
        if success:
            LOGGER.info('Successfully sent alert to %s', self.__service__)
        else:
            LOGGER.error('Failed to send alert to %s', self.__service__)

        return bool(success)

    @classmethod
    def _get_request(cls, url, params=None, headers=None, verify=True):
        """Method to return the json loaded response for this GET request

        Args:
            url (str): Endpoint for this request
            params (dict): Payload to send with this request
            headers (dict): Dictionary containing request-specific header parameters
            verify (bool): Whether or not the server's SSL certificate should be verified
        Returns:
            dict: Contains the http response object
        """
        return requests.get(url, headers=headers, params=params,
                            verify=verify, timeout=cls._DEFAULT_REQUEST_TIMEOUT)

    @classmethod
    def _post_request(cls, url, data=None, headers=None, verify=True):
        """Method to return the json loaded response for this POST request

        Args:
            url (str): Endpoint for this request
            data (dict): Payload to send with this request
            headers (dict): Dictionary containing request-specific header parameters
            verify (bool): Whether or not the server's SSL certificate should be verified
        Returns:
            dict: Contains the http response object
        """
        return requests.post(url, headers=headers, json=data,
                             verify=verify, timeout=cls._DEFAULT_REQUEST_TIMEOUT)

    @classmethod
    def _check_http_response(cls, response):
        """Method for checking for a valid HTTP response code

        Args:
            response (requests.Response): Response object from requests

        Returns:
            bool: Indicator of whether or not this request was successful
        """
        success = response is not None and (200 <= response.status_code <= 299)
        if not success:
            LOGGER.error('Encountered an error while sending to %s:\n%s',
                         cls.__service__,
                         response.content)
        return success

    @classmethod
    def _get_default_properties(cls):
        """Base method for retrieving properties that should be hard-coded for this
        output service integration. This could include information such as a static
        url used for sending the alerts to this service, a static port, or other
        non-sensitive information.

        If information of this sort is needed, this should be overridden in output subclasses.

        NOTE: This should not contain any sensitive or use-case specific data. Information
        such as this should be retrieved from the user using `get_user_defined_properties()`
        so the user is prompted for the sensitive information at configuration time and said
        information is then sent to kms for encryption and s3 for storage.

        Returns:
            dict: Contains various default items for this output (ie: url)
        """
        pass

    @classmethod
    def output_cred_name(cls, descriptor):
        """Formats the output name for this credential by combining the service
        and the descriptor.

        Args:
            descriptor (str): Service destination (ie: slack channel, pd integration)

        Returns:
            str: Formatted credential name (ie: slack_ryandchannel)
        """
        cred_name = str(cls.__service__)

        # should descriptor be enforced in all rules?
        if descriptor:
            cred_name = '{}/{}'.format(cred_name, descriptor)

        return cred_name

    @classmethod
    def format_output_config(cls, service_config, values):
        """Add this descriptor to the list of descriptor this service
           If the service doesn't exist, a new entry is added to an empty list

        Args:
            service_config (dict): Loaded configuration as a dictionary
            values (OrderedDict): Contains various OutputProperty items
        Returns:
            [list<string>] List of descriptors for this service
        """
        return service_config.get(cls.__service__, []) + [values['descriptor'].value]

    @classmethod
    @abstractmethod
    def get_user_defined_properties(cls):
        """Base method for retrieving properties that must be asssigned by the user when
        configuring a new output for this service. This should include any information that
        is sensitive or use-case specific. For intance, if the url needed for this integration
        is unique to your situation, it should be supplied here.

        If information of this sort is needed, it should be added to the method that
        overrides this one in the subclass.

        At the very minimum, subclass functions should return an OrderedDict that contains
        the key 'descriptor' with a description of the integration being configured

        Returns:
            OrderedDict: Contains various OutputProperty items
        """

    @abstractmethod
    def dispatch(self, **kwargs):
        """Send alerts to the given service. This base class just
            logs an error if not implemented on the inheriting class

        Args:
            **kwargs: consists of any combination of the following items:
                descriptor (str): Service descriptor (ie: slack channel, pd integration)
                rule_name (str): Name of the triggered rule
                alert (dict): Alert relevant to the triggered rule
        """
<|endoftext|>


<commit_before>"""
Installation script for RLPy
"""

from setuptools import setup, Extension, find_packages
from Cython.Distutils import build_ext
import numpy
import os
import sys

version = '1.3.1'

if sys.platform == 'darwin':
    # by default use clang++ as this most likely to have c++11 support
    # on OSX
    if "CC" not in os.environ or os.environ["CC"] == "":
        os.environ["CC"] = "clang++"
        extra_args = ["-std=c++0x", "-stdlib=libc++"]
else:
    extra_args = []

setup(name="rlpy",
      version=version,
      maintainer="Christoph Dann",
      maintainer_email="cdann@cdann.de",
      license="BSD 3-clause",
      description="Value-Function-Based Reinforcement-Learning Library for"
                  + " Education and Research",
      url="http://acl.mit.edu/rlpy/",
      classifiers=['Intended Audience :: Science/Research',
                   'Intended Audience :: Developers',
                   'License :: OSI Approved',
                   'Programming Language :: C++',
                   'Programming Language :: Python',
                   'Topic :: Scientific/Engineering',
                   'Operating System :: Microsoft :: Windows',
                   'Operating System :: POSIX',
                   'Operating System :: Unix',
                   'Operating System :: MacOS',
                   'Programming Language :: Python :: 2',
                   'Programming Language :: Python :: 2.7',
                  ],
      long_description=open('README.rst').read(),
      packages=find_packages(exclude=['tests', 'tests.*']),
      include_package_data=True,
#      package_data={'rlpy': [
#          'Domains/GridWorldMaps/*.txt',
#          'Domains/IntruderMonitoringMaps/*.txt',
#          'Domains/PinballConfigs/*.cfg',
#          'Domains/PacmanPackage/layouts/*.lay',
#          'Domains/SystemAdministratorMaps/*.txt',
#          "Representations/c_kernels.h",
#      ]
#      },
      install_requires=[
          'numpy >= 1.7',
          'scipy',
          'matplotlib >= 1.2',
          'networkx',
          'scikit-learn',
          'joblib',
          'hyperopt',
          'pymongo'
      ],
      extras_require={'cython_extensions': ['cython']},
      cmdclass={'build_ext': build_ext},
      ext_modules=[
          Extension("rlpy.Representations.hashing",
                    ["rlpy/Representations/hashing.pyx"],
                    include_dirs=[numpy.get_include(), "rlpy/Representations"]),
          Extension("rlpy.Domains.HIVTreatment_dynamics",
                    ["rlpy/Domains/HIVTreatment_dynamics.pyx"],
                    include_dirs=[numpy.get_include(), "rlpy/Representations"]),
          Extension("rlpy.Representations.kernels",
                    ["rlpy/Representations/kernels.pyx",
                     "rlpy/Representations/c_kernels.cc",
                     "rlpy/Representations/c_kernels.pxd"],
                    language="c++",
                    include_dirs=[numpy.get_include(), "rlpy.Representations"]),
          Extension("rlpy.Tools._transformations",
                    ["rlpy/Tools/transformations.c"],
                    include_dirs=[numpy.get_include()])],
      test_suite='tests'
      )
<commit_msg>Do not cythonize by default during installation<commit_after>"""
Installation script for RLPy
"""

from setuptools import setup, Extension, find_packages
#from Cython.Distutils import build_ext
import numpy
import os
import sys

version = '1.3.2'

if sys.platform == 'darwin':
    # by default use clang++ as this most likely to have c++11 support
    # on OSX
    if "CC" not in os.environ or os.environ["CC"] == "":
        os.environ["CC"] = "clang++"
        extra_args = ["-std=c++0x", "-stdlib=libc++"]
else:
    extra_args = []

# only use Cython if explicitly told
USE_CYTHON =  os.getenv('USE_CYTHON', False)
extensions = [
          Extension("rlpy.Representations.hashing",
                    ["rlpy/Representations/hashing.pyx"],
                    include_dirs=[numpy.get_include(), "rlpy/Representations"]),
          Extension("rlpy.Domains.HIVTreatment_dynamics",
                    ["rlpy/Domains/HIVTreatment_dynamics.pyx"],
                    include_dirs=[numpy.get_include(), "rlpy/Representations"]),
          Extension("rlpy.Representations.kernels",
                    ["rlpy/Representations/kernels.pyx",
                     "rlpy/Representations/c_kernels.cc",
                     "rlpy/Representations/c_kernels.pxd"],
                    language="c++",
                    include_dirs=[numpy.get_include(), "rlpy.Representations"]),
          Extension("rlpy.Tools._transformations",
                    ["rlpy/Tools/transformations.c"],
                    include_dirs=[numpy.get_include()])]

def no_cythonize(extensions, **_ignore):
    for extension in extensions:
        sources = []
        for sfile in extension.sources:
            path, ext = os.path.splitext(sfile)
            if ext in ('.pyx', '.py'):
                if extension.language == 'c++':
                    ext = '.cpp'
                else:
                    ext = '.c'
                sfile = path + ext
            elif ext in ('.pxd'):
                continue
            sources.append(sfile)
        extension.sources[:] = sources
    return extensions

if USE_CYTHON:
    from Cython.Build import cythonize
    extensions = cythonize(extensions)
else:
    extensions = no_cythonize(extensions)

setup(name="rlpy",
      version=version,
      maintainer="Christoph Dann",
      maintainer_email="cdann@cdann.de",
      license="BSD 3-clause",
      description="Value-Function-Based Reinforcement-Learning Library for"
                  + " Education and Research",
      url="http://acl.mit.edu/rlpy/",
      classifiers=['Intended Audience :: Science/Research',
                   'Intended Audience :: Developers',
                   'License :: OSI Approved',
                   'Programming Language :: C++',
                   'Programming Language :: Python',
                   'Topic :: Scientific/Engineering',
                   'Operating System :: Microsoft :: Windows',
                   'Operating System :: POSIX',
                   'Operating System :: Unix',
                   'Operating System :: MacOS',
                   'Programming Language :: Python :: 2',
                   'Programming Language :: Python :: 2.7',
                  ],
      long_description=open('README.rst').read(),
      packages=find_packages(exclude=['tests', 'tests.*']),
      include_package_data=True,
#      package_data={'rlpy': [
#          'Domains/GridWorldMaps/*.txt',
#          'Domains/IntruderMonitoringMaps/*.txt',
#          'Domains/PinballConfigs/*.cfg',
#          'Domains/PacmanPackage/layouts/*.lay',
#          'Domains/SystemAdministratorMaps/*.txt',
#          "Representations/c_kernels.h",
#      ]
#      },
      install_requires=[
          'numpy >= 1.7',
          'scipy',
          'matplotlib >= 1.2',
          'networkx',
          'scikit-learn',
          'joblib',
          'hyperopt',
          'pymongo'
      ],
      ext_modules=extensions,
      test_suite='tests'
      )
<|endoftext|>


<commit_before>from setuptools import setup, find_packages
setup(
    name='cleave',
    packages=find_packages(),
    version='0.2',
    description='Python easy tools library',
    author='Maxim Papezhuk',
    author_email='maxp.job@gmail.com',
    url='https://github.com/Max201/cleave',
    download_url='https://github.com/Max201/cleave/tarball/v0.2',
    keywords=['server', 'python', 'socket', 'easy', 'encryption'],
    classifiers=[],
    entry_points={
        'console_scripts': [
            'serve=cleave.tool:HttpFileServer',
        ],
    },
)<commit_msg>Updated description<commit_after>from setuptools import setup, find_packages
setup(
    name='cleave',
    packages=find_packages(),
    version='0.21',
    description='Python easy tools library. Allows to run local http server in one command.',
    author='Maxim Papezhuk',
    author_email='maxp.job@gmail.com',
    url='https://github.com/Max201/cleave',
    download_url='https://github.com/Max201/cleave/tarball/v0.21',
    keywords=['server', 'python', 'socket', 'easy', 'encryption', 'http server', 'file server'],
    classifiers=[],
    entry_points={
        'console_scripts': [
            'serve=cleave.tool:HttpFileServer',
        ],
    },
)<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
#
# Copyright (c) 2010-2012 Cidadania S. Coop. Galega
#
# This file is part of e-cidadania.
#
# e-cidadania is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# e-cidadania is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with e-cidadania. If not, see <http://www.gnu.org/licenses/>.

from src.core.spaces.models import Space
from src.apps.ecidadania.debate.models import Debate

from tests.test_utils import ECDTestCase

class ListDebatesViewsTest(ECDTestCase):
    """Tests the views of debate app.
    """

    def setUp(self):
        self.init()

    def testListDebatesView(self):
        """Tests ListDebates view.
        """
        user = self.create_user('test_user', 'abcde')
        other_user = self.create_user('other_test_user', 'acsrsd')
        space_properties = {'name': 'test_space', 'url': 'test_space_url',
                            'author': user, 'public': True}
        space1 = self.seed(Space, properties=space_properties)

        space_properties.update({'name': 'other_space', 'url': 'other_test_url',
                                'author': other_user, 'public': True})
        space2 = self.seed(Space, space_properties)

        debate_properties = {'space': space1, 'author': user}
        debate1 = self.seed(Debate, properties=debate_properties)
        debate2 = self.seed(Debate, properties=debate_properties)
        debates_list = [debate1, debate2]

        debate_properties.update({'space': space2, 'author': other_user})
        debate3 = self.seed(Debate, properties=debate_properties)
        debate4 = self.seed(Debate, properties=debate_properties)
        debate5 = self.seed(Debate, properties=debate_properties)
        other_debates_list = [debate3, debate4, debate5]
        url = self.getURL('list-debates', kwargs={'space_url':space1.url})
        response = self.get(url)
        #print self.printResponse(response)
        self.assertResponseOK(response)
        self.assertEqual(len(response.context[0].dicts[0]['debate_list']),
                         len(debates_list))

        url = self.getURL('list-debates', kwargs={'space_url': space2.url})
        response = self.get(url)
        self.assertResponseOK(response)
        self.assertEqual(len(response.context[0].dicts[0]['debate_list']),
                         len(other_debates_list))

    def testViewDebate(self):
        """Tests ViewDebate view.
        """
        url = self.getURL('view-debate',(), {'debate_id': self.user_debate.id,
                                             'space_url': self.user_space.url})
        response = self.get(url)
        self.assertResponseOK(response)
        context = response.context[0].dicts[0]
        assert 'notes' in context
        assert 'columns' in context
        assert 'rows' in context
        assert 'get_place' in context
        #print context['columns']
        self.assertEqual(len(context['notes']), 1)
        self.assertEqual(len(context['columns']), 1)
        self.assertEqual(len(context['rows']), 1)

        url = self.getURL('view-debate',(), {'debate_id': 5,
                                             'space_url': self.user_space.url})
        response = self.get(url)
        self.assertResponseNotFound(response)
<commit_msg>Accomodate changes done in test_utils.py.<commit_after># -*- coding: utf-8 -*-
#
# Copyright (c) 2010-2012 Cidadania S. Coop. Galega
#
# This file is part of e-cidadania.
#
# e-cidadania is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# e-cidadania is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with e-cidadania. If not, see <http://www.gnu.org/licenses/>.

from src.core.spaces.models import Space
from src.apps.ecidadania.debate.models import Debate

from tests.test_utils import ECDTestCase

class ListDebatesViewsTest(ECDTestCase):
    """Tests the views of debate app.
    """

    def setUp(self):
        self.init()

    def testListDebatesView(self):
        """Tests ListDebates view.
        """
        user = self.create_user('test_user', 'abcde')
        other_user = self.create_user('other_test_user', 'acsrsd')
        space_properties = {'name': 'test_space', 'url': 'test_space_url',
                            'author': user, 'public': True}
        space1 = self.seed(Space, properties=space_properties)

        space_properties.update({'name': 'other_space', 'url': 'other_test_url',
                                'author': other_user, 'public': True})
        space2 = self.seed(Space, space_properties)

        debate_properties = {'space': space1, 'author': user}
        debate1 = self.seed(Debate, properties=debate_properties)
        debate2 = self.seed(Debate, properties=debate_properties)
        debates_list = [debate1, debate2]

        debate_properties.update({'space': space2, 'author': other_user})
        debate3 = self.seed(Debate, properties=debate_properties)
        debate4 = self.seed(Debate, properties=debate_properties)
        debate5 = self.seed(Debate, properties=debate_properties)
        other_debates_list = [debate3, debate4, debate5]
        url = self.getURL('list-debates', kwargs={'space_url':space1.url})
        response = self.get(url)
        #print self.printResponse(response)
        self.assertResponseOK(response)
        self.assertEqual(len(response.context[0].dicts[0]['debate_list']),
                         len(debates_list))

        url = self.getURL('list-debates', kwargs={'space_url': space2.url})
        response = self.get(url)
        self.assertResponseOK(response)
        self.assertEqual(len(response.context[0].dicts[0]['debate_list']),
                         len(other_debates_list))

    def testViewDebate(self):
        """Tests ViewDebate view.
        """
        url = self.getURL('view-debate',(), {'debate_id': self.foo_debate.id,
                                             'space_url': self.foo_space.url})
        response = self.get(url)
        self.assertResponseOK(response)
        context = response.context[0].dicts[0]
        assert 'notes' in context
        assert 'columns' in context
        assert 'rows' in context
        assert 'get_place' in context
        #print context['columns']
        self.assertEqual(len(context['notes']), 1)
        self.assertEqual(len(context['columns']), 1)
        self.assertEqual(len(context['rows']), 1)

        url = self.getURL('view-debate',(), {'debate_id': 5,
                                             'space_url': self.foo_space.url})
        response = self.get(url)
        self.assertResponseNotFound(response)
<|endoftext|>


<commit_before>#!/usr/bin/env python
# -*- coding: UTF-8 -*-

#usage python batch_download_insert.py

from Bio import SeqIO

def download_to_insert(accession):
    import subprocess

    r = from_nuccore(accession)

    if r is None:
        print 'OH CRAP'
    else:
        subprocess.call('python insert.py -i ' + from_nuccore(accession))

    print 'woogle'

def downloadFasta_to_insert(url):
    import subprocess, os

    from time import sleep

    print 'working on ' + url
    try:
        r = download_fasta(url)
    except:
        sleep(300)
        continue

    print 'done downloading, file at ' + r
    print 'now generating .ttl'
    if r is None:
        print 'OH CRAP'
    else:
        print 'calling subproces'
        subprocess.call(['./insert.py', '-i', r])
        print 'done generating .ttl'
    #os.remove(r) need to add way to check after
    print 'woogle'

if __name__ == "__main__":
    from multiprocessing import Pool, cpu_count

    '''this is testing code using the .csv file
    import pandas #this is the .csv parser we're using
    from _utils import from_nuccore

    metadata_table = pandas.read_csv('data/metadata_table.csv')
    accessions = metadata_table['primary_dbxref'].apply(lambda s: s.strip().split(':')[1])

    p = Pool(multiprocessing.cpu_count()) #you can use an int instead, just don't go crazy
    #note: you may want to write out the fasta file, but I'm unsure whether it will improve performance as concurrency requires them all to be loaded into memory anyways
    p.map(download_to_insert, accessions)
    '''

    #testing using the .txt file as source
    from _utils import download_fasta

    with open('data/download_files.txt') as f:
        lines = f.read().splitlines()
        p = Pool(cpu_count())
        p.map(downloadFasta_to_insert, lines)
<commit_msg>bug fix<commit_after>#!/usr/bin/env python
# -*- coding: UTF-8 -*-

#usage python batch_download_insert.py

from Bio import SeqIO

def download_to_insert(accession):
    import subprocess

    r = from_nuccore(accession)

    if r is None:
        print 'OH CRAP'
    else:
        subprocess.call('python insert.py -i ' + from_nuccore(accession))

    print 'woogle'

def downloadFasta_to_insert(url):
    import subprocess, os

    from time import sleep

    print 'working on ' + url

    i = 0

    while i < 3:
        try:
            r = download_fasta(url)
        except:
            sleep(300)
            i += 1
            continue

    print 'done downloading, file at ' + r
    print 'now generating .ttl'
    if r is None:
        print 'OH CRAP'
    else:
        print 'calling subproces'
        subprocess.call(['./insert.py', '-i', r])
        print 'done generating .ttl'
    #os.remove(r) need to add way to check after
    print 'woogle'

if __name__ == "__main__":
    from multiprocessing import Pool, cpu_count

    '''this is testing code using the .csv file
    import pandas #this is the .csv parser we're using
    from _utils import from_nuccore

    metadata_table = pandas.read_csv('data/metadata_table.csv')
    accessions = metadata_table['primary_dbxref'].apply(lambda s: s.strip().split(':')[1])

    p = Pool(multiprocessing.cpu_count()) #you can use an int instead, just don't go crazy
    #note: you may want to write out the fasta file, but I'm unsure whether it will improve performance as concurrency requires them all to be loaded into memory anyways
    p.map(download_to_insert, accessions)
    '''

    #testing using the .txt file as source
    from _utils import download_fasta

    with open('data/download_files.txt') as f:
        lines = f.read().splitlines()
        p = Pool(cpu_count())
        p.map(downloadFasta_to_insert, lines)
<|endoftext|>


<commit_before># coding=utf-8
# Copyright 2021 TF.Text Authors.
#
# 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.

r"""Tool to generate external api_docs.

python build_docs.py --output_dir=/tmp/text_api
"""
import os

from absl import app
from absl import flags

import tensorflow as tf

from tensorflow_docs.api_generator import doc_controls
from tensorflow_docs.api_generator import generate_lib
from tensorflow_docs.api_generator import public_api

import tensorflow_text as text

PROJECT_SHORT_NAME = "text"
PROJECT_FULL_NAME = "TensorFlow Text"

FLAGS = flags.FLAGS

flags.DEFINE_string(
    "output_dir",
    default="/tmp/text_api",
    help="Where to write the resulting docs to.")
flags.DEFINE_string(
    "code_url_prefix",
    "http://github.com/tensorflow/text/blob/master/tensorflow_text",
    "The url prefix for links to code.")

flags.DEFINE_bool("search_hints", True,
                  "Include metadata search hints in the generated files")

flags.DEFINE_string("site_path", "/text/api_docs/python",
                    "Path prefix in the _toc.yaml")

flags.DEFINE_bool("gen_report", False,
                  ("Generate an API report containing the health of the"
                   "docstrings of the public API."))

def _hide_layer_and_module_methods():
  """Hide methods and properties defined in the base classes of keras layers."""
  # __dict__ only sees attributes defined in *this* class, not on parent classes
  # Needed to ignore redudant subclass documentation
  module_contents = list(tf.Module.__dict__.items())
  layer_contents = list(tf.keras.layers.Layer.__dict__.items())

  for name, obj in module_contents + layer_contents:
    if name == "__init__":
      continue

    if isinstance(obj, property):
      obj = obj.fget

    if isinstance(obj, (staticmethod, classmethod)):
      obj = obj.__func__

    try:
      doc_controls.do_not_doc_in_subclasses(obj)
    except AttributeError:
      pass

def build_docs():
  """Build api docs for tensorflow_text."""
  _hide_layer_and_module_methods()
  del text.keras  # keras is empty.

  doc_generator = generate_lib.DocGenerator(
      root_title="TensorFlow Text",
      py_modules=[("text", text)],
      base_dir=os.path.dirname(text.__file__),
      search_hints=True,
      code_url_prefix=FLAGS.code_url_prefix,
      site_path="text/api_docs/python",
      callbacks=[public_api.explicit_package_contents_filter])
  doc_generator.build(FLAGS.output_dir)

def main(_):
  # Build API docs
  build_docs()

if __name__ == "__main__":
  app.run(main)
<commit_msg>Use the gen_report flag to generate the API report.<commit_after># coding=utf-8
# Copyright 2021 TF.Text Authors.
#
# 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.

r"""Tool to generate external api_docs.

python build_docs.py --output_dir=/tmp/text_api
"""
import os

from absl import app
from absl import flags

import tensorflow as tf

from tensorflow_docs.api_generator import doc_controls
from tensorflow_docs.api_generator import generate_lib
from tensorflow_docs.api_generator import public_api

import tensorflow_text as text

PROJECT_SHORT_NAME = "text"
PROJECT_FULL_NAME = "TensorFlow Text"

FLAGS = flags.FLAGS

flags.DEFINE_string(
    "output_dir",
    default="/tmp/text_api",
    help="Where to write the resulting docs to.")
flags.DEFINE_string(
    "code_url_prefix",
    "http://github.com/tensorflow/text/blob/master/tensorflow_text",
    "The url prefix for links to code.")

flags.DEFINE_bool("search_hints", True,
                  "Include metadata search hints in the generated files")

flags.DEFINE_string("site_path", "/text/api_docs/python",
                    "Path prefix in the _toc.yaml")

flags.DEFINE_bool("gen_report", False,
                  ("Generate an API report containing the health of the"
                   "docstrings of the public API."))

def _hide_layer_and_module_methods():
  """Hide methods and properties defined in the base classes of keras layers."""
  # __dict__ only sees attributes defined in *this* class, not on parent classes
  # Needed to ignore redudant subclass documentation
  module_contents = list(tf.Module.__dict__.items())
  layer_contents = list(tf.keras.layers.Layer.__dict__.items())

  for name, obj in module_contents + layer_contents:
    if name == "__init__":
      continue

    if isinstance(obj, property):
      obj = obj.fget

    if isinstance(obj, (staticmethod, classmethod)):
      obj = obj.__func__

    try:
      doc_controls.do_not_doc_in_subclasses(obj)
    except AttributeError:
      pass

def build_docs():
  """Build api docs for tensorflow_text."""
  _hide_layer_and_module_methods()
  del text.keras  # keras is empty.

  doc_generator = generate_lib.DocGenerator(
      root_title="TensorFlow Text",
      py_modules=[("text", text)],
      base_dir=os.path.dirname(text.__file__),
      search_hints=True,
      code_url_prefix=FLAGS.code_url_prefix,
      site_path="text/api_docs/python",
      gen_report=FLAGS.gen_report,
      callbacks=[public_api.explicit_package_contents_filter])
  doc_generator.build(FLAGS.output_dir)

def main(_):
  # Build API docs
  build_docs()

if __name__ == "__main__":
  app.run(main)
<|endoftext|>


<commit_before>"""Tasks we perform on the master server.

See `askmaster.py` for tasks that are run on minions."""

import os
import aws
from fabric.api import sudo, task, local
from buildercore import core, bootstrap, config, keypair
from buildercore.utils import last
from decorators import debugtask, echo_output, requires_project, requires_aws_stack, requires_feature
from kids.cache import cache as cached
import logging

LOG = logging.getLogger(__name__)

#
#
#

@debugtask
@requires_feature('write-keypairs-to-s3')
def write_missing_keypairs_to_s3():
    "uploads any missing ec2 keys to S3 if they're present locally"
    remote_keys = keypair.all_in_s3()
    local_paths = keypair.all_locally()
    local_keys = map(os.path.basename, local_paths)

    to_upload = set(local_keys).difference(set(remote_keys))

    print 'remote:', remote_keys
    print 'local:', local_keys
    print 'to upload:', to_upload

    def write(key):
        stackname = os.path.splitext(key)[0]
        keypair.write_keypair_to_s3(stackname)

    map(write, to_upload)

def write_missing_context_to_s3():
    pass

@debugtask
@requires_feature('write-keypairs-to-s3')
@requires_aws_stack
@echo_output
def download_keypair(stackname):
    try:
        path = keypair.download_from_s3(stackname)
        local('chmod 400 -R %s' % path)
        return path
    except EnvironmentError as err:
        LOG.info(err.message)

#
#
#

@debugtask
@echo_output
@cached
def server_access():
    """returns True if this builder instance has access to the master server.
    access may be available through presence of the master-server's bootstrap user's
    identify file OR current user is in master server's allowed_keys list"""
    stackname = core.find_master(core.find_region())
    public_ip = core.stack_data(stackname, ensure_single_instance=True)[0]['ip_address']
    result = local('ssh -o "StrictHostKeyChecking no" %s@%s "exit"' % (config.BOOTSTRAP_USER, public_ip))
    return result.return_code == 0

@echo_output
def aws_update_many_projects(pname_list):
    minions = ' or '.join(map(lambda pname: pname + "-*", pname_list))
    region = aws.find_region()
    with core.stack_conn(core.find_master(region)):
        sudo("salt -C '%s' state.highstate --retcode-passthrough" % minions)

@debugtask
@requires_project
def aws_update_projects(pname):
    "calls state.highstate on ALL projects matching <projectname>-*"
    return aws_update_many_projects([pname])

@debugtask
@requires_aws_stack
def remaster_minion(stackname, master_ip=None):
    "tell minion who their new master is. deletes any existing master key on minion"

    if not master_ip:
        newest_master = last(core.find_master_servers(core.active_aws_stacks(core.find_region())))
        if not newest_master:
            raise core.NoMasterException("no master servers found")
        master_ip = core.stack_data(newest_master)[0]['private_ip_address']

    print 're-mastering %s to %s' % (stackname, master_ip)

    def work():
        sudo("rm -f /etc/salt/pki/minion/minion_master.pub")  # destroy the old master key we have
        sudo("sed -i -e 's/^master:.*$/master: %s/g' /etc/salt/minion" % master_ip)
    core.stack_all_ec2_nodes(stackname, work, username=config.BOOTSTRAP_USER)
    bootstrap.update_ec2_stack(stackname, concurrency='serial')
<commit_msg>linted<commit_after>"""Tasks we perform on the master server.

See `askmaster.py` for tasks that are run on minions."""

import os
import aws
from fabric.api import sudo, local
from buildercore import core, bootstrap, config, keypair
from buildercore.utils import last
from decorators import debugtask, echo_output, requires_project, requires_aws_stack, requires_feature
from kids.cache import cache as cached
import logging

LOG = logging.getLogger(__name__)

#
#
#

@debugtask
@requires_feature('write-keypairs-to-s3')
def write_missing_keypairs_to_s3():
    "uploads any missing ec2 keys to S3 if they're present locally"
    remote_keys = keypair.all_in_s3()
    local_paths = keypair.all_locally()
    local_keys = map(os.path.basename, local_paths)

    to_upload = set(local_keys).difference(set(remote_keys))

    print 'remote:', remote_keys
    print 'local:', local_keys
    print 'to upload:', to_upload

    def write(key):
        stackname = os.path.splitext(key)[0]
        keypair.write_keypair_to_s3(stackname)

    map(write, to_upload)

def write_missing_context_to_s3():
    pass

@debugtask
@requires_feature('write-keypairs-to-s3')
@requires_aws_stack
@echo_output
def download_keypair(stackname):
    try:
        path = keypair.download_from_s3(stackname)
        local('chmod 400 -R %s' % path)
        return path
    except EnvironmentError as err:
        LOG.info(err.message)

#
#
#

@debugtask
@echo_output
@cached
def server_access():
    """returns True if this builder instance has access to the master server.
    access may be available through presence of the master-server's bootstrap user's
    identify file OR current user is in master server's allowed_keys list"""
    stackname = core.find_master(core.find_region())
    public_ip = core.stack_data(stackname, ensure_single_instance=True)[0]['ip_address']
    result = local('ssh -o "StrictHostKeyChecking no" %s@%s "exit"' % (config.BOOTSTRAP_USER, public_ip))
    return result.return_code == 0

@echo_output
def aws_update_many_projects(pname_list):
    minions = ' or '.join(map(lambda pname: pname + "-*", pname_list))
    region = aws.find_region()
    with core.stack_conn(core.find_master(region)):
        sudo("salt -C '%s' state.highstate --retcode-passthrough" % minions)

@debugtask
@requires_project
def aws_update_projects(pname):
    "calls state.highstate on ALL projects matching <projectname>-*"
    return aws_update_many_projects([pname])

@debugtask
@requires_aws_stack
def remaster_minion(stackname, master_ip=None):
    "tell minion who their new master is. deletes any existing master key on minion"

    if not master_ip:
        newest_master = last(core.find_master_servers(core.active_aws_stacks(core.find_region())))
        if not newest_master:
            raise core.NoMasterException("no master servers found")
        master_ip = core.stack_data(newest_master)[0]['private_ip_address']

    print 're-mastering %s to %s' % (stackname, master_ip)

    def work():
        sudo("rm -f /etc/salt/pki/minion/minion_master.pub")  # destroy the old master key we have
        sudo("sed -i -e 's/^master:.*$/master: %s/g' /etc/salt/minion" % master_ip)
    core.stack_all_ec2_nodes(stackname, work, username=config.BOOTSTRAP_USER)
    bootstrap.update_ec2_stack(stackname, concurrency='serial')
<|endoftext|>


<commit_before>from distutils.core import setup

setup(
    name='django-flatblocks',
    version='0.6.0',
    description='django-flatblocks acts like django.contrib.flatpages but '
                'for parts of a page; like an editable help box you want '
                'show alongside the main content.',
    long_description=open('README.rst').read(),
    keywords='django apps',
    license='New BSD License',
    author='Horst Gutmann',
    author_email='zerok@zerokspot.com',
    url='http://github.com/zerok/django-flatblocks/',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Environment :: Plugins',
        'Framework :: Django',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: BSD License',
        'Programming Language :: Python',
        'Topic :: Software Development :: Libraries :: Python Modules',
    ],
    packages=['flatblocks', 'flatblocks.management',
              'flatblocks.management.commands', 'flatblocks.migrations',
              'flatblocks.templatetags'],
    data_files=['MANIFEST.in']
)
<commit_msg>Preparing for 0.7.0<commit_after>from distutils.core import setup

setup(
    name='django-flatblocks',
    version='0.7.0',
    description='django-flatblocks acts like django.contrib.flatpages but '
                'for parts of a page; like an editable help box you want '
                'show alongside the main content.',
    long_description=open('README.rst').read(),
    keywords='django apps',
    license='New BSD License',
    author='Horst Gutmann',
    author_email='zerok@zerokspot.com',
    url='http://github.com/zerok/django-flatblocks/',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Environment :: Plugins',
        'Framework :: Django',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: BSD License',
        'Programming Language :: Python',
        'Topic :: Software Development :: Libraries :: Python Modules',
    ],
    packages=['flatblocks', 'flatblocks.management',
              'flatblocks.management.commands', 'flatblocks.migrations',
              'flatblocks.templatetags'],
    data_files=['MANIFEST.in']
)
<|endoftext|>


<commit_before>#!/usr/bin/env python

from __future__ import print_function

import distutils.spawn
import shlex
import subprocess
import sys

from setuptools import find_packages
from setuptools import setup

version = '6.4.14'

if sys.argv[1] == 'release':
    if not distutils.spawn.find_executable('twine'):
        print(
            'Please install twine:\n\n\tpip install twine\n',
            file=sys.stderr,
        )
        sys.exit(1)

    commands = [
        'git pull origin master',
        'git tag v{:s}'.format(version),
        'git push origin master --tag',
        'python setup.py sdist',
        'twine upload dist/fcn-{:s}.tar.gz'.format(version),
    ]
    for cmd in commands:
        print('+ {}'.format(cmd))
        subprocess.check_call(shlex.split(cmd))
    sys.exit(0)

def get_long_description():
    with open('README.md') as f:
        long_description = f.read()

    try:
        import github2pypi
    except ImportError:
        return long_description

    return github2pypi.replace_url(
        slug='wkentaro/fcn', content=long_description
    )

def get_install_requires():
    with open('requirements.txt') as f:
        return [req.strip() for req in f]

setup(
    name='fcn',
    version=version,
    packages=find_packages(exclude=['github2pypi']),
    include_package_data=True,
    scripts=['scripts/fcn_infer.py'],
    install_requires=get_install_requires(),
    description='Fully Convolutional Networks',
    long_description=get_long_description(),
    long_description_content_type='text/markdown',
    author='Kentaro Wada',
    author_email='www.kentaro.wada@gmail.com',
    url='http://github.com/wkentaro/fcn',
    license='MIT',
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: Developers',
        'Natural Language :: English',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: Implementation :: CPython',
        'Programming Language :: Python :: Implementation :: PyPy',
    ],
)
<commit_msg>6.4.15<commit_after>#!/usr/bin/env python

from __future__ import print_function

import distutils.spawn
import shlex
import subprocess
import sys

from setuptools import find_packages
from setuptools import setup

version = '6.4.15'

if sys.argv[1] == 'release':
    if not distutils.spawn.find_executable('twine'):
        print(
            'Please install twine:\n\n\tpip install twine\n',
            file=sys.stderr,
        )
        sys.exit(1)

    commands = [
        'git pull origin master',
        'git tag v{:s}'.format(version),
        'git push origin master --tag',
        'python setup.py sdist',
        'twine upload dist/fcn-{:s}.tar.gz'.format(version),
    ]
    for cmd in commands:
        print('+ {}'.format(cmd))
        subprocess.check_call(shlex.split(cmd))
    sys.exit(0)

def get_long_description():
    with open('README.md') as f:
        long_description = f.read()

    try:
        import github2pypi
    except ImportError:
        return long_description

    return github2pypi.replace_url(
        slug='wkentaro/fcn', content=long_description
    )

def get_install_requires():
    with open('requirements.txt') as f:
        return [req.strip() for req in f]

setup(
    name='fcn',
    version=version,
    packages=find_packages(exclude=['github2pypi']),
    include_package_data=True,
    scripts=['scripts/fcn_infer.py'],
    install_requires=get_install_requires(),
    description='Fully Convolutional Networks',
    long_description=get_long_description(),
    long_description_content_type='text/markdown',
    author='Kentaro Wada',
    author_email='www.kentaro.wada@gmail.com',
    url='http://github.com/wkentaro/fcn',
    license='MIT',
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: Developers',
        'Natural Language :: English',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: Implementation :: CPython',
        'Programming Language :: Python :: Implementation :: PyPy',
    ],
)
<|endoftext|>


<commit_before>#from distutils.core import setup
#from distutils.extension import Extension
from setuptools import setup
from setuptools.extension import Extension

import subprocess

import os
import numpy

try:
    from Cython.Build import cythonize
    USE_CYTHON = True
except ImportError:
    USE_CYTHON = False

if not os.path.exists('grizli/utils_c/interp.pyx'):
    USE_CYTHON = False

if USE_CYTHON:
    cext = '.pyx'
else:
    cext = '.c'

print('C extension: {0}'.format(cext))

extensions = [
    Extension("grizli.utils_c.interp", ["grizli/utils_c/interp"+cext],
        include_dirs = [numpy.get_include()],
        libraries=["m"]),

    Extension("grizli.utils_c.disperse", ["grizli/utils_c/disperse"+cext],
        include_dirs = [numpy.get_include()],
        libraries=["m"]),

]

#update version
args = 'git describe --tags'
p = subprocess.Popen(args.split(), stdout=subprocess.PIPE)
version = p.communicate()[0].decode("utf-8").strip()

version = "0.7.0"

version_str = """# git describe --tags
__version__ = "{0}"\n""".format(version)

fp = open('grizli/version.py','w')
fp.write(version_str)
fp.close()
print('Git version: {0}'.format(version))

if USE_CYTHON:
    extensions = cythonize(extensions)

# Utility function to read the README file.
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name = "grizli",
    version = version,
    author = "Gabriel Brammer",
    author_email = "gbrammer@gmail.com",
    description = "Grism redshift and line analysis software",
    license = "MIT",
    url = "https://github.com/gbrammer/grizli",
    download_url = "https://github.com/gbrammer/grizli/tarball/{0}".format(version),
    packages=['grizli', 'grizli/pipeline', 'grizli/utils_c', 'grizli/tests', 'grizli/galfit'],
    # requires=['numpy', 'scipy', 'astropy', 'drizzlepac', 'stwcs'],
    # long_description=read('README.rst'),
    classifiers=[
        "Development Status :: 1 - Planning",
        'Intended Audience :: Science/Research',
        'Topic :: Scientific/Engineering :: Astronomy',
    ],
    ext_modules = extensions,
    package_data={'grizli': ['data/*', 'data/templates/*', 'data/templates/stars/*', 'data/templates/fsps/*']},
    # scripts=['grizli/scripts/flt_info.sh'],
)
<commit_msg>tag version<commit_after>#from distutils.core import setup
#from distutils.extension import Extension
from setuptools import setup
from setuptools.extension import Extension

import subprocess

import os
import numpy

try:
    from Cython.Build import cythonize
    USE_CYTHON = True
except ImportError:
    USE_CYTHON = False

if not os.path.exists('grizli/utils_c/interp.pyx'):
    USE_CYTHON = False

if USE_CYTHON:
    cext = '.pyx'
else:
    cext = '.c'

print('C extension: {0}'.format(cext))

extensions = [
    Extension("grizli.utils_c.interp", ["grizli/utils_c/interp"+cext],
        include_dirs = [numpy.get_include()],
        libraries=["m"]),

    Extension("grizli.utils_c.disperse", ["grizli/utils_c/disperse"+cext],
        include_dirs = [numpy.get_include()],
        libraries=["m"]),

]

#update version
args = 'git describe --tags'
p = subprocess.Popen(args.split(), stdout=subprocess.PIPE)
version = p.communicate()[0].decode("utf-8").strip()

#version = "0.7.0"

version_str = """# git describe --tags
__version__ = "{0}"\n""".format(version)

fp = open('grizli/version.py','w')
fp.write(version_str)
fp.close()
print('Git version: {0}'.format(version))

if USE_CYTHON:
    extensions = cythonize(extensions)

# Utility function to read the README file.
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name = "grizli",
    version = version,
    author = "Gabriel Brammer",
    author_email = "gbrammer@gmail.com",
    description = "Grism redshift and line analysis software",
    license = "MIT",
    url = "https://github.com/gbrammer/grizli",
    download_url = "https://github.com/gbrammer/grizli/tarball/{0}".format(version),
    packages=['grizli', 'grizli/pipeline', 'grizli/utils_c', 'grizli/tests', 'grizli/galfit'],
    # requires=['numpy', 'scipy', 'astropy', 'drizzlepac', 'stwcs'],
    # long_description=read('README.rst'),
    classifiers=[
        "Development Status :: 1 - Planning",
        'Intended Audience :: Science/Research',
        'Topic :: Scientific/Engineering :: Astronomy',
    ],
    ext_modules = extensions,
    package_data={'grizli': ['data/*', 'data/templates/*', 'data/templates/stars/*', 'data/templates/fsps/*']},
    # scripts=['grizli/scripts/flt_info.sh'],
)
<|endoftext|>


<commit_before>#
# Copyright (C) 2015 Man AHL
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
# USA

import logging
from setuptools import setup
from setuptools.extension import Extension
from setuptools import find_packages
from setuptools.command.test import test as TestCommand
import sys
import os
import platform

if platform.system().lower() == 'darwin':
    # clang on macOS does not work with OpenMP
    ccs = ["/usr/local/bin/g++-5", "/usr/local/bin/g++-6", "/usr/local/bin/g++-7"]
    cc = None
    for compiler in ccs:
        if os.path.isfile(compiler):
            cc = compiler
    if cc is None:
        raise ValueError("You must install gcc/g++. You can install with homebrew: brew install gcc --without-multilib")
    os.environ["CC"] = cc.replace("g++", "gcc")
    os.environ["CXX"] = cc
    # not all OSX/clang compiler flags supported by GCC. For some reason
    # these sometimes are generated and used. Cython will still add more flags.
    os.environ["CFLAGS"] = "-fno-common -fno-strict-aliasing -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -g -fwrapv -Os"

# Convert Markdown to RST for PyPI
# http://stackoverflow.com/a/26737672
try:
    import pypandoc
    long_description = pypandoc.convert('README.md', 'rst')
    changelog = pypandoc.convert('CHANGES.md', 'rst')
except (IOError, ImportError, OSError):
    long_description = open('README.md').read()
    changelog = open('CHANGES.md').read()

class PyTest(TestCommand):
    user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]

    def initialize_options(self):
        TestCommand.initialize_options(self)
        self.pytest_args = []

    def finalize_options(self):
        TestCommand.finalize_options(self)
        self.test_args = []
        self.test_suite = True

    def run_tests(self):
        logging.basicConfig(format='%(asctime)s %(levelname)s %(name)s %(message)s', level='DEBUG')

        # import here, cause outside the eggs aren't loaded
        import pytest
        import six

        args = [self.pytest_args] if isinstance(self.pytest_args, six.string_types) else list(self.pytest_args)
        args.extend(['--cov', 'arctic',
                     '--cov-report', 'xml',
                     '--cov-report', 'html',
                     '--junitxml', 'junit.xml',
                    ])
        errno = pytest.main(args)
        sys.exit(errno)

class defer_cythonize(list):
    def __init__(self, callback):
        self._list, self.callback = None, callback

    def c_list(self):
        if self._list is None:
            self._list = self.callback()
        return self._list

    def __iter__(self):
        for elem in self.c_list():
            yield elem

    def __getitem__(self, ii):
        return self.c_list()[ii]

    def __len__(self):
        return len(self.c_list())

def extensions():
    from Cython.Build import cythonize
    return cythonize(Extension('arctic._compress',
                               sources=["src/_compress.pyx", "src/lz4.c", "src/lz4hc.c"],
                               extra_compile_args=['-fopenmp', '-fpermissive'], # Avoid compiling error with prange. Similar to http://stackoverflow.com/questions/36577182/unable-to-assign-value-to-array-in-prange
                               extra_link_args=['-fopenmp']))

setup(
    name="arctic",
    version="1.51.0",
    author="Man AHL Technology",
    author_email="ManAHLTech@ahl.com",
    description=("AHL Research Versioned TimeSeries and Tick store"),
    license="GPL",
    keywords=["ahl", "keyvalue", "tickstore", "mongo", "timeseries", ],
    url="https://github.com/manahl/arctic",
    packages=find_packages(exclude=['tests', 'tests.*', 'benchmarks']),
    long_description='\n'.join((long_description, changelog)),
    cmdclass={'test': PyTest},
    ext_modules=defer_cythonize(extensions),
    setup_requires=["six",
                    "cython",
                    "numpy",
                    "setuptools-git",
                   ],
    install_requires=["cython",
                      "decorator",
                      "enum34",
                      "mockextras",
                      "pandas",
                      "pymongo",
                      "python-dateutil",
                      "pytz",
                      "tzlocal",
                     ],
    tests_require=["mock",
                   "mockextras",
                   "pytest",
                   "pytest-cov",
                   "pytest-server-fixtures",
                   "pytest-timeout",
                   "pytest-xdist",
                   "lz4"
                  ],
    entry_points={'console_scripts': [
                                        'arctic_init_library = arctic.scripts.arctic_init_library:main',
                                        'arctic_list_libraries = arctic.scripts.arctic_list_libraries:main',
                                        'arctic_delete_library = arctic.scripts.arctic_delete_library:main',
                                        'arctic_enable_sharding = arctic.scripts.arctic_enable_sharding:main',
                                        'arctic_copy_data = arctic.scripts.arctic_copy_data:main',
                                        'arctic_create_user = arctic.scripts.arctic_create_user:main',
                                        'arctic_prune_versions = arctic.scripts.arctic_prune_versions:main',
                                        'arctic_fsck = arctic.scripts.arctic_fsck:main',
                                        ]
                  },
    classifiers=[
        "Development Status :: 4 - Beta",
        "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
        "Programming Language :: Python :: 2.7",
        "Programming Language :: Python :: 3.4",
        "Programming Language :: Python :: 3.5",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: Implementation :: CPython",
        "Programming Language :: Cython",
        "Operating System :: POSIX",
        "Operating System :: MacOS",
        "Topic :: Database",
        "Topic :: Database :: Front-Ends",
        "Topic :: Software Development :: Libraries",
    ],
)
<commit_msg>Rolling version number 1.51.0 -> 1.52.0<commit_after>#
# Copyright (C) 2015 Man AHL
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
# USA

import logging
from setuptools import setup
from setuptools.extension import Extension
from setuptools import find_packages
from setuptools.command.test import test as TestCommand
import sys
import os
import platform

if platform.system().lower() == 'darwin':
    # clang on macOS does not work with OpenMP
    ccs = ["/usr/local/bin/g++-5", "/usr/local/bin/g++-6", "/usr/local/bin/g++-7"]
    cc = None
    for compiler in ccs:
        if os.path.isfile(compiler):
            cc = compiler
    if cc is None:
        raise ValueError("You must install gcc/g++. You can install with homebrew: brew install gcc --without-multilib")
    os.environ["CC"] = cc.replace("g++", "gcc")
    os.environ["CXX"] = cc
    # not all OSX/clang compiler flags supported by GCC. For some reason
    # these sometimes are generated and used. Cython will still add more flags.
    os.environ["CFLAGS"] = "-fno-common -fno-strict-aliasing -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -g -fwrapv -Os"

# Convert Markdown to RST for PyPI
# http://stackoverflow.com/a/26737672
try:
    import pypandoc
    long_description = pypandoc.convert('README.md', 'rst')
    changelog = pypandoc.convert('CHANGES.md', 'rst')
except (IOError, ImportError, OSError):
    long_description = open('README.md').read()
    changelog = open('CHANGES.md').read()

class PyTest(TestCommand):
    user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]

    def initialize_options(self):
        TestCommand.initialize_options(self)
        self.pytest_args = []

    def finalize_options(self):
        TestCommand.finalize_options(self)
        self.test_args = []
        self.test_suite = True

    def run_tests(self):
        logging.basicConfig(format='%(asctime)s %(levelname)s %(name)s %(message)s', level='DEBUG')

        # import here, cause outside the eggs aren't loaded
        import pytest
        import six

        args = [self.pytest_args] if isinstance(self.pytest_args, six.string_types) else list(self.pytest_args)
        args.extend(['--cov', 'arctic',
                     '--cov-report', 'xml',
                     '--cov-report', 'html',
                     '--junitxml', 'junit.xml',
                    ])
        errno = pytest.main(args)
        sys.exit(errno)

class defer_cythonize(list):
    def __init__(self, callback):
        self._list, self.callback = None, callback

    def c_list(self):
        if self._list is None:
            self._list = self.callback()
        return self._list

    def __iter__(self):
        for elem in self.c_list():
            yield elem

    def __getitem__(self, ii):
        return self.c_list()[ii]

    def __len__(self):
        return len(self.c_list())

def extensions():
    from Cython.Build import cythonize
    return cythonize(Extension('arctic._compress',
                               sources=["src/_compress.pyx", "src/lz4.c", "src/lz4hc.c"],
                               extra_compile_args=['-fopenmp', '-fpermissive'], # Avoid compiling error with prange. Similar to http://stackoverflow.com/questions/36577182/unable-to-assign-value-to-array-in-prange
                               extra_link_args=['-fopenmp']))

setup(
    name="arctic",
    version="1.52.0",
    author="Man AHL Technology",
    author_email="ManAHLTech@ahl.com",
    description=("AHL Research Versioned TimeSeries and Tick store"),
    license="GPL",
    keywords=["ahl", "keyvalue", "tickstore", "mongo", "timeseries", ],
    url="https://github.com/manahl/arctic",
    packages=find_packages(exclude=['tests', 'tests.*', 'benchmarks']),
    long_description='\n'.join((long_description, changelog)),
    cmdclass={'test': PyTest},
    ext_modules=defer_cythonize(extensions),
    setup_requires=["six",
                    "cython",
                    "numpy",
                    "setuptools-git",
                   ],
    install_requires=["cython",
                      "decorator",
                      "enum34",
                      "mockextras",
                      "pandas",
                      "pymongo",
                      "python-dateutil",
                      "pytz",
                      "tzlocal",
                     ],
    tests_require=["mock",
                   "mockextras",
                   "pytest",
                   "pytest-cov",
                   "pytest-server-fixtures",
                   "pytest-timeout",
                   "pytest-xdist",
                   "lz4"
                  ],
    entry_points={'console_scripts': [
                                        'arctic_init_library = arctic.scripts.arctic_init_library:main',
                                        'arctic_list_libraries = arctic.scripts.arctic_list_libraries:main',
                                        'arctic_delete_library = arctic.scripts.arctic_delete_library:main',
                                        'arctic_enable_sharding = arctic.scripts.arctic_enable_sharding:main',
                                        'arctic_copy_data = arctic.scripts.arctic_copy_data:main',
                                        'arctic_create_user = arctic.scripts.arctic_create_user:main',
                                        'arctic_prune_versions = arctic.scripts.arctic_prune_versions:main',
                                        'arctic_fsck = arctic.scripts.arctic_fsck:main',
                                        ]
                  },
    classifiers=[
        "Development Status :: 4 - Beta",
        "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
        "Programming Language :: Python :: 2.7",
        "Programming Language :: Python :: 3.4",
        "Programming Language :: Python :: 3.5",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: Implementation :: CPython",
        "Programming Language :: Cython",
        "Operating System :: POSIX",
        "Operating System :: MacOS",
        "Topic :: Database",
        "Topic :: Database :: Front-Ends",
        "Topic :: Software Development :: Libraries",
    ],
)
<|endoftext|>


<commit_before># coding=utf-8
# author@alingse
# 2016.10.07

from setuptools import setup, find_packages

from jsoncsv import __version__

version = '.'.join(map(str, __version__))

with open('README.md') as f:
    readme = f.read()

with open('LICENSE') as f:
    license = f.read()

setup(
    name='jsoncsv',
    version=version,
    description='a tool convert json file to csv or xlsx',
    long_description=readme,
    author='alingse',
    author_email='alingse@foxmail.com',
    license=license,
    packages=find_packages(exclude=('tests')),
    install_requires=[
        'xlwt',
    ],
    entry_points={
        'console_scripts': [
            'jsoncsv = jsoncsv.main:jsoncsv',
            'mkexcel = jsoncsv.main:mkexcel',
        ],
    }
)
<commit_msg>pypi 信息<commit_after># coding=utf-8
# author@alingse
# 2016.10.07

from setuptools import setup, find_packages

from jsoncsv import __version__

version = '.'.join(map(str, __version__))

# with open('README.md') as f:
#    readme = f.read()
readme = 'Documents: https://github.com/alingse/jsoncsv'

setup(
    name='jsoncsv',
    version=version,
    description='a tool convert json file to csv or xlsx',
    long_description=readme,
    author='alingse',
    author_email='alingse@foxmail.com',
    url='https://github.com/alingse/jsoncsv',
    license='Apache 2.0',
    packages=find_packages(exclude=('tests')),
    install_requires=[
        'xlwt',
    ],
    entry_points={
        'console_scripts': [
            'jsoncsv = jsoncsv.main:jsoncsv',
            'mkexcel = jsoncsv.main:mkexcel',
        ],
    }
)
<|endoftext|>


<commit_before>import re
import setuptools

versionLine = open("axiom/_version.py", "rt").read()
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", versionLine, re.M)
versionString = match.group(1)

setuptools.setup(
    name="Axiom",
    version=versionString,
    description="An in-process object-relational database",
    url="http://divmod.org/trac/wiki/DivmodAxiom",

    maintainer="Divmod, Inc.",
    maintainer_email="support@divmod.org",

    license="MIT",
    platforms=["any"],

    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Framework :: Twisted",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python",
        "Topic :: Database"],

    scripts=['bin/axiomatic'])
<commit_msg>Tell setuptools about Axiom packages<commit_after>import re
import setuptools

versionLine = open("axiom/_version.py", "rt").read()
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", versionLine, re.M)
versionString = match.group(1)

setuptools.setup(
    name="Axiom",
    version=versionString,
    description="An in-process object-relational database",
    url="http://divmod.org/trac/wiki/DivmodAxiom",

    maintainer="Divmod, Inc.",
    maintainer_email="support@divmod.org",

    packages=["axiom", "axiom.test", "axiom.plugins"],
    scripts=['bin/axiomatic'],

    license="MIT",
    platforms=["any"],

    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Framework :: Twisted",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python",
        "Topic :: Database"])
<|endoftext|>


<commit_before>from dragonfly import (Grammar, FocusWindow, MappingRule, Key, Config, Section, Item, Playback, Mimic)

rules = MappingRule(
	name = "general",
	mapping = {
		"slap": Key("enter"),
		"Max when": Key("w-up"),
		"left when": Key("w-left"),
		"right when": Key("w-right"),
		"min win": Key("w-down"),
    "switch apps": Key("alt:down, tab"),
		"switch app": Key("a-tab"),
    "termi": Key("w-1"),
    "foxy": Key("w-2"),
    "foxy reload": Key("w-2/10, f5"),
    "Jimmy": Key("w-3"),
    "Heidi": Key("w-4"),
    "chrome": Key("w-5"),
    "chrome reload": Key("w-5/10, f5"),
    "smelly": Key("w-6"),
    "bashing": Key("w-7"),
    "code mode": Mimic("\\no-caps-on") + Mimic("\\no-space-on"),
	}
)

grammar = Grammar("general")
grammar.add_rule(rules)
grammar.load()

def unload():
  global grammar
  if grammar: grammar.unload()
  grammar = None
<commit_msg>Fixing app switching<commit_after>from dragonfly import (Grammar, FocusWindow, MappingRule, Key, Config, Section, Item, Playback, Mimic)

rules = MappingRule(
	name = "general",
	mapping = {
		"slap": Key("enter"),
		"Max when": Key("w-up"),
		"left when": Key("w-left"),
		"right when": Key("w-right"),
		"min win": Key("w-down"),
    "switch apps": Key("alt:down, tab"),
		"switch app": Key("a-tab"),
    "termi": Key("w-b/10, s-tab/10, enter"),
    "foxy": Key("w-b/10, s-tab/10, right:1/10, enter"),
    "foxy reload": Key("w-b/10, s-tab/10, right:1/10, enter/10, f5"),
    "Jimmy": Key("w-b/10, s-tab/10, right:2/10, enter"),
    "Heidi": Key("w-b/10, s-tab/10, right:3/10, enter"),
    "chrome": Key("w-b/10, s-tab/10, right:4/10, enter"),
    "chrome reload": Key("w-b/10, s-tab/10, right:4/10, enter/10, f5"),
    "bashing": Key("w-b/10, s-tab/10, right:5/10, enter"),
    "code mode": Mimic("\\no-caps-on") + Mimic("\\no-space-on"),
	}
)

grammar = Grammar("general")
grammar.add_rule(rules)
grammar.load()

def unload():
  global grammar
  if grammar: grammar.unload()
  grammar = None
<|endoftext|>


<commit_before>"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/Rambatino/CHAID
"""

from setuptools import setup, find_packages
from codecs import open
from os import path

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name='CHAID',
    version='0.0.7',
    description='A CHAID tree building algorithm',
    long_description=long_description,
    url='https://github.com/Rambatino/CHAID',
    author='Mark Ramotowski, Richard Fitzgerald',
    author_email='mark.tint.ramotowski@gmail.com',
    license='MIT',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'Topic :: Software Development :: Build Tools',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
    ],
    keywords='CHAID pandas numpy scipy statistics statistical analysis',
    packages=find_packages(exclude=['contrib', 'docs', 'tests']),
    install_requires=['numpy', 'scipy', 'pandas', 'treelib'],
    extras_require={
        'dev': ['check-manifest'],
        'test': ['coverage'],
    }
)<commit_msg>Updated the setup file<commit_after>"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/Rambatino/CHAID
"""

from setuptools import setup, find_packages
from codecs import open
from os import path

setup(
    name='CHAID',
    version='0.0.8',
    description='A CHAID tree building algorithm',
    long_description="This package provides a python implementation of the Chi-Squared Automatic Inference Detection (CHAID) decision tree",
    url='https://github.com/Rambatino/CHAID',
    author='Mark Ramotowski, Richard Fitzgerald',
    author_email='mark.tint.ramotowski@gmail.com',
    license='MIT',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'Topic :: Software Development :: Build Tools',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',
    ],
    keywords='CHAID pandas numpy scipy statistics statistical analysis',
    packages=find_packages(exclude=['contrib', 'docs', 'tests']),
    install_requires=['numpy', 'scipy', 'pandas', 'treelib'],
    extras_require={
        'dev': ['check-manifest'],
        'test': ['coverage'],
    }
)<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
from setuptools import find_packages
from setuptools import setup

setup(
    name='plone.server',
    version=open('src/plone.server/VERSION').read().strip(),
    long_description=(open('src/plone.server/README.rst').read() + '\n' +
                      open('src/plone.server/CHANGELOG.rst').read()),
    classifiers=[
        'Framework :: Plone :: 7.0',
        'Programming Language :: Python :: 3.5',
        'Topic :: Software Development :: Libraries :: Python Modules',
    ],
    url='https://pypi.python.org/pypi/plone.server',
    license='GPL version 3',
    setup_requires=[
        'pytest-runner',
    ],
    zip_safe=True,
    include_package_data=True,
    packages=find_packages(exclude=['ez_setup']),
    namespace_packages=['plone'],
    install_requires=[
        'aiohttp',
        'ujson',
        'BTrees',
        'cchardet',
        'plone.dexterity',
        'plone.jsonserializer',
        'plone.registry',
        'plone.supermodel',
        'plone.i18n',
        'plone.indexer',
        'repoze.workflow',
        'setuptools',
        'transaction',
        'ZODB',
        'ZEO',
        'zope.component',
        'zope.configuration',
        'zope.copy',
        'zope.dottedname',
        'zope.event',
        'zope.i18n',
        'zope.i18nmessageid',
        'zope.interface',
        'zope.location',
        'zope.proxy',
        'zope.schema',
        'zope.security'
    ],
    extras_require={
        'test': [
            'pytest',
            'requests'
        ]
    },
    entry_points={
        'console_scripts': [
            'server = plone.server.server:main',
        ]
    }
)
<commit_msg>Add pycrypto so there is RSA keys on websocket token generation<commit_after># -*- coding: utf-8 -*-
from setuptools import find_packages
from setuptools import setup

setup(
    name='plone.server',
    version=open('src/plone.server/VERSION').read().strip(),
    long_description=(open('src/plone.server/README.rst').read() + '\n' +
                      open('src/plone.server/CHANGELOG.rst').read()),
    classifiers=[
        'Framework :: Plone :: 7.0',
        'Programming Language :: Python :: 3.5',
        'Topic :: Software Development :: Libraries :: Python Modules',
    ],
    url='https://pypi.python.org/pypi/plone.server',
    license='GPL version 3',
    setup_requires=[
        'pytest-runner',
    ],
    zip_safe=True,
    include_package_data=True,
    packages=find_packages(exclude=['ez_setup']),
    namespace_packages=['plone'],
    install_requires=[
        'aiohttp',
        'ujson',
        'pycrypto',
        'BTrees',
        'cchardet',
        'plone.dexterity',
        'plone.jsonserializer',
        'plone.registry',
        'plone.supermodel',
        'plone.i18n',
        'plone.indexer',
        'repoze.workflow',
        'setuptools',
        'transaction',
        'ZODB',
        'ZEO',
        'zope.component',
        'zope.configuration',
        'zope.copy',
        'zope.dottedname',
        'zope.event',
        'zope.i18n',
        'zope.i18nmessageid',
        'zope.interface',
        'zope.location',
        'zope.proxy',
        'zope.schema',
        'zope.security'
    ],
    extras_require={
        'test': [
            'pytest',
            'requests'
        ]
    },
    entry_points={
        'console_scripts': [
            'server = plone.server.server:main',
        ]
    }
)
<|endoftext|>