Skip to content

Commit

Permalink
Fix duplicate error raises in dbAuth, remove extraneous re-raise in c…
Browse files Browse the repository at this point in the history
…onnection string and fix type in registryConf2.yaml.
  • Loading branch information
DinoBektesevic committed Apr 30, 2020
1 parent 0abcba3 commit 970f92a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
4 changes: 1 addition & 3 deletions python/lsst/daf/butler/registry/_dbAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,14 @@ def __init__(self, path=None, envVar=None, authList=None):
else:
secretPath = os.path.expanduser(path)
if not os.path.isfile(secretPath):
raise DbAuthError("No DbAuth configuration file: " + secretPath)
raise DbAuthNotFoundError(f"No DbAuth configuration file: {secretPath}")
mode = os.stat(secretPath).st_mode
if mode & (stat.S_IRWXG | stat.S_IRWXO) != 0:
raise DbAuthPermissionsError(
"DbAuth configuration file {} has incorrect permissions: "
"{:o}".format(secretPath, mode))

try:
if not os.path.isfile(secretPath):
raise DbAuthNotFoundError(f"DbAuth file not found: {secretPath}")
with open(secretPath) as secretFile:
self.authList = yaml.safe_load(secretFile)
except Exception as exc:
Expand Down
3 changes: 0 additions & 3 deletions python/lsst/daf/butler/registry/connectionString.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ def fromConfig(cls, registryConfig):
except DbAuthNotFoundError:
# credentials file doesn't exist or no matches were found
pass
except Exception:
# re-raise everything else
raise
else:
# only assign auth when *no* errors were raised, otherwise assume
# connection string was correct
Expand Down
2 changes: 1 addition & 1 deletion tests/config/dbAuth/registryConf2.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# minimal configuration required when using explicit 'host-port',
# also tests '/' are placed correctly when not epxlicit in dbname
# also tests '/' are placed correctly when not explicit in dbname
registry:
db: 'postgresql://host.example.com'
port: 5432
Expand Down

0 comments on commit 970f92a

Please sign in to comment.