<commit_before>#!/bin/bash

#    Copyright 2015 <NAME>

#    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.

# :Author:
#     <NAME> (<EMAIL>)

# __author__ = '<EMAIL>'

function install_packages()
{
	echo ">>> Installing system packages..."
	sudo aptitude update && sudo aptitude dist-upgrade -y
	sudo aptitude install $( cat "$linux_packages" ) -y
}

function install_sip()
{

        # Downloading packages for GUI
        # Needed to install SIP first
	cd $venv_path
	mkdir build && cd build
	wget http://downloads.sourceforge.net/project/pyqt/sip/sip-4.17/sip-4.17.tar.gz	
	tar -xvf sip-4.17.tar.gz
	cd sip-4.17
	python configure.py
	make
	sudo make install
	cd ../ && rm -rf sip-4.17


}

function install_pyqt4()
{

        # PyQt4 installation.
        wget http://downloads.sourceforge.net/project/pyqt/PyQt4/PyQt-4.11.4/PyQt-x11-gpl-4.11.4.tar.gz
        tar xvzf PyQt-x11-gpl-4.11.4.tar.gz
        cd PyQt-x11-gpl-4.11.4
        python ./configure.py --confirm-license --no-designer-plugin -q /usr/bin/qmake-qt4 -e QtGui -e QtCore
        make
        # Bug. Needed ldconfig, copy it from /usr/sbin
        cp /sbin/ldconfig ../../bin/
        sudo ldconfig
        sudo make install
        cd ../ && rm -r -f PyQt*

}

function install_venv()
{
	[[ -d $venv_dir ]] || {

    	echo ">>> Creating virtual environment..."
    	virtualenv --python=python2.7 $venv_dir
    	source "$venv_dir/bin/activate"
	    pip install -r "$project_path/requirements.txt"
	    deactivate

	} && {
	    echo ">>> Python Virtual environment found, skipping"
	}
}

script_path="$( cd "$( dirname "$0" )" && pwd )"
project_path=$( readlink -e "$script_path/.." )

linux_packages="$script_path/debian.packages"
venv_dir="$project_path/.venv"

if [ $1 == '-install' ];
then

    [[ $_install_packages == 'true' ]] && install_packages
    [[ $_install_venv == 'true' ]] && install_venv

	[[ $_generate_keys == 'true' ]] && create_selfsigned_keys
    [[ $_create_logs == 'true' ]] && create_logs_dir

    [[ $_config_supervisor == 'true' ]] && configure_supervisor

    [[ $_reboot == 'true' ]] && {
 
    	echo ">>> To apply changes you must reboot your system"
    	echo ">>> Reboot now? (yes/no)"
    	read OPTION
    	[[ $OPTION == 'yes' ]] && sudo reboot

    }
fi



	# Enable serial access
	currentUser=$(whoami)
	sudo usermod -a -G dialout $currentUser 

	# Install required packages
	sudo apt --assume-yes install build-essential 
	sudo apt --assume-yes install virtualenv
	sudo apt --assume-yes install python-qt4
	sudo apt --assume-yes install libqt4-dev 
	sudo apt --assume-yes install unzip
	sudo apt --assume-yes install python-pip
	sudo apt --assume-yes install python-dev
	sudo apt --assume-yes install libffi-dev
	sudo apt --assume-yes install libssl-dev
 	sudo apt --asumme-yes install libcanberra-gtk-module
 	sudo apt --assume-yes install shc
	sudo apt --assume-yes --force-yes install unzip

	# Create a virtualenv
	virtualenv $venv_path
	source "$venv_path/bin/activate"
	pip install -r "$project_path/requirements.txt"

	# Downloading packages for GUI
	# Needed to install SIP first
	cd $venv_path<commit_msg>Installation script updated.<commit_after>#!/bin/bash

#    Copyright 2015 <NAME>

#    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.

# :Author:
#     <NAME> (<EMAIL>)

# __author__ = '<EMAIL>'

function install_packages()
{
	echo ">>> Installing system packages..."
	sudo aptitude update && sudo aptitude dist-upgrade -y
	sudo aptitude install $( cat "$linux_packages" ) -y
}

function install_sip()
{

        # Downloading packages for GUI
        # Needed to install SIP first
	cd $venv_path
	mkdir build && cd build
	wget http://downloads.sourceforge.net/project/pyqt/sip/sip-4.17/sip-4.17.tar.gz	
	tar -xvf sip-4.17.tar.gz
	cd sip-4.17
	python configure.py
	make
	sudo make install
	cd ../ && rm -rf sip-4.17


}

function install_pyqt4()
{

        # PyQt4 installation.
        wget http://downloads.sourceforge.net/project/pyqt/PyQt4/PyQt-4.11.4/PyQt-x11-gpl-4.11.4.tar.gz
        tar xvzf PyQt-x11-gpl-4.11.4.tar.gz
        cd PyQt-x11-gpl-4.11.4
        python ./configure.py --confirm-license --no-designer-plugin -q /usr/bin/qmake-qt4 -e QtGui -e QtCore
        make
        # Bug. Needed ldconfig, copy it from /usr/sbin
        cp /sbin/ldconfig ../../bin/
        sudo ldconfig
        sudo make install
        cd ../ && rm -r -f PyQt*

}

function install_venv()
{
	[[ -d $venv_dir ]] || {

    	echo ">>> Creating virtual environment..."
    	virtualenv --python=python2.7 $venv_dir
    	source "$venv_dir/bin/activate"
	    pip install -r "$project_path/requirements.txt"
	    deactivate

	} && {
	    echo ">>> Python Virtual environment found, skipping"
	}
}

script_path="$( cd "$( dirname "$0" )" && pwd )"
project_path=$( readlink -e "$script_path/.." )

linux_packages="$script_path/debian.packages"
venv_dir="$project_path/.venv"

if [ $1 == '-install' ];
then
	# Enable serial access
	currentUser=$(whoami)
	sudo usermod -a -G dialout $currentUser 

	# Install required packages
	sudo apt --assume-yes install build-essential 
	sudo apt --assume-yes install virtualenv
	sudo apt --assume-yes install python-qt4
	sudo apt --assume-yes install libqt4-dev 
	sudo apt --assume-yes install unzip
	sudo apt --assume-yes install python-pip
	sudo apt --assume-yes install python-dev
	sudo apt --assume-yes install libffi-dev
	sudo apt --assume-yes install libssl-dev
 	sudo apt --asumme-yes install libcanberra-gtk-module
 	sudo apt --assume-yes install shc
	sudo apt --assume-yes --force-yes install unzip

	# Create a virtualenv
	virtualenv $venv_path
	source "$venv_path/bin/activate"
	pip install -r "$project_path/requirements.txt"

	# Downloading packages for GUI
	# Needed to install SIP first
	cd $venv_path
{'fraction_non_alphanumeric': 0.12253313696612665, 'fraction_numerical': 0.016200294550810016, 'mean_word_length': 2.909614277489925, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3344677', 'n_tokens_mistral': 2407, 'n_tokens_neox': 2246, 'n_words': 672}