Use a more concise `mkdir -p` when the situation permits.

This commit is contained in:
rht 2017-11-12 11:28:23 +01:00 committed by Tim Abbott
parent a86968cd44
commit 72ce1c6501
3 changed files with 4 additions and 8 deletions

View File

@ -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:

View File

@ -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):

View File

@ -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