Skip to content
Snippets Groups Projects
Commit eb49730a authored by Swen Vermeul's avatar Swen Vermeul
Browse files

feat: implement openbis_token as either string or file

parent aebaf0dd
No related branches found
No related tags found
2 merge requests!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...,!14feat: look in all parent dirs for local configs, get_token_for_hostname,...
......@@ -135,8 +135,7 @@ class ConfigEnv(object):
self.rules.append(rule)
def initialize_rules(self):
# self.add_rule(TokenRule())
pass
self.add_rule(TokenRule())
class CollectionEnv(ConfigEnv):
......@@ -420,3 +419,18 @@ class ClearIdentifierRule(SettingRule):
def on_set(self, config_resolver, name, value, loc):
if name == "permId":
config_resolver.set_value_for_parameter("id", None, loc)
class TokenRule(SettingRule):
""" When the user sets a token, check whether it is a file."""
def on_set(self, config_resolver, name, value, loc):
token = ""
tokenpath = Path(value).expanduser()
if tokenpath.exists():
with open(tokenpath, "r") as fh:
token = fh.read()
else:
token = value
config_resolver.set_value_for_parameter("openbis_token", token, loc)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment