<commit_before>#!/bin/bash

checkVirtualPythonEnvironmentFolder() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  goToRoot
  if [ -d "$1" ]; then
    cd $1/
  else
    cd $2/
    mkdir $3
    cd $3/
  fi;
}

postgresPasswordReset() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  goToRoot
  sudo -u postgres psql < $1
  sudo service postgresql restart
}

goToDir() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  cd $1/
}

pythonThreeVeCheck() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  if [ -z "$4" ]; then
    echo 'null value not allowed as fourth parameter! You must pass the required parameter(s).'
    return $4
  fi;
  if [ -d "$1/bin" ]; then
    cd $1/
    echo "VE exists for $4!"
  else
    cd $2/
    virtualenv -p python3.5 $3
    echo "Created VE for $4!"
  fi;
}

pythonTwoVeCheck() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  if [ -z "$4" ]; then
    echo 'null value not allowed as fourth parameter! You must pass the required parameter(s).'
    return $4
  fi;
  if [ -d "$1/bin" ]; then
    cd $1/
    echo "VE exists for $4!"
  else
    cd $2/
    virtualenv -p python2 $3
    echo "Created VE for $4!"
  fi;
}

pythonVeVersionDecider() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  if [ -z "$4" ]; then
    echo 'null value not allowed as fourth parameter! You must pass the required parameter(s).'
    return $4
  fi;
  if [ -z "$5" ]; then
    echo 'null value not allowed as fifth parameter! You must pass the required parameter(s).'
    return $5
  fi;
  if [ "$5" = "2" ]; then
    eval 'pythonTwoVeCheck "${1}" "${2}" "${3}" "${4}"'
  elif [ "$5" = "3" ]; then
    eval 'pythonThreeVeCheck "${1}" "${2}" "${3}" "${4}"'
  else
    echo "Invalid parameter passed for python version."
  fi;
}

djangoUseVe() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  eval ${2}_ve_check
  cd $1/
  source bin/activate
  eval ${2}_dir
}

startCeleryWorkers() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  nohup celery -A $1 worker -l info &
  nohup celery -A $1 beat -l info -S django &
  nohup celery flower -A $1 --address=$2 --port=$3 &
}

djangoStopProcesses() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  kill -9 $(lsof -t -i:$1)
  kill $(ps aux | grep python | grep manage.py | awk '{print $2}')
  celery multi stop celery --pidfile=celerybeat.pid
  celery multi stop worker
  celery multi stop $2
  celery multi stop flower
  celery multi stop beat
  celery -A $2 purge -f
  ps auxww | grep 'celery worker' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'beat' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'flower' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'worker' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'celery' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'nohup' | awk '{print $2}' | xargs kill -9
  ps auxww | grep "$2" | awk '{print $2}' | xargs kill -9
}

djangoVeClear() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;<commit_msg>Fixed the chrome crashing issue.<commit_after>#!/bin/bash

checkVirtualPythonEnvironmentFolder() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  goToRoot
  if [ -d "$1" ]; then
    cd $1/
  else
    cd $2/
    mkdir $3
    cd $3/
  fi;
}

postgresPasswordReset() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  goToRoot
  sudo -u postgres psql < $1
  sudo service postgresql restart
}

goToDir() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  cd $1/
}

pythonThreeVeCheck() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  if [ -z "$4" ]; then
    echo 'null value not allowed as fourth parameter! You must pass the required parameter(s).'
    return $4
  fi;
  if [ -d "$1/bin" ]; then
    cd $1/
    echo "VE exists for $4!"
  else
    cd $2/
    virtualenv -p python3.5 $3
    echo "Created VE for $4!"
  fi;
}

pythonTwoVeCheck() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  if [ -z "$4" ]; then
    echo 'null value not allowed as fourth parameter! You must pass the required parameter(s).'
    return $4
  fi;
  if [ -d "$1/bin" ]; then
    cd $1/
    echo "VE exists for $4!"
  else
    cd $2/
    virtualenv -p python2 $3
    echo "Created VE for $4!"
  fi;
}

pythonVeVersionDecider() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  if [ -z "$4" ]; then
    echo 'null value not allowed as fourth parameter! You must pass the required parameter(s).'
    return $4
  fi;
  if [ -z "$5" ]; then
    echo 'null value not allowed as fifth parameter! You must pass the required parameter(s).'
    return $5
  fi;
  if [ "$5" = "2" ]; then
    eval 'pythonTwoVeCheck "${1}" "${2}" "${3}" "${4}"'
  elif [ "$5" = "3" ]; then
    eval 'pythonThreeVeCheck "${1}" "${2}" "${3}" "${4}"'
  else
    echo "Invalid parameter passed for python version."
  fi;
}

djangoUseVe() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  eval ${2}_ve_check
  cd $1/
  source bin/activate
  eval ${2}_dir
}

startCeleryWorkers() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  if [ -z "$3" ]; then
    echo 'null value not allowed as third parameter! You must pass the required parameter(s).'
    return $3
  fi;
  nohup celery -A $1 worker -l info &
  nohup celery -A $1 beat -l info -S django &
  nohup celery flower -A $1 --address=$2 --port=$3 &
}

djangoStopProcesses() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
  kill -9 $(lsof -t -i:$1)
  kill $(ps aux | grep python | grep manage.py | awk '{print $2}')
  celery multi stop celery --pidfile=celerybeat.pid
  celery multi stop worker
  celery multi stop $2
  celery multi stop flower
  celery multi stop beat
  celery -A $2 purge -f
  ps auxww | grep 'celery worker' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'beat' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'flower' | awk '{print $2}' | xargs kill -9
  #the following command crashes chrome
  #ps auxww | grep 'worker' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'celery' | awk '{print $2}' | xargs kill -9
  ps auxww | grep 'nohup' | awk '{print $2}' | xargs kill -9
  ps auxww | grep "$2" | awk '{print $2}' | xargs kill -9
}

djangoVeClear() {
  if [ -z "$1" ]; then
    echo 'null value not allowed as first parameter! You must pass the required parameter(s).'
    return $1
  fi;
  if [ -z "$2" ]; then
    echo 'null value not allowed as second parameter! You must pass the required parameter(s).'
    return $2
  fi;
{'fraction_non_alphanumeric': 0.12664791703287046, 'fraction_numerical': 0.020390226753383724, 'mean_word_length': 2.7247135842880525, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7520055', 'n_tokens_mistral': 3832, 'n_tokens_neox': 3764, 'n_words': 1658}