forked from 07sumit1002/CabRental
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DBSetup.ps1
72 lines (56 loc) · 1.41 KB
/
DBSetup.ps1
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
58
59
60
61
62
63
64
65
66
67
68
69
70
# Check if python/python3 is installed
if (!(Get-Command python3 -ErrorAction SilentlyContinue)) {
Write-Host "Python3 is not installed."
exit 1
}
else {
if (!(python --version 2>&1 | Out-Null)) {
python3 --version
}
else {
python --version
}
}
# Check if pip/pip3 is installed
$pipInstalled = $false
$pip3Installed = $false
if (Get-Command pip -ErrorAction SilentlyContinue) {
pip --version
$pipInstalled = $true
Write-Host ""
}
else {
$pipInstalled = $false
}
if (Get-Command pip3 -ErrorAction SilentlyContinue) {
pip3 --version
$pip3Installed = $true
Write-Host ""
}
else {
$pip3Installed = $false
}
if (!($pipInstalled -or $pip3Installed)) {
Write-Host "Neither pip nor pip3 is installed. Please install pip or pip3." -ForegroundColor Red
exit 1
}
# Move to Setup Directory
Set-Location -Path .\DBSetup
# Install modules using pip
if (pip install -r .\requirements.txt) {
Write-Host "`nRequired Modules Installed Success Fully...`n" -ForegroundColor Green
sleep 2
}
else {
Write-Host "`nFailed to install modules.`n" -ForegroundColor Red
sleep 2
}
# Try running python script
& python ./setup.py
if ($LASTEXITCODE -eq 0) {
Write-Host "Setup Script Successfully Exited with 0 errors.`n" -ForegroundColor Green
} else {
Write-Host "Python script failed." -ForegroundColor Red
}
Set-Location -Path ..
sleep 3