def __check_setup(self): """ Auxiliary stuff that needs to be checked per run. Is there a database? Are the config files there? """ if not Config.is_first_setup(): self._db = sqlite3.connect(Config.db_path()) return Config.bootstrap() self._db = sqlite3.connect(Config.db_path()) Bookmark.create_table(self.db)
def execute(self): message = '|'.join(['del', str(book.identification), Config.load_key()]) host = Host() socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) socket.sendto(message.encode(), (host.address(), host.port())) response = socket.recv(1024).decode() self.__handle_resp(response)
def execute(self): host = Host() message = '|'.join(["auth", self._user.name, self._user.password]) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.sendto(message.encode(), (host.address, host.port)) # Response print("authentication ... ", end='', flush=True) resp = sock.recv(1024).decode() token = resp.split('|')[1] if token == "fail": print("fail") else: print("success") Config.store_key(token)
def execute(self): message = '|'.join( ['del', str(book.identification), Config.load_key()]) host = Host() socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) socket.sendto(message.encode(), (host.address(), host.port())) response = socket.recv(1024).decode() self.__handle_resp(response)
def execute(self): bm = self._bookmark token = Config.load_key() host = Host() bmdata = ['ins'] bmdata += [bm.name, bm.title] bmdata += [str(bm.volume), str(bm.chapter), str(bm.page)] bmdata += [token] message = '|'.join(bmdata) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.sendto(message.encode(), (host.address, host.port)) resp = sock.recv(1024).decode() self._handle_response(resp)