mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
pyupgrade fixes
This commit is contained in:
@@ -72,7 +72,7 @@ def fix_permissions(prefix):
|
||||
Run after each install command.
|
||||
"""
|
||||
utils.run_subprocess(
|
||||
["chown", "-R", "{}:{}".format(os.getuid(), os.getgid()), prefix]
|
||||
["chown", "-R", f"{os.getuid()}:{os.getgid()}", prefix]
|
||||
)
|
||||
utils.run_subprocess(["chmod", "-R", "o-w", prefix])
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ def load_traefik_api_credentials():
|
||||
proxy_secret_path = os.path.join(STATE_DIR, 'traefik-api.secret')
|
||||
if not os.path.exists(proxy_secret_path):
|
||||
return {}
|
||||
with open(proxy_secret_path, 'r') as f:
|
||||
with open(proxy_secret_path) as f:
|
||||
password = f.read()
|
||||
return {
|
||||
'traefik_api': {
|
||||
|
||||
@@ -225,7 +225,7 @@ def ensure_admins(admin_password_list):
|
||||
logger.info("Setting up admin users")
|
||||
config_path = CONFIG_FILE
|
||||
if os.path.exists(config_path):
|
||||
with open(config_path, 'r') as f:
|
||||
with open(config_path) as f:
|
||||
config = yaml.load(f)
|
||||
else:
|
||||
config = {}
|
||||
@@ -261,7 +261,7 @@ def ensure_jupyterhub_running(times=20):
|
||||
|
||||
for i in range(times):
|
||||
try:
|
||||
logger.info('Waiting for JupyterHub to come up ({}/{} tries)'.format(i + 1, times))
|
||||
logger.info(f'Waiting for JupyterHub to come up ({i + 1}/{times} tries)')
|
||||
# Because we don't care at this level that SSL is valid, we can suppress
|
||||
# InsecureRequestWarning for this request.
|
||||
with warnings.catch_warnings():
|
||||
@@ -283,7 +283,7 @@ def ensure_jupyterhub_running(times=20):
|
||||
# Everything else should immediately abort
|
||||
raise
|
||||
|
||||
raise Exception("Installation failed: JupyterHub did not start in {}s".format(times))
|
||||
raise Exception(f"Installation failed: JupyterHub did not start in {times}s")
|
||||
|
||||
|
||||
def ensure_symlinks(prefix):
|
||||
@@ -388,7 +388,7 @@ def ensure_config_yaml(plugin_manager):
|
||||
migrator.migrate_config_files()
|
||||
|
||||
if os.path.exists(CONFIG_FILE):
|
||||
with open(CONFIG_FILE, 'r') as f:
|
||||
with open(CONFIG_FILE) as f:
|
||||
config = yaml.load(f)
|
||||
else:
|
||||
config = {}
|
||||
|
||||
@@ -69,7 +69,7 @@ def ensure_traefik_binary(prefix):
|
||||
# verify that we got what we expected
|
||||
checksum = checksum_file(traefik_bin)
|
||||
if checksum != checksums[plat]:
|
||||
raise IOError(f"Checksum failed {traefik_bin}: {checksum} != {checksums[plat]}")
|
||||
raise OSError(f"Checksum failed {traefik_bin}: {checksum} != {checksums[plat]}")
|
||||
|
||||
|
||||
def compute_basic_auth(username, password):
|
||||
|
||||
@@ -34,7 +34,7 @@ def ensure_user(username):
|
||||
subprocess.check_call([
|
||||
'chmod',
|
||||
'o-rwx',
|
||||
expanduser('~{username}'.format(username=username))
|
||||
expanduser(f'~{username}')
|
||||
])
|
||||
|
||||
pm = get_plugin_manager()
|
||||
|
||||
Reference in New Issue
Block a user