mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-01-23 12:37:05 +00:00
Fixed TRY300 (try-consider-else): Consider moving this statement to an else
block
This commit is contained in:
parent
9d9e900ca2
commit
77a7a29322
@ -380,11 +380,12 @@ def dns_set_record(qname, rtype="A"):
|
||||
|
||||
if set_custom_dns_record(qname, rtype, value, action, env):
|
||||
return do_dns_update(env) or "Something isn't right."
|
||||
return "OK"
|
||||
|
||||
except ValueError as e:
|
||||
return (str(e), 400)
|
||||
|
||||
return "OK"
|
||||
|
||||
@app.route('/dns/dump')
|
||||
@authorized_personnel_only
|
||||
def dns_get_dump():
|
||||
|
@ -105,12 +105,12 @@ def check_service(i, service, env):
|
||||
s.settimeout(1)
|
||||
try:
|
||||
s.connect((ip, service["port"]))
|
||||
return True
|
||||
except OSError:
|
||||
# timed out or some other odd error
|
||||
return False
|
||||
finally:
|
||||
s.close()
|
||||
return True
|
||||
|
||||
if service["public"]:
|
||||
# Service should be publicly accessible.
|
||||
|
@ -39,9 +39,9 @@ def load_settings(env):
|
||||
with open(fn, encoding="utf-8") as f:
|
||||
config = rtyaml.load(f)
|
||||
if not isinstance(config, dict): raise ValueError # caught below
|
||||
return config
|
||||
except:
|
||||
return { }
|
||||
return config
|
||||
|
||||
# UTILITIES
|
||||
|
||||
@ -172,10 +172,11 @@ def wait_for_service(port, public, env, timeout):
|
||||
s.settimeout(timeout/3)
|
||||
try:
|
||||
s.connect(("127.0.0.1" if not public else env['PUBLIC_IP'], port))
|
||||
return True
|
||||
except OSError:
|
||||
if time.perf_counter() > start+timeout:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
time.sleep(min(timeout/4, 1))
|
||||
|
||||
def get_ssh_port():
|
||||
|
Loading…
Reference in New Issue
Block a user