Skip to content

Commit 4f89da0

Browse files
authored
Merge pull request #209 from pvgenuchten/restore-bat-approach
restore .bat approach for windows cmd
2 parents 8d0c6ad + 7956264 commit 4f89da0

2 files changed

Lines changed: 84 additions & 1 deletion

File tree

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,19 @@ cd workshop
3434
./geopython-workshop-ctl.sh stop
3535
```
3636

37-
Windows (Powershell):
37+
Windows (Powershell or Command Prompt):
38+
39+
```bat
40+
cd workshop
41+
.\win-geopython-workshop-ctl.bat start
42+
.\win-geopython-workshop-ctl.bat url
43+
.\win-geopython-workshop-ctl.bat stop
44+
```
45+
46+
Windows (Powershell + bash):
3847

3948
```bash
49+
cd workshop
4050
# start workshop
4151
bash ./geopython-workshop-ctl.sh start
4252
# display URL and open in default web browser
@@ -45,6 +55,8 @@ bash ./geopython-workshop-ctl.sh url
4555
bash ./geopython-workshop-ctl.sh stop
4656
```
4757

58+
59+
4860
NB [Jupyter notebook](https://en.wikipedia.org/wiki/Project_Jupyter) needs a **token**. The token is displayed in the jupyter container logs on startup:
4961

5062
`http://127.0.0.1:8888/?token=<longtokenhexstring>`.

win-geopython-workshop-ctl.bat

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@ECHO OFF
2+
3+
SETLOCAL EnableDelayedExpansion
4+
5+
SET "PROGRAM_NAME=%~nx0"
6+
7+
SET "USAGE=Usage: %PROGRAM_NAME% ^<start^|stop^|url^|update^|clean^>"
8+
9+
IF "%1"=="" (
10+
ECHO %USAGE%
11+
ENDLOCAL
12+
EXIT /B 1
13+
)
14+
IF NOT "%2"=="" (
15+
ECHO %USAGE%
16+
ENDLOCAL
17+
EXIT /B 1
18+
)
19+
20+
REM Sniff which Docker Compose variant is installed
21+
REM and set an alias.
22+
REM See https://github.com/geopython/geopython-workshop/issues/82
23+
docker-compose --version >NUL
24+
IF !ERRORLEVEL! EQU 0 (
25+
SET DOCKERCOMPOSE=docker-compose
26+
ECHO Using docker-compose
27+
) ELSE (
28+
docker compose version >NUL
29+
IF !ERRORLEVEL! NEQ 0 (
30+
ECHO Neither docker-compose nor docker compose is available
31+
ECHO Check your Docker Installation
32+
ENDLOCAL
33+
EXIT /B 1
34+
)
35+
SET "DOCKERCOMPOSE=docker compose"
36+
ECHO Using docker compose
37+
)
38+
39+
REM Test for the command
40+
IF /I "%1"=="start" (
41+
%PROGRAM_NAME% stop
42+
%DOCKERCOMPOSE% up -d
43+
) ELSE ( IF /I "%1"=="stop" (
44+
%DOCKERCOMPOSE% stop
45+
%DOCKERCOMPOSE% rm --force
46+
) ELSE ( IF /I "%1"=="url" (
47+
REM try to open the Jupyter Notebook in Browser
48+
REM Filter the URL from the log output
49+
powershell -Command "try { $url = (docker logs geopython-workshop-jupyter 2>&1 | Select-String -Pattern 'http://127\.0\.0\.1\S+token\S+')[-1].Matches[0].Value; Write-Output ('Attempting to open ' + $url + ' in your browser on platform Windows...') 'If this fails, simply copy/paste that URL in your browser'; start $url } catch { exit 2 }"
50+
IF !ERRORLEVEL! NEQ 0 (
51+
ECHO workshop not started
52+
ECHO did you start the workshop? (i.e. %PROGRAM_NAME% start^)
53+
ENDLOCAL
54+
EXIT /B 2
55+
)
56+
) ELSE ( IF /I "%1"=="update" (
57+
docker pull geopython/geopython-workshop:latest
58+
ECHO:
59+
ECHO:
60+
ECHO workshop is running the latest Docker images
61+
ECHO If updates occured, then stop/start the workshop
62+
) ELSE ( IF /I "%1"=="clean" (
63+
REM Remove all exited containers
64+
FOR /F %%c IN ('docker ps -a -f status^=exited -q') DO docker rm %%c
65+
REM And dangling images
66+
FOR /F %%i IN ('docker images -f dangling^=true -q') DO docker rmi %%i
67+
) ELSE (
68+
ECHO %USAGE%
69+
) ) ) ) )
70+
71+
ENDLOCAL

0 commit comments

Comments
 (0)