Another bit

This commit is contained in:
Marcel Otte 2019-02-24 22:42:36 +01:00
parent fd52f70015
commit 8d3be057a8
4 changed files with 48 additions and 4 deletions

View File

@ -3,3 +3,15 @@
""" """
Service startup script. Service startup script.
""" """
class Backive:
def __init__(self):
pass
def serve(self):
pass
if __name__ == "__main__":
backive = Backive()
backive.serve()

View File

@ -3,3 +3,13 @@
""" """
Callable script for udev rules. Callable script for udev rules.
""" """
import socket
import sys
unix_socket = "/tmp/backive/backive.sock"
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(unix_socket)
if len(sys.argv) > 1:
sock.send(sys.argv[1].encode())
sock.close()

View File

@ -2,11 +2,9 @@ import os
class Backup: class Backup:
config = {}
def __init__(self, name, cfg=None): def __init__(self, name, cfg=None):
pass self.name = name
self.config = cfg
def run(self): def run(self):
pass pass

24
backive/core/events.py Normal file
View File

@ -0,0 +1,24 @@
import os
import socket
class EventInterface:
def __init__(self, unix_socket=None):
if not unix_socket:
unix_socket = "/tmp/backive/backive.sock"
self.socket = socket.socket(
socket.AF_UNIX,
socket.SOCK_STREAM
)
try:
os.remove(unix_socket)
except OSError:
pass
self.socket.bind(unix_socket)
self.socket.listen()
def accept(self):
return self.socket.accept()