mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-24 02:37:05 +00:00
Fixed SIM108 (if-else-block-instead-of-if-exp)
This commit is contained in:
parent
51dc7615f7
commit
fba92de051
@ -93,10 +93,7 @@ elif sys.argv[1] == "user" and len(sys.argv) == 2:
|
|||||||
|
|
||||||
elif sys.argv[1] == "user" and sys.argv[2] in {"add", "password"}:
|
elif sys.argv[1] == "user" and sys.argv[2] in {"add", "password"}:
|
||||||
if len(sys.argv) < 5:
|
if len(sys.argv) < 5:
|
||||||
if len(sys.argv) < 4:
|
email = input('email: ') if len(sys.argv) < 4 else sys.argv[3]
|
||||||
email = input("email: ")
|
|
||||||
else:
|
|
||||||
email = sys.argv[3]
|
|
||||||
pw = read_password()
|
pw = read_password()
|
||||||
else:
|
else:
|
||||||
email, pw = sys.argv[3:5]
|
email, pw = sys.argv[3:5]
|
||||||
@ -110,10 +107,7 @@ elif sys.argv[1] == "user" and sys.argv[2] == "remove" and len(sys.argv) == 4:
|
|||||||
print(mgmt("/mail/users/remove", { "email": sys.argv[3] }))
|
print(mgmt("/mail/users/remove", { "email": sys.argv[3] }))
|
||||||
|
|
||||||
elif sys.argv[1] == "user" and sys.argv[2] in {"make-admin", "remove-admin"} and len(sys.argv) == 4:
|
elif sys.argv[1] == "user" and sys.argv[2] in {"make-admin", "remove-admin"} and len(sys.argv) == 4:
|
||||||
if sys.argv[2] == "make-admin":
|
action = 'add' if sys.argv[2] == 'make-admin' else 'remove'
|
||||||
action = "add"
|
|
||||||
else:
|
|
||||||
action = "remove"
|
|
||||||
print(mgmt("/mail/users/privileges/" + action, { "email": sys.argv[3], "privilege": "admin" }))
|
print(mgmt("/mail/users/privileges/" + action, { "email": sys.argv[3], "privilege": "admin" }))
|
||||||
|
|
||||||
elif sys.argv[1] == "user" and sys.argv[2] == "admins":
|
elif sys.argv[1] == "user" and sys.argv[2] == "admins":
|
||||||
|
@ -751,10 +751,7 @@ def log_failed_login(request):
|
|||||||
# During setup we call the management interface directly to determine the user
|
# During setup we call the management interface directly to determine the user
|
||||||
# status. So we can't always use X-Forwarded-For because during setup that header
|
# status. So we can't always use X-Forwarded-For because during setup that header
|
||||||
# will not be present.
|
# will not be present.
|
||||||
if request.headers.getlist("X-Forwarded-For"):
|
ip = request.headers.getlist("X-Forwarded-For")[0] if request.headers.getlist("X-Forwarded-For") else request.remote_addr
|
||||||
ip = request.headers.getlist("X-Forwarded-For")[0]
|
|
||||||
else:
|
|
||||||
ip = request.remote_addr
|
|
||||||
|
|
||||||
# We need to add a timestamp to the log message, otherwise /dev/log will eat the "duplicate"
|
# We need to add a timestamp to the log message, otherwise /dev/log will eat the "duplicate"
|
||||||
# message.
|
# message.
|
||||||
|
@ -861,10 +861,7 @@ def filter_custom_records(domain, custom_dns_iter):
|
|||||||
# our short form (None => domain, or a relative QNAME) if
|
# our short form (None => domain, or a relative QNAME) if
|
||||||
# domain is not None.
|
# domain is not None.
|
||||||
if domain is not None:
|
if domain is not None:
|
||||||
if qname == domain:
|
qname = None if qname == domain else qname[0:len(qname) - len("." + domain)]
|
||||||
qname = None
|
|
||||||
else:
|
|
||||||
qname = qname[0:len(qname)-len("." + domain)]
|
|
||||||
|
|
||||||
yield (qname, rtype, value)
|
yield (qname, rtype, value)
|
||||||
|
|
||||||
@ -1094,10 +1091,7 @@ def build_recommended_dns(env):
|
|||||||
|
|
||||||
# expand qnames
|
# expand qnames
|
||||||
for i in range(len(records)):
|
for i in range(len(records)):
|
||||||
if records[i][0] == None:
|
qname = domain if records[i][0] == None else records[i][0] + "." + domain
|
||||||
qname = domain
|
|
||||||
else:
|
|
||||||
qname = records[i][0] + "." + domain
|
|
||||||
|
|
||||||
records[i] = {
|
records[i] = {
|
||||||
"qname": qname,
|
"qname": qname,
|
||||||
|
@ -476,10 +476,7 @@ def add_mail_alias(address, forwards_to, permitted_senders, env, update_if_exist
|
|||||||
|
|
||||||
forwards_to = ",".join(validated_forwards_to)
|
forwards_to = ",".join(validated_forwards_to)
|
||||||
|
|
||||||
if len(validated_permitted_senders) == 0:
|
permitted_senders = None if len(validated_permitted_senders) == 0 else ",".join(validated_permitted_senders)
|
||||||
permitted_senders = None
|
|
||||||
else:
|
|
||||||
permitted_senders = ",".join(validated_permitted_senders)
|
|
||||||
|
|
||||||
conn, c = open_database(env, with_connection=True)
|
conn, c = open_database(env, with_connection=True)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user