def send(self, data): Logger.debug("Sending '" + str(data) + "' to " + self.host + ":" + str(self.port)) if isinstance(data, bytes): self.socket.sendall(data) else: self.socket.sendall(bytes(data, self.charset))
def login(self, username, password): if username is None and password is None: Logger.debug("Loging into FTP Server with anonymous account") Logger.debug(self.ftp_client.login()) else: Logger.debug("Loging into FTP Server with " + username) Logger.debug(self.ftp_client.login(username, password))
def read(self, convert_to_str=True): Logger.debug("Reading socket from " + self.host + ":" + str(self.port)) buffer_len = 4096 if self.type == socket.SOCK_DGRAM: buffer_len = 65535 buffer = self.socket.recv(buffer_len) if len(buffer) > 0: if convert_to_str: return buffer.decode(self.charset) else: return buffer else: return ""
def read(self, convert_to_str=True): Logger.debug("Reading socket from " + self.host + ":" + str(self.port)) buffer_len = 4096 if self.type == socket.SOCK_DGRAM: buffer_len = 65535 while True: print("a") connection, address = self.socket.accept() buffer = connection.recv(buffer_len) if len(buffer) > 0: if convert_to_str: return buffer.decode(self.charset) else: return buffer else: return ""
def connect(self): Logger.debug("Connecting socket to " + self.host + ":" + str(self.port)) self.socket.connect((self.host, self.port)) Logger.debug("Successfully connected to " + self.host + ":" + str(self.port))
def listen(self): Logger.debug("Starting to listen on " + self.host + ":" + str(self.port)) self.socket.listen() Logger.debug("Successfully started to listen on " + self.host + ":" + str(self.port))