Skip to content

Commit

Permalink
Fix env variables checks
Browse files Browse the repository at this point in the history
* update configuration file
  • Loading branch information
gek20 authored and JohannesLares committed Oct 25, 2022
1 parent 3c6ee27 commit 33aa074
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions b2share/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,12 @@
RECORDS_REST_DEFAULT_DELETE_PERMISSION_FACTORY = \
'b2share.modules.records.permissions:DeleteRecordPermission'

B2ACCESS_APP_CREDENTIALS = dict(
# B2ACCESS authentication key and secret
consumer_key=os.environ.get("B2ACCESS_CONSUMER_KEY"),
consumer_secret=os.environ.get("B2ACCESS_SECRET_KEY"),
)
if os.environ.get("B2ACCESS_CONSUMER_KEY") and os.environ.get("B2ACCESS_SECRET_KEY"):
B2ACCESS_APP_CREDENTIALS = dict(
# B2ACCESS authentication key and secret
consumer_key=os.environ.get("B2ACCESS_CONSUMER_KEY"),
consumer_secret=os.environ.get("B2ACCESS_SECRET_KEY"),
)


B2ACCESS_BASE_URL = 'https://b2access.eudat.eu/'
Expand Down
2 changes: 1 addition & 1 deletion b2share/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def check(var_name):
if not config.get(var_name):
error("Configuration variable expected: {}".format(var_name))

if not os.environ.get('B2SHARE_SECRET_KEY'):
if not os.environ.get('B2SHARE_SECRET_KEY') and check('B2SHARE_SECRET_KEY'):
error("Environment variable not defined: B2SHARE_SECRET_KEY")

check('SQLALCHEMY_DATABASE_URI')
Expand Down

0 comments on commit 33aa074

Please sign in to comment.