Skip to content

Commit 4104b30

Browse files
committed
feat: having the possibility to define a custom path for .sdichecker
1 parent 3276478 commit 4104b30

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ optional arguments:
2525
space-separated list of geoserver hostname to check in
2626
CSW mode with inspire strict option activated. Ex:
2727
sdi.georchestra.org
28-
--check-layers check WMS/WFS layer validity by performing sample WMS
28+
--check-layers check WMS/WFS layer validity by performing sample WMS
2929
GetMap or WFS GetFeature requests
3030
--disable-ssl-verification
3131
Disable certificate verification
@@ -60,7 +60,9 @@ python3 checker.py --mode WMS --server https://www.geopicardie.fr/geoserver/wms
6060
```
6161

6262

63-
In case a private service is to be checked, you should first create a `.sdichecker` in your home directory, with the following format:
63+
In case a private service is to be checked, you should first create a `.sdichecker`
64+
in your home directory, or define a `SDICHECKER_CREDS_PATH` environment variable,
65+
pointing to a file having the following format:
6466
```
6567
<hostname> <username> <password>
6668
```

sdi-consistence-check/credentials.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ def __init__(self, logger=None):
88
Loads the credentials file, which consists of a text file
99
formatted with "hostname username password" and whose default location is set to
1010
~/.sdichecker.
11+
12+
The file path can also be defined using the SDICHECKER_CREDS_PATH environment variable.
1113
"""
1214
self._credentials = {}
1315

1416
try:
15-
with open(os.getenv("HOME") + "/.sdichecker") as file:
17+
pwfile = os.getenv("SDICHECKER_CREDS_PATH") or os.getenv("HOME") + "/.sdichecker"
18+
with open(pwfile) as file:
1619
for line in file:
1720
try:
1821
(hostname, user, password) = line.rstrip("\n").split(" ", 3)
@@ -21,7 +24,7 @@ def __init__(self, logger=None):
2124
pass
2225
except FileNotFoundError:
2326
if logger is not None:
24-
logger.info("No ~/.sdichecker file found, skipping credentials definition.")
27+
logger.info("No sdichecker credentials file found, skipping credentials definition.")
2528
pass
2629

2730
def add(self, site, username, password):
@@ -39,4 +42,4 @@ def get(self, site):
3942

4043
def getFromUrl(self, url):
4144
u = urlparse(url)
42-
return self.get(u.hostname)
45+
return self.get(u.hostname)

0 commit comments

Comments
 (0)