Skip to content

Instantly share code, notes, and snippets.

@themorgantown
Created January 5, 2018 00:47
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 themorgantown/0450186f556368d12f2016b0d0993f34 to your computer and use it in GitHub Desktop.
Save themorgantown/0450186f556368d12f2016b0d0993f34 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import argparse
import json
import sys
import distutils.util
import os
import pysftp # http://pysftp.readthedocs.io/en/release_0.2.8/cookbook.html#pysftp-connection
# First, install run 'pip install pysftp''
# Define sFTP credentials:
sftp = pysftp.Connection('domain.com', username='xx', password='xx')
# set remote directory. (Must exist)
sftpDir = 'wp-content/uploads/hypeanimations/'
public_html_url = 'http://tumulttest.nfshost.com' + '/' + sftpDir + '/'
HypedocumentName = 'index.html'
# Show where in the FTP directory you are.
print sftp.pwd
# todo check if you can get into sftpDIR, then run sftp.mkdir(sftpDir, mode=644) if you cannot.
sftp.put_r('toupload', sftpDir, preserve_mtime=True)
print 'Upload done.'
print os.getcwd()
# Single File.
# sftp.put('file.png', preserve_mtime=True)
sftp.close()
print 'Connection closed. Your URL is ' + public_html_url + HypedocumentName
#webbrowser.open_new_tab(public_html_url + HypedocumentName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment