mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #1465 from hramezani/issue_1325
fix non-decimal values problem in `umask` config.(issue 1325)
This commit is contained in:
commit
2de1ea3561
@ -48,6 +48,13 @@ def make_settings(ignore=None):
|
||||
return settings
|
||||
|
||||
|
||||
def auto_int(_, x):
|
||||
if x.startswith('0') and not x.lower().startswith('0x'):
|
||||
# for compatible with octal numbers in python3
|
||||
x = x.replace('0', '0o', 1)
|
||||
return int(x, 0)
|
||||
|
||||
|
||||
class Config(object):
|
||||
|
||||
def __init__(self, usage=None, prog=None):
|
||||
@ -1027,14 +1034,13 @@ class Group(Setting):
|
||||
change the worker processes group.
|
||||
"""
|
||||
|
||||
|
||||
class Umask(Setting):
|
||||
name = "umask"
|
||||
section = "Server Mechanics"
|
||||
cli = ["-m", "--umask"]
|
||||
meta = "INT"
|
||||
validator = validate_pos_int
|
||||
type = int
|
||||
type = auto_int
|
||||
default = 0
|
||||
desc = """\
|
||||
A bit mask for the file mode on files written by Gunicorn.
|
||||
|
||||
@ -357,3 +357,16 @@ def test_reload(options, expected):
|
||||
with AltArgs(cmdline):
|
||||
app = NoConfigApp()
|
||||
assert app.cfg.reload == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("options, expected", [
|
||||
(["--umask 0", "myapp:app"], 0),
|
||||
(["--umask", "0xFF", "myapp:app"], 255),
|
||||
(["--umask", "0022", "myapp:app"], 18),
|
||||
])
|
||||
def test_umask_config(options, expected):
|
||||
cmdline = ["prog_name"]
|
||||
cmdline.extend(options)
|
||||
with AltArgs(cmdline):
|
||||
app = NoConfigApp()
|
||||
assert app.cfg.umask == expected
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user