Skip to content

Instantly share code, notes, and snippets.

@tylerbuchea
Created April 20, 2013 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerbuchea/5424303 to your computer and use it in GitHub Desktop.
Save tylerbuchea/5424303 to your computer and use it in GitHub Desktop.
Comprehensive FTP class
import ftplib
from ftplib import FTP
# Ftp Class
class Ftp:
conn = False
def __init__(self, address, user, password):
self.address = address
self.user = user
self.password = password
def connect(self):
Ftp.conn = FTP(self.address)
Ftp.conn.login(self.user, self.password)
def read(self):
return None
def upload(self, localFile, remoteDir):
file = open(localFile, "rb")
Ftp.conn.cwd(remoteDir)
Ftp.conn.storbinary('STOR ' + localFile, file)
file.close()
def download(self, remoteFile, localDir):
return None
def close(self):
Ftp.conn.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment