<commit_before># -*- coding: utf-8 -*-
#
# Cookbook Name:: sentry cookbook
# Definition:: sentry_conf
#
# Making sentry configuration file
#
# :copyright: (c) 2012 - 2013 by <NAME> (<EMAIL>).
# :license: BSD, see LICENSE for more details.
# :github: http://github.com/Lispython/sentry-cookbook
#

class Chef::Recipe
  include Chef::Mixin::DeepMerge
end

define :sentry_conf,
       :name => nil,
       :template => "sentry/sentry.conf.erb",
       :virtualenv_dir => nil,
       :user => "sentry",
       :group => "sentry",
       :config => nil,
       :superusers => [],
       :variables => {},
       :templates_cookbook => "sentry",
       :settings => {} do

  Chef::Log.info("Making sentry config for: #{params[:name]}")
  include_recipe "python::virtualenv"
  include_recipe "python::pip"
  include_recipe "sentry::default"

  virtualenv_dir = params[:virtualenv_dir] or node["sentry"]["virtulenv"]

  #settings_variables = Chef::Mixin::DeepMerge.deep_merge!(node[:sentry][:settings].to_hash, params[:settings])

  node.default["settings_variables"] = params[:settings]
  config = params[:config] || node["sentry"]["config"]
  node.default["settings_variables"]["config"] = config

  Chef::Log.info("Making directory for virtualenv: #{virtualenv_dir}")
  # Making application virtualenv directory
  directory virtualenv_dir do
    owner params[:user]
    group params[:group]
    mode 0777
    recursive true
    action :create
  end

  Chef::Log.info("Making virtualenv: #{virtualenv_dir}")
  # Creating virtualenv structure
  python_virtualenv virtualenv_dir do
    owner params[:user]
    group params[:group]
    action :create
  end

  Chef::Log.info("Making config #{config}")
  # Creating sentry config
  template config do
    owner params[:user]
    group params[:group]
    source params[:template]
    mode 0777
    variables(node["settings_variables"].to_hash)
    cookbook params[:templates_cookbook]
  end

  # Intstall sentry via pip
  python_pip "sentry" do
    provider Chef::Provider::PythonPip
    user params[:user]
    group params[:group]
    virtualenv virtualenv_dir
    version node["sentry"]["version"]
    action :install
  end

  # Install database drivers
  node['sentry']['settings']['databases'].each do |key, db_options|
    driver_name = nil
    if db_options['ENGINE'] == 'django.db.backends.postgresql_psycopg2'
      driver_name = 'psycopg2'
    elsif db_options['ENGINE'] == 'django.db.backends.mysql'
      driver_name = 'mysql-python'
    elsif db_options['ENGINE'] == 'django.db.backends.oracle'
      driver_name = 'cx_Oracle'
    else
      raise "You need specify database ENGINE"
    end

    if driver_name
      Chef::Log.info("Install #{driver_name} driver")
      python_pip driver_name do
        user params[:user]
        group params[:group]
        provider Chef::Provider::PythonPip
        virtualenv virtualenv_dir
        action :install
      end<commit_msg>Mysql driver for ubuntu with required package<commit_after># -*- coding: utf-8 -*-
#
# Cookbook Name:: sentry cookbook
# Definition:: sentry_conf
#
# Making sentry configuration file
#
# :copyright: (c) 2012 - 2013 by <NAME> (<EMAIL>).
# :license: BSD, see LICENSE for more details.
# :github: http://github.com/Lispython/sentry-cookbook
#

class Chef::Recipe
  include Chef::Mixin::DeepMerge
end

define :sentry_conf,
       :name => nil,
       :template => "sentry/sentry.conf.erb",
       :virtualenv_dir => nil,
       :user => "sentry",
       :group => "sentry",
       :config => nil,
       :superusers => [],
       :variables => {},
       :templates_cookbook => "sentry",
       :settings => {} do

  Chef::Log.info("Making sentry config for: #{params[:name]}")
  include_recipe "python::virtualenv"
  include_recipe "python::pip"
  include_recipe "sentry::default"

  virtualenv_dir = params[:virtualenv_dir] or node["sentry"]["virtulenv"]

  #settings_variables = Chef::Mixin::DeepMerge.deep_merge!(node[:sentry][:settings].to_hash, params[:settings])

  node.default["settings_variables"] = params[:settings]
  config = params[:config] || node["sentry"]["config"]
  node.default["settings_variables"]["config"] = config

  Chef::Log.info("Making directory for virtualenv: #{virtualenv_dir}")
  # Making application virtualenv directory
  directory virtualenv_dir do
    owner params[:user]
    group params[:group]
    mode 0777
    recursive true
    action :create
  end

  Chef::Log.info("Making virtualenv: #{virtualenv_dir}")
  # Creating virtualenv structure
  python_virtualenv virtualenv_dir do
    owner params[:user]
    group params[:group]
    action :create
  end

  Chef::Log.info("Making config #{config}")
  # Creating sentry config
  template config do
    owner params[:user]
    group params[:group]
    source params[:template]
    mode 0777
    variables(node["settings_variables"].to_hash)
    cookbook params[:templates_cookbook]
  end

  # Intstall sentry via pip
  python_pip "sentry" do
    provider Chef::Provider::PythonPip
    user params[:user]
    group params[:group]
    virtualenv virtualenv_dir
    version node["sentry"]["version"]
    action :install
  end

  # Install database drivers
  node['sentry']['settings']['databases'].each do |key, db_options|
    driver_name = nil
    if db_options['ENGINE'] == 'django.db.backends.postgresql_psycopg2'
      driver_name = 'psycopg2'
    elsif db_options['ENGINE'] == 'django.db.backends.mysql'
      if node['platform'] == 'ubuntu'
        package "libmysqlclient-dev" # mysql-python requires this package to be installed
        driver_name = 'mysql-python'
      else
        driver_name = 'MySQLdb'
      end
    elsif db_options['ENGINE'] == 'django.db.backends.oracle'
      driver_name = 'cx_Oracle'
    else
      raise "You need specify database ENGINE"
    end

    if driver_name
      Chef::Log.info("Install #{driver_name} driver")
      python_pip driver_name do
        user params[:user]
        group params[:group]
        provider Chef::Provider::PythonPip
        virtualenv virtualenv_dir
        action :install
      end
{'fraction_non_alphanumeric': 0.12823471237844075, 'fraction_numerical': 0.0062633921213120156, 'mean_word_length': 3.674884437596302, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5869583', 'n_tokens_mistral': 1931, 'n_tokens_neox': 1854, 'n_words': 441}