baseimage-tutorial-framework/tfw/components/pipe_io/pipe_io_server/pipe.py

19 lines
398 B
Python
Raw Normal View History

2019-05-02 12:53:59 +00:00
from os import mkfifo, remove, chmod
from os.path import exists
2019-07-29 16:31:01 +00:00
DEFAULT_PERMISSIONS = 0o600
2019-05-02 12:53:59 +00:00
class Pipe:
def __init__(self, path):
self.path = path
def recreate(self, permissions):
self.remove()
mkfifo(self.path)
chmod(self.path, permissions) # use chmod to ignore umask
def remove(self):
if exists(self.path):
remove(self.path)