diff --git a/tools/lib/provision.py b/tools/lib/provision.py index ae6a088b3a..d37f325c9a 100755 --- a/tools/lib/provision.py +++ b/tools/lib/provision.py @@ -249,8 +249,7 @@ def main(options): # issue with the symlinks being improperly owned by root. if os.path.islink("node_modules"): run(["sudo", "rm", "-f", "node_modules"]) - if not os.path.isdir(NODE_MODULES_CACHE_PATH): - run(["sudo", "mkdir", NODE_MODULES_CACHE_PATH]) + run(["sudo", "mkdir", "-p", NODE_MODULES_CACHE_PATH]) run(["sudo", "chown", "%s:%s" % (user_id, user_id), NODE_MODULES_CACHE_PATH]) setup_node_modules(prefer_offline=True) except subprocess.CalledProcessError: diff --git a/tools/setup/generate_zulip_bots_static_files b/tools/setup/generate_zulip_bots_static_files index 5c3a2b2624..f5ff16bf8d 100755 --- a/tools/setup/generate_zulip_bots_static_files +++ b/tools/setup/generate_zulip_bots_static_files @@ -15,8 +15,7 @@ from zulip_bots.lib import get_bots_directory_path bots_dir = os.path.join(settings.STATIC_ROOT, 'generated/bots') -if not os.path.isdir(bots_dir): - os.makedirs(bots_dir) +os.makedirs(bots_dir, exist_ok=True) def copyfiles(paths): # type: (List[Text]) -> None @@ -24,8 +23,7 @@ def copyfiles(paths): bot_name = os.path.basename(os.path.dirname(src_path)) bot_dir = os.path.join(bots_dir, bot_name) - if not os.path.isdir(bot_dir): - os.mkdir(bot_dir) + os.makedirs(bot_dir, exist_ok=True) dst_path = os.path.join(bot_dir, os.path.basename(src_path)) if not os.path.isfile(dst_path): diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index b08d5921e3..37fde85d71 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -427,8 +427,7 @@ class S3UploadBackend(ZulipUploadBackend): def mkdirs(path): # type: (Text) -> None dirname = os.path.dirname(path) - if not os.path.isdir(dirname): - os.makedirs(dirname) + os.makedirs(dirname, exist_ok=True) def write_local_file(type, path, file_data): # type: (Text, Text, bytes) -> None