Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
klaus
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
jonashaag
klaus
Commits
f133f0c8
Commit
f133f0c8
authored
8 years ago
by
Jimmy Petersson
Browse files
Options
Downloads
Patches
Plain Diff
Use strtobool to parse boolean env variables
parent
cac17605
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
klaus/contrib/app_args.py
+7
-4
7 additions, 4 deletions
klaus/contrib/app_args.py
tests/test_contrib.py
+14
-4
14 additions, 4 deletions
tests/test_contrib.py
with
21 additions
and
8 deletions
klaus/contrib/app_args.py
+
7
−
4
View file @
f133f0c8
import
os
import
os
from
distutils.util
import
strtobool
def
get_args_from_env
():
def
get_args_from_env
():
...
@@ -11,10 +12,12 @@ def get_args_from_env():
...
@@ -11,10 +12,12 @@ def get_args_from_env():
)
)
kwargs
=
dict
(
kwargs
=
dict
(
htdigest_file
=
os
.
environ
.
get
(
'
KLAUS_HTDIGEST_FILE
'
),
htdigest_file
=
os
.
environ
.
get
(
'
KLAUS_HTDIGEST_FILE
'
),
use_smarthttp
=
bool
(
os
.
environ
.
get
(
'
KLAUS_USE_SMARTHTTP
'
)),
use_smarthttp
=
strtobool
(
os
.
environ
.
get
(
'
KLAUS_USE_SMARTHTTP
'
,
'
0
'
)),
require_browser_auth
=
bool
(
os
.
environ
.
get
(
'
KLAUS_REQUIRE_BROWSER_AUTH
'
)),
require_browser_auth
=
strtobool
(
disable_push
=
bool
(
os
.
environ
.
get
(
'
KLAUS_DISABLE_PUSH
'
)),
os
.
environ
.
get
(
'
KLAUS_REQUIRE_BROWSER_AUTH
'
,
'
0
'
)),
unauthenticated_push
=
bool
(
os
.
environ
.
get
(
'
KLAUS_UNAUTHENTICATED_PUSH
'
)),
disable_push
=
strtobool
(
os
.
environ
.
get
(
'
KLAUS_DISABLE_PUSH
'
,
'
0
'
)),
unauthenticated_push
=
strtobool
(
os
.
environ
.
get
(
'
KLAUS_UNAUTHENTICATED_PUSH
'
,
'
0
'
)),
ctags_policy
=
os
.
environ
.
get
(
'
KLAUS_CTAGS_POLICY
'
,
'
none
'
)
ctags_policy
=
os
.
environ
.
get
(
'
KLAUS_CTAGS_POLICY
'
,
'
none
'
)
)
)
return
args
,
kwargs
return
args
,
kwargs
This diff is collapsed.
Click to expand it.
tests/test_contrib.py
+
14
−
4
View file @
f133f0c8
...
@@ -49,8 +49,8 @@ def test_app_args_from_env():
...
@@ -49,8 +49,8 @@ def test_app_args_from_env():
'
KLAUS_HTDIGEST_FILE
'
:
HTDIGEST_FILE
,
'
KLAUS_HTDIGEST_FILE
'
:
HTDIGEST_FILE
,
'
KLAUS_USE_SMARTHTTP
'
:
'
yes
'
,
'
KLAUS_USE_SMARTHTTP
'
:
'
yes
'
,
'
KLAUS_REQUIRE_BROWSER_AUTH
'
:
'
1
'
,
'
KLAUS_REQUIRE_BROWSER_AUTH
'
:
'
1
'
,
'
KLAUS_DISABLE_PUSH
'
:
'
false
'
,
# TODO?
'
KLAUS_DISABLE_PUSH
'
:
'
false
'
,
'
KLAUS_UNAUTHENTICATED_PUSH
'
:
'
0
'
,
# TODO?
'
KLAUS_UNAUTHENTICATED_PUSH
'
:
'
0
'
,
'
KLAUS_CTAGS_POLICY
'
:
'
ALL
'
'
KLAUS_CTAGS_POLICY
'
:
'
ALL
'
},
},
([
TEST_REPO
],
TEST_SITE_NAME
),
([
TEST_REPO
],
TEST_SITE_NAME
),
...
@@ -58,11 +58,21 @@ def test_app_args_from_env():
...
@@ -58,11 +58,21 @@ def test_app_args_from_env():
htdigest_file
=
HTDIGEST_FILE
,
htdigest_file
=
HTDIGEST_FILE
,
use_smarthttp
=
True
,
use_smarthttp
=
True
,
require_browser_auth
=
True
,
require_browser_auth
=
True
,
disable_push
=
Tru
e
,
disable_push
=
Fals
e
,
unauthenticated_push
=
Tru
e
,
unauthenticated_push
=
Fals
e
,
ctags_policy
=
'
ALL
'
)
ctags_policy
=
'
ALL
'
)
)
)
with
pytest
.
raises
(
ValueError
):
check_env
(
{
'
KLAUS_REPOS
'
:
TEST_REPO
,
'
KLAUS_SITE_NAME
'
:
TEST_SITE_NAME
,
'
KLAUS_HTDIGEST_FILE
'
:
HTDIGEST_FILE
,
'
KLAUS_USE_SMARTHTTP
'
:
'
unsupported
'
,
},
(),
{}
)
def
test_wsgi
():
def
test_wsgi
():
clear_env
()
clear_env
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment