dist/common/scripts: drop makedirs(), use os.makedirs()

Since os.makedirs() has exist_ok option, no need to create wrapper function.
This commit is contained in:
Takuya ASADA
2020-09-20 00:48:04 +09:00
parent 85f76e80b4
commit 8e1f7d4fc7
3 changed files with 4 additions and 9 deletions

View File

@@ -75,7 +75,7 @@ WantedBy=multi-user.target
'''[1:-1]
with open('/etc/systemd/system/var-lib-systemd-coredump.mount', 'w') as f:
f.write(dot_mount)
makedirs('/var/lib/scylla/coredump')
os.makedirs('/var/lib/scylla/coredump', exist_ok=True)
systemd_unit.reload()
systemd_unit('var-lib-systemd-coredump.mount').enable()
systemd_unit('var-lib-systemd-coredump.mount').start()

View File

@@ -138,7 +138,7 @@ if __name__ == '__main__':
f.write(res)
f.write('\nMAILADDR root')
makedirs(mount_at)
os.makedirs(mount_at, exist_ok=True)
uuid = out(f'blkid -s UUID -o value {fsdev}')
after = 'local-fs.target'
@@ -163,7 +163,7 @@ WantedBy=multi-user.target
f.write(unit_data)
mounts_conf = '/etc/systemd/system/scylla-server.service.d/mounts.conf'
if not os.path.exists(mounts_conf):
makedirs('/etc/systemd/system/scylla-server.service.d/')
os.makedirs('/etc/systemd/system/scylla-server.service.d/', exist_ok=True)
with open(mounts_conf, 'w') as f:
f.write(f'[Unit]\nRequiresMountsFor={mount_at}\n')
else:
@@ -183,7 +183,7 @@ WantedBy=multi-user.target
for d in ['coredump', 'data', 'commitlog', 'hints', 'view_hints', 'saved_caches']:
dpath = '{}/{}'.format(root, d)
makedirs(dpath)
os.makedirs(dpath, exist_ok=True)
os.chown(dpath, uid, gid)
if is_debian_variant():

View File

@@ -582,11 +582,6 @@ def hex2list(hex_str):
return ",".join(cpu_list)
def makedirs(name):
if not os.path.isdir(name):
os.makedirs(name)
def rmtree(path):
if not os.path.islink(path):
shutil.rmtree(path)