def get_ftp(depot_type=depot_type): """ Returns FTP client generator targeted to the depot machine. Usage: with depot_ftp() as ftp: ftp.recursively_delete() # And so on ... """ # Condition to check if it anonymous ftp or not, use default anonymous user if depot_type == "anon_ftp": ftp_user_name = "anonymous" ftp_password = "" # case anonymous connection cfme works only with hardcoded "incoming" directory # incoming folder used for https://bugzilla.redhat.com/show_bug.cgi?id=1307019 upload_dir = "incoming" ftp_host_name = hostname else: ftp_user_name = ftp_credentials["username"] ftp_password = ftp_credentials["password"] # if it's not anonymous using predefined credentials upload_dir = "/" ftp_host_name = ftp_credentials["hostname"] return FTPClient(ftp_host_name, ftp_user_name, ftp_password, upload_dir)
def ftp_client(): hostname = "localhost" username = "******" password = "******" ftp = FTPClient(hostname, username, password) return ftp
def get_ftp(): """ Returns FTP client generator targeted to the depot machine. Usage: with depot_ftp() as ftp: ftp.recursively_delete() # And so on ... """ return FTPClient(ftp_credentials["hostname"], ftp_credentials["username"], ftp_credentials["password"])
def ftp(self): if self.protocol == "anon_ftp": ftp_user_name = "anonymous" ftp_password = "" # case anonymous connection cfme works only with hardcoded "incoming" directory # incoming folder used for https://bugzilla.redhat.com/show_bug.cgi?id=1307019 upload_dir = "incoming" else: ftp_user_name = self.credentials["username"] ftp_password = self.credentials["password"] # if it's not anonymous using predefined credentials upload_dir = "/" return FTPClient(self.machine_ip, ftp_user_name, ftp_password, upload_dir)