-
Notifications
You must be signed in to change notification settings - Fork 0
/
challenge.sh
executable file
·57 lines (48 loc) · 1.69 KB
/
challenge.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Initializes the environment and runs the code.
# Check if the data files are present otherwise download them
echo "Looking for data files..."
if [ ! -f listings.txt ] || [ ! -f products.txt ]; then
echo "Data files not found. Will attempt to download them..."
wget https://s3.amazonaws.com/sortable-public/challenge/challenge_data_20110429.tar.gz
tar -xvf challenge_data_20110429.tar.gz
rm challenge_data_20110429.tar.gz
echo "Data files downloaded successfully!"
fi
# Check if Pip is installed on the system
echo "Looking for the Pip Package Manager..."
if ! which pip 1> /dev/null; then
echo "Pip could not be found on the system. Will attempt to download it now..."
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
rm get-pip.py
echo "Pip installed successfully!"
fi
# Check if virtualenv is installed on the system
echo "Looking for the Virtualenv utility..."
if ! which virtualenv 1> /dev/null; then
echo "Virtualenv could not be found. Will attempt to install it..."
pip install virtualenv
echo "Virtualenv was installed successfully!"
fi
# Check if a virtual env exists otherwise create it
echo "Looking for a virtualenv named 'env'"
if [ ! -d env ]; then
echo "Virtualenv not found. Creating one..."
virtualenv -p /usr/bin/python2.7 env
echo "Virtualenv created successfully!"
fi
# Activate the env
source env/bin/activate
echo "Virtualenv activated!"
# Install the dependencies
echo "Running a dependency check..."
pip install -r requirements.txt
echo "All dependencies installed!"
echo "Running the main program..."
if [ $# -eq 0 ]; then
python challenge.py
else
python challenge-es.py "$@"
fi
echo "All done!"