forked from omkarcloud/google-maps-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy-search-gmaps.sh
56 lines (46 loc) · 1.29 KB
/
py-search-gmaps.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
#!/bin/bash
INTERNET_CHECK_URL="http://www.google.com"
VENV_FOLDER="venv"
MAIN_SCRIPT="main.py"
REQUIREMENTS_FILE="requirements.txt"
# Check for the operating system
if [[ "$OSTYPE" == "linux-gnu" ]]; then
OS="Linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macOS"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
OS="Windows"
else
OS="Unknown"
fi
echo "Operating System: $OS"
# Check if Python 3 is installed
if command -v python3 &> /dev/null; then
echo "Python 3 is installed"
else
echo "Python 3 is not installed. Please install Python 3."
exit 1
fi
# Check for an internet connection
if curl --output /dev/null --silent --head --fail "$INTERNET_CHECK_URL"; then
echo "Internet connection detected"
else
echo "No internet connection. Please connect to the internet."
exit 1
fi
# Check if venv folder exists
if [ ! -d "$VENV_FOLDER" ]; then
# If not, create a virtual environment
python3 -m venv $VENV_FOLDER
fi
# Activate virtual environment
source $VENV_FOLDER/bin/activate
# Install dependencies if needed
if [ -f "$REQUIREMENTS_FILE" ]; then
# If requirements.txt exists, install dependencies
pip install -r $REQUIREMENTS_FILE
fi
# Run main.py
python $MAIN_SCRIPT
# Deactivate virtual environment after running main.py
deactivate