def enable_sv(sv, sv_dir, runsvdir):
"""
Enable the specified service, 'sv'.
Assemble 'sv_path' and 'service_path' from 'sv', 'sv_dir', and 'runsvdir'.
Make a symlink from 'sv_path' to 'service_path' and bail if we get one
of a couple different exceptions.
"""
sv_path = os.path.join(sv_dir, sv)
service_path = os.path.join(runsvdir, sv)
try:
check_sv_path(sv_path)
os.symlink(sv_path, service_path)
return True
except NoSuchSvError:
raise NoSuchSvError
except PermissionError:
raise NeedSudoError
except FileExistsError:
raise SvAlreadyEnabledError
评论列表
文章目录