Skip to content

Instantly share code, notes, and snippets.

Last active December 12, 2015 09:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poingg/4751543 to your computer and use it in GitHub Desktop.
Save poingg/4751543 to your computer and use it in GitHub Desktop.
Simple hack to have a local FTP that allows Skitch to post files to CloudPT
# Edit these only
# Where do you want your files?
MYLOCALFOLDER = '/Users/myhomedir/CloudPT/sites/'
# Don't touch below
from pyftpdlib import ftpserver
import httplib, time, os
from urlparse import urlparse
MY_NETLOC = u.netloc
if u.path == '':
MY_PATH = '/'
MY_PATH = u.path
class MyHandler(ftpserver.FTPHandler):
def on_file_received(self, file):
status = 0
retries = 20
while status != 200 and retries > 0:
conn = httplib.HTTPConnection(u.netloc)
conn.request("HEAD", MY_PATH + "/"+os.path.basename(file))
res = conn.getresponse()
status = res.status
print 'Got status {}'.format(status)
retries -= 1
if retries == 0:
print 'Gave up...'
print 'Donely done!'
def on_incomplete_file_received(self, file):
def main():
authorizer = ftpserver.DummyAuthorizer()
authorizer.add_user("skitch", "skitch", MYLOCALFOLDER, perm="elradfmw")
handler = MyHandler
# handler = ftpserver.FTPHandler
handler.authorizer = authorizer
address = ("", 2121)
ftpd = ftpserver.FTPServer(address, handler)
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment