api: ensure parent of socket dir exists
When creating the socket directory, i.e. in the case that it was not specified directly, ensure the parent directories exist. Make it possible to override that parent directory.
This commit is contained in:
parent
ea3dad17fc
commit
35149c6aec
1 changed files with 3 additions and 2 deletions
|
|
@ -64,9 +64,10 @@ class BaseAPI(abc.ABC):
|
|||
"""Called after the event loop is shut down"""
|
||||
|
||||
@classmethod
|
||||
def _make_socket_dir(cls):
|
||||
def _make_socket_dir(cls, rundir: PathLike = "/run/osbuild"):
|
||||
"""Called to create the temporary socket dir"""
|
||||
return tempfile.TemporaryDirectory(prefix="api-", dir="/run/osbuild")
|
||||
os.makedirs(rundir, exist_ok=True)
|
||||
return tempfile.TemporaryDirectory(prefix="api-", dir=rundir)
|
||||
|
||||
def _dispatch(self, sock: jsoncomm.Socket):
|
||||
"""Called when data is available on the socket"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue